{"action":"created","issue":{"url":"https://api.github.com/repos/docker/libcompose/issues/307","repository_url":"https://api.github.com/repos/docker/libcompose","labels_url":"https://api.github.com/repos/docker/libcompose/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/docker/libcompose/issues/307/comments","events_url":"https://api.github.com/repos/docker/libcompose/issues/307/events","html_url":"https://github.com/docker/libcompose/pull/307","id":160879190,"number":307,"title":"Load multiple type of env_file and environments","user":{"login":"dtan4","id":680124,"avatar_url":"https://avatars.githubusercontent.com/u/680124?v=3","gravatar_id":"","url":"https://api.github.com/users/dtan4","html_url":"https://github.com/dtan4","followers_url":"https://api.github.com/users/dtan4/followers","following_url":"https://api.github.com/users/dtan4/following{/other_user}","gists_url":"https://api.github.com/users/dtan4/gists{/gist_id}","starred_url":"https://api.github.com/users/dtan4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtan4/subscriptions","organizations_url":"https://api.github.com/users/dtan4/orgs","repos_url":"https://api.github.com/users/dtan4/repos","events_url":"https://api.github.com/users/dtan4/events{/privacy}","received_events_url":"https://api.github.com/users/dtan4/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/libcompose/labels/status/2-code-review","name":"status/2-code-review","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-06-17T12:39:55Z","updated_at":"2016-06-23T06:22:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/libcompose/pulls/307","html_url":"https://github.com/docker/libcompose/pull/307","diff_url":"https://github.com/docker/libcompose/pull/307.diff","patch_url":"https://github.com/docker/libcompose/pull/307.patch"},"body":"## WHAT\r\nAccept multiple types of `env_files` and `environments` in `docker-compose.yml` using type assertion and switch-statement.\r\n\r\n## WHY\r\nOriginal docker-compose.yml supports the multiple type of some configurations:\r\n\r\n- [`env_file`](https://docs.docker.com/compose/compose-file/#env-file): __string__ or __array[string]__\r\n\r\n```yaml\r\nenv_file: .env\r\n# or\r\nenv_file:\r\n  - .env\r\n```\r\n\r\n- [`environment`](https://docs.docker.com/compose/compose-file/#environment): __array[string]__ or __map[string]string__ or __map[string]int__\r\n\r\n```yaml\r\nenvironment:\r\n  - FOO=bar\r\n# or\r\nenvironment:\r\n  FOO: bar\r\n```\r\n\r\nHowever, current libcompose accepts _single_ type only. `env_file` accepts __array[string]__, `environment` accepts __array[string]__.\r\nIf unsupported type is given, `config.readEnvFile` fails with panic.\r\n\r\nwith array[string] `env_file`:\r\n\r\n```\r\nremote: panic: interface conversion: interface is string, not []interface {}\r\nremote:\r\nremote: goroutine 1 [running]:\r\nremote: panic(0xbe0c20, 0xc820017f40)\r\nremote:         /usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.readEnvFile(0x7f84e76565e8, 0x11acc38, 0xc820016240, 0x37, 0xc8201275c0, 0x5, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge.go:89 +0x161\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.parseV2(0x7f84e76565e8, 0x11acc38, 0x7f84e7656668, 0xc820014280, 0xc820016240, 0x37, 0xc8201275c0, 0xc820127560, 0x117f820, 0xc820016100, ...)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge_v2.go:95 +0x83\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.MergeServicesV2(0xc8200142c0, 0x7f84e7656668, 0xc820014280, 0x7f84e76565e8, 0x11acc38, 0xc820016240, 0x37, 0xc8202d0000, 0x3eb, 0x5eb, ...)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge_v2.go:36 +0x2e3\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.Merge(0xc8200142c0, 0x7f84e7656668, 0xc820014280, 0x7f84e76565e8, 0x11acc38, 0xc820016240, 0x37, 0xc8202d0000, 0x3eb, 0x5eb, ...)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge.go:40 +0x24c\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project.(*Project).load(0xc8201440c0, 0xc820016240, 0x37, 0xc8202d0000, 0x3eb, 0x5eb, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project/project.go:159 +0xdf\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project.(*Project).Parse(0xc8201440c0, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project/project.go:84 +0x323\r\nremote: github.com/dtan4/paus-gitreceive/receiver/model.NewCompose(0xc82019664b, 0x14, 0xc820016240, 0x37, 0xc820196720, 0x17, 0x7f84e767e270, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/model/compose.go:65 +0x466\r\nremote: main.main()\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/main.go:168 +0xc07\r\n```\r\n\r\nwith map[string]string `environments`:\r\n\r\n```\r\nremote: panic: interface conversion: interface is map[interface {}]interface {}, not []interface {}\r\nremote:\r\nremote: goroutine 1 [running]:\r\nremote: panic(0xbe0c20, 0xc820121600)\r\nremote:         /usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.readEnvFile(0x7f574fd91fb0, 0x11acc38, 0xc820120a80, 0x37, 0xc82038c150, 0x7, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge.go:109 +0x4c2\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.parseV2(0x7f574fd91fb0, 0x11acc38, 0x7f574fd92030, 0xc820126e80, 0xc820120a80, 0x37, 0xc82038c150, 0xc82038c0f0, 0x117f820, 0xc820016100, ...)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge_v2.go:95 +0x83\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.MergeServicesV2(0xc820126ec0, 0x7f574fd92030, 0xc820126e80, 0x7f574fd91fb0, 0x11acc38, 0xc820120a80, 0x37, 0xc820352c00, 0x3e6, 0x5e6, ...)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge_v2.go:36 +0x2e3\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config.Merge(0xc820126ec0, 0x7f574fd92030, 0xc820126e80, 0x7f574fd91fb0, 0x11acc38, 0xc820120a80, 0x37, 0xc820352c00, 0x3e6, 0x5e6, ...)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/config/merge.go:40 +0x24c\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project.(*Project).load(0xc82013a0c0, 0xc820120a80, 0x37, 0xc820352c00, 0x3e6, 0x5e6, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project/project.go:159 +0xdf\r\nremote: github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project.(*Project).Parse(0xc82013a0c0, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/vendor/github.com/docker/libcompose/project/project.go:84 +0x323\r\nremote: github.com/dtan4/paus-gitreceive/receiver/model.NewCompose(0xc82018c6ab, 0x14, 0xc820120a80, 0x37, 0xc82018c780, 0x17, 0x7f574fdc0270, 0x0, 0x0)\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/model/compose.go:65 +0x466\r\nremote: main.main()\r\nremote:         /Users/dtan4/src/github.com/dtan4/paus-gitreceive/receiver/main.go:168 +0xc07\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/docker/libcompose/issues/comments/227960579","html_url":"https://github.com/docker/libcompose/pull/307#issuecomment-227960579","issue_url":"https://api.github.com/repos/docker/libcompose/issues/307","id":227960579,"user":{"login":"joshwget","id":6208550,"avatar_url":"https://avatars.githubusercontent.com/u/6208550?v=3","gravatar_id":"","url":"https://api.github.com/users/joshwget","html_url":"https://github.com/joshwget","followers_url":"https://api.github.com/users/joshwget/followers","following_url":"https://api.github.com/users/joshwget/following{/other_user}","gists_url":"https://api.github.com/users/joshwget/gists{/gist_id}","starred_url":"https://api.github.com/users/joshwget/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshwget/subscriptions","organizations_url":"https://api.github.com/users/joshwget/orgs","repos_url":"https://api.github.com/users/joshwget/repos","events_url":"https://api.github.com/users/joshwget/events{/privacy}","received_events_url":"https://api.github.com/users/joshwget/received_events","type":"User","site_admin":false},"created_at":"2016-06-23T06:22:29Z","updated_at":"2016-06-23T06:22:29Z","body":"I agree this is the proper solution. `config` should use `RawService` (or maps instead of structs, more generally) which means there isn't really another way of doing this as @dtan4 said."}}
{"actor":{"display_login":"joshwget"}}