open-nomad/drivers/docker
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
..
cmd Plugins use parent loggers 2019-01-11 11:36:37 -08:00
docklog Nomad 0.9.0-beta1 generated code 2019-01-30 10:49:44 -08:00
test-resources/docker tests: pin busybox image to a specific point tag 2018-12-15 15:03:56 -05:00
config.go drivers: restore port_map old json support 2019-02-16 11:37:33 -05:00
config_test.go drivers: restore port_map old json support 2019-02-16 11:37:33 -05:00
coordinator.go docker: unexport new coordinator func 2018-11-19 23:07:07 -05:00
coordinator_test.go docker: unexport new coordinator func 2018-11-19 23:07:07 -05:00
driver.go drivers/docker: SIGTERM to stop containers 2019-02-14 15:38:54 +00:00
driver_darwin_test.go tests: run docker tests in macOS out of box 2019-01-08 14:35:40 -05:00
driver_default.go docker: started work on porting docker driver to new plugin framework 2018-11-19 22:59:15 -05:00
driver_linux_test.go tests: helper function for checking docker presense 2019-01-07 08:27:06 -05:00
driver_pre09.go client: fix bug during 0.8 state up grade that causes external drivers to fail 2019-01-30 14:22:29 -05:00
driver_test.go goimports until make check is happy 2019-01-23 06:27:14 -08:00
driver_unix_test.go docker: Only run Cleanup test on unix os' 2019-01-17 18:43:14 +01:00
driver_windows.go docker: started work on porting docker driver to new plugin framework 2018-11-19 22:59:15 -05:00
driver_windows_test.go chore: General Cleanup 2019-01-17 18:43:14 +01:00
fingerprint.go docker: only log missing bridge_ip on initial fingerprint 2019-01-24 22:34:57 -05:00
handle.go Don't fall through 2019-01-28 09:53:19 -08:00
progress.go docker: started work on porting docker driver to new plugin framework 2018-11-19 22:59:15 -05:00
progress_test.go docker: started work on porting docker driver to new plugin framework 2018-11-19 22:59:15 -05:00
state.go docker: started work on porting docker driver to new plugin framework 2018-11-19 22:59:15 -05:00
stats.go Track Basic Memory Usage as reported by cgroups 2019-01-14 18:47:52 -05:00
stats_test.go Track Basic Memory Usage as reported by cgroups 2019-01-14 18:47:52 -05:00
utils.go drivers/docker: enforce volumes.enabled (#4983) 2018-12-11 14:22:50 -05:00
utils_test.go docker: Test cleanup for windows 2019-01-17 18:43:14 +01:00
utils_unix_test.go docker: Test cleanup for windows 2019-01-17 18:43:14 +01:00
utils_windows_test.go docker: Test cleanup for windows 2019-01-17 18:43:14 +01:00