-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5321 from hashicorp/b-portmap-regression
drivers: restore port_map old json support
- Loading branch information
Showing
6 changed files
with
339 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package hclutils | ||
|
||
import ( | ||
"github.com/ugorji/go/codec" | ||
) | ||
|
||
// MapStrInt is a wrapper for map[string]int that handles | ||
// deserialization from different hcl2 json representation | ||
// that were supported in Nomad 0.8 | ||
type MapStrInt map[string]int | ||
|
||
func (s *MapStrInt) CodecEncodeSelf(enc *codec.Encoder) { | ||
v := []map[string]int{*s} | ||
enc.MustEncode(v) | ||
} | ||
|
||
func (s *MapStrInt) CodecDecodeSelf(dec *codec.Decoder) { | ||
ms := []map[string]int{} | ||
dec.MustDecode(&ms) | ||
|
||
r := map[string]int{} | ||
for _, m := range ms { | ||
for k, v := range m { | ||
r[k] = v | ||
} | ||
} | ||
*s = r | ||
} | ||
|
||
// MapStrStr is a wrapper for map[string]string that handles | ||
// deserialization from different hcl2 json representation | ||
// that were supported in Nomad 0.8 | ||
type MapStrStr map[string]string | ||
|
||
func (s *MapStrStr) CodecEncodeSelf(enc *codec.Encoder) { | ||
v := []map[string]string{*s} | ||
enc.MustEncode(v) | ||
} | ||
|
||
func (s *MapStrStr) CodecDecodeSelf(dec *codec.Decoder) { | ||
ms := []map[string]string{} | ||
dec.MustDecode(&ms) | ||
|
||
r := map[string]string{} | ||
for _, m := range ms { | ||
for k, v := range m { | ||
r[k] = v | ||
} | ||
} | ||
*s = r | ||
} |
Oops, something went wrong.