open-nomad/helper
Mahmood Ali 46cd3c3f55 drivers: restore port_map old json support
This ensures that `port_map` along with other block like attribute
declarations (e.g. ulimit, labels, etc) can handle various hcl and json
syntax that was supported in 0.8.

In 0.8.7, the following declarations are effectively equivalent:

```
// hcl block
port_map {
  http = 80
  https = 443
}

// hcl assignment
port_map = {
  http  = 80
  https = 443
}

// json single element array of map (default in API response)
{"port_map": [{"http": 80, "https": 443}]}

// json array of individual maps (supported accidentally iiuc)
{"port_map: [{"http": 80}, {"https": 443}]}
```

We achieve compatbility by using `NewAttr("...", "list(map(string))",
false)` to be serialized to a `map[string]string` wrapper, instead of using
`BlockAttrs` declaration.  The wrapper merges the list of maps
automatically, to ease driver development.

This approach is closer to how v0.8.7 implemented the fields [1][2], and
despite its verbosity, seems to perserve 0.8.7 behavior in hcl2.

This is only required for built-in types that have backward
compatibility constraints.  External drivers should use `BlockAttrs`
instead, as they see fit.

[1] https://github.com/hashicorp/nomad/blob/v0.8.7/client/driver/docker.go#L216
[2] https://github.com/hashicorp/nomad/blob/v0.8.7/client/driver/docker.go#L698-L700
2019-02-16 11:37:33 -05:00
..
args address review comments 2018-10-30 13:58:52 -04:00
boltdd client/state: improve upgradeTaskBucket error handling 2018-12-19 10:39:27 -08:00
codec Pull inmem codec to helper 2018-02-15 13:59:00 -08:00
discover skip running test executables 2017-10-19 16:49:57 -07:00
fields goimports 2019-01-22 15:44:31 -08:00
flag-helpers
flatmap
gated-writer
pluginutils drivers: restore port_map old json support 2019-02-16 11:37:33 -05:00
pool yamux 2018-09-17 14:22:40 -07:00
stats Extend timeout based on user feedback 2018-06-21 15:27:56 -04:00
testlog agent + consul 2018-09-13 10:43:40 -07:00
testtask Update helper/testtask/testtask_windows.go 2019-01-17 18:43:14 +01:00
tlsutil config: accept CA PEM files with extra whitespace 2018-09-06 11:38:56 -07:00
useragent Set user-agent when talking to GCE metadata 2018-04-10 10:36:46 -04:00
uuid Remove structs import from api 2017-09-29 10:36:08 -07:00
funcs.go Update comment on int8ToPtr 2019-01-30 12:23:43 -08:00
funcs_test.go api: move formatFloat function 2019-01-18 15:31:31 -05:00