{"action":"created","comment":{"url":"https://api.github.com/repos/docker/cli/pulls/comments/189962129","pull_request_review_id":122243014,"id":189962129,"diff_hunk":"@@ -53,17 +53,23 @@ func parseKeyValueFile(filename string, emptyFn func(string) string) ([]string,\n \t\t\tif strings.ContainsAny(variable, whiteSpaces) {\n \t\t\t\treturn []string{}, ErrBadKey{fmt.Sprintf(\"variable '%s' has white spaces\", variable)}\n \t\t\t}\n+\t\t\tif len(variable) == 0 {\n+\t\t\t\treturn []string{}, ErrBadKey{fmt.Sprintf(\"no variable name on line '%s'\", line)}\n+\t\t\t}\n \n \t\t\tif len(data) > 1 {\n \t\t\t\t// pass the value through, no trimming\n \t\t\t\tlines = append(lines, fmt.Sprintf(\"%s=%s\", variable, data[1]))\n \t\t\t} else {\n \t\t\t\tvar value string","path":"opts/file.go","position":21,"original_position":21,"commit_id":"1252a119d48ecb5b723647c267bd23f0e52d42ab","original_commit_id":"1252a119d48ecb5b723647c267bd23f0e52d42ab","user":{"login":"ktomk","id":352517,"avatar_url":"https://avatars0.githubusercontent.com/u/352517?v=4","gravatar_id":"","url":"https://api.github.com/users/ktomk","html_url":"https://github.com/ktomk","followers_url":"https://api.github.com/users/ktomk/followers","following_url":"https://api.github.com/users/ktomk/following{/other_user}","gists_url":"https://api.github.com/users/ktomk/gists{/gist_id}","starred_url":"https://api.github.com/users/ktomk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktomk/subscriptions","organizations_url":"https://api.github.com/users/ktomk/orgs","repos_url":"https://api.github.com/users/ktomk/repos","events_url":"https://api.github.com/users/ktomk/events{/privacy}","received_events_url":"https://api.github.com/users/ktomk/received_events","type":"User","site_admin":false},"body":"It's not suggested within POSIX that a well-formed variable name may contain a space character, however: \"Other characters may be permitted by an implementation; applications shall tolerate the presence of such names.\" - so either refuse or accept but not alter (like trimming spaces). (quote from: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html)","created_at":"2018-05-22T16:09:38Z","updated_at":"2018-05-22T16:09:39Z","html_url":"https://github.com/docker/cli/pull/1019#discussion_r189962129","pull_request_url":"https://api.github.com/repos/docker/cli/pulls/1019","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/docker/cli/pulls/comments/189962129"},"html":{"href":"https://github.com/docker/cli/pull/1019#discussion_r189962129"},"pull_request":{"href":"https://api.github.com/repos/docker/cli/pulls/1019"}},"in_reply_to_id":189944835},"pull_request":{"url":"https://api.github.com/repos/docker/cli/pulls/1019","id":183280037,"html_url":"https://github.com/docker/cli/pull/1019","diff_url":"https://github.com/docker/cli/pull/1019.diff","patch_url":"https://github.com/docker/cli/pull/1019.patch","issue_url":"https://api.github.com/repos/docker/cli/issues/1019","number":1019,"state":"open","locked":false,"title":"import environment variables that are present","user":{"login":"ktomk","id":352517,"avatar_url":"https://avatars0.githubusercontent.com/u/352517?v=4","gravatar_id":"","url":"https://api.github.com/users/ktomk","html_url":"https://github.com/ktomk","followers_url":"https://api.github.com/users/ktomk/followers","following_url":"https://api.github.com/users/ktomk/following{/other_user}","gists_url":"https://api.github.com/users/ktomk/gists{/gist_id}","starred_url":"https://api.github.com/users/ktomk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktomk/subscriptions","organizations_url":"https://api.github.com/users/ktomk/orgs","repos_url":"https://api.github.com/users/ktomk/repos","events_url":"https://api.github.com/users/ktomk/events{/privacy}","received_events_url":"https://api.github.com/users/ktomk/received_events","type":"User","site_admin":false},"body":"fixes https://github.com/docker/for-linux/issues/284\r\n\r\npreviously docker did import environment variables if they were present\r\nbut created them if they were not when it was asked via a --env-file\r\ncli option to import but not create them.\r\n\r\nfix is to only import the variable into the environment if it is present.\r\n\r\nadditionally do not import variable names of zero-length (which are lines\r\nw/ a potential variable definition w/o a variable name).\r\n\r\nrefs:\r\n\r\n- https://github.com/docker/for-linux/issues/284\r\n\r\n\r\n<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/docker/cli/blob/master/CONTRIBUTING.md\r\n\r\n** Make sure all your commits include a signature generated with `git commit -s` **\r\n\r\nFor additional information on our contributing process, read our contributing\r\nguide https://docs.docker.com/opensource/code/\r\n\r\nIf this is a bug fix, make sure your description includes \"fixes #xxxx\", or\r\n\"closes #xxxx\"\r\n\r\nPlease provide the following information:\r\n-->\r\n\r\n**- What I did**\r\n\r\n1. Check for environment variable presence and only import if it is present.\r\n\r\n2. Check the environment variable is not with a zero-length name\r\n\r\n**- How I did it**\r\n\r\n1. Swap os.Getenv w/ os.LookupEnv for emptyFn to gain presence information and handle it\r\n\r\n2. String length check\r\n\r\n**- How to verify it**\r\n\r\nI have not run any automated test on these apart from the existing build. I'm new to go so I'm not yet comfortable adding tests.\r\n\r\n**- Description for the changelog**\r\n\r\nFix environment file parsing for imports of absent variables and those w/ no name.\r\n","created_at":"2018-04-22T15:55:17Z","updated_at":"2018-05-22T16:09:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28c81b42457c8ff760a184cdf5e67087aa46a310","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":585916071,"url":"https://api.github.com/repos/docker/cli/labels/status/2-code-review","name":"status/2-code-review","color":"fad8c7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/docker/cli/pulls/1019/commits","review_comments_url":"https://api.github.com/repos/docker/cli/pulls/1019/comments","review_comment_url":"https://api.github.com/repos/docker/cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/cli/issues/1019/comments","statuses_url":"https://api.github.com/repos/docker/cli/statuses/1252a119d48ecb5b723647c267bd23f0e52d42ab","head":{"label":"ktomk:fix-env-file","ref":"fix-env-file","sha":"1252a119d48ecb5b723647c267bd23f0e52d42ab","user":{"login":"ktomk","id":352517,"avatar_url":"https://avatars0.githubusercontent.com/u/352517?v=4","gravatar_id":"","url":"https://api.github.com/users/ktomk","html_url":"https://github.com/ktomk","followers_url":"https://api.github.com/users/ktomk/followers","following_url":"https://api.github.com/users/ktomk/following{/other_user}","gists_url":"https://api.github.com/users/ktomk/gists{/gist_id}","starred_url":"https://api.github.com/users/ktomk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktomk/subscriptions","organizations_url":"https://api.github.com/users/ktomk/orgs","repos_url":"https://api.github.com/users/ktomk/repos","events_url":"https://api.github.com/users/ktomk/events{/privacy}","received_events_url":"https://api.github.com/users/ktomk/received_events","type":"User","site_admin":false},"repo":{"id":130582505,"name":"cli","full_name":"ktomk/cli","owner":{"login":"ktomk","id":352517,"avatar_url":"https://avatars0.githubusercontent.com/u/352517?v=4","gravatar_id":"","url":"https://api.github.com/users/ktomk","html_url":"https://github.com/ktomk","followers_url":"https://api.github.com/users/ktomk/followers","following_url":"https://api.github.com/users/ktomk/following{/other_user}","gists_url":"https://api.github.com/users/ktomk/gists{/gist_id}","starred_url":"https://api.github.com/users/ktomk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktomk/subscriptions","organizations_url":"https://api.github.com/users/ktomk/orgs","repos_url":"https://api.github.com/users/ktomk/repos","events_url":"https://api.github.com/users/ktomk/events{/privacy}","received_events_url":"https://api.github.com/users/ktomk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ktomk/cli","description":"The Docker CLI","fork":true,"url":"https://api.github.com/repos/ktomk/cli","forks_url":"https://api.github.com/repos/ktomk/cli/forks","keys_url":"https://api.github.com/repos/ktomk/cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ktomk/cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ktomk/cli/teams","hooks_url":"https://api.github.com/repos/ktomk/cli/hooks","issue_events_url":"https://api.github.com/repos/ktomk/cli/issues/events{/number}","events_url":"https://api.github.com/repos/ktomk/cli/events","assignees_url":"https://api.github.com/repos/ktomk/cli/assignees{/user}","branches_url":"https://api.github.com/repos/ktomk/cli/branches{/branch}","tags_url":"https://api.github.com/repos/ktomk/cli/tags","blobs_url":"https://api.github.com/repos/ktomk/cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ktomk/cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ktomk/cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/ktomk/cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ktomk/cli/statuses/{sha}","languages_url":"https://api.github.com/repos/ktomk/cli/languages","stargazers_url":"https://api.github.com/repos/ktomk/cli/stargazers","contributors_url":"https://api.github.com/repos/ktomk/cli/contributors","subscribers_url":"https://api.github.com/repos/ktomk/cli/subscribers","subscription_url":"https://api.github.com/repos/ktomk/cli/subscription","commits_url":"https://api.github.com/repos/ktomk/cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/ktomk/cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/ktomk/cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/ktomk/cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/ktomk/cli/contents/{+path}","compare_url":"https://api.github.com/repos/ktomk/cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ktomk/cli/merges","archive_url":"https://api.github.com/repos/ktomk/cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ktomk/cli/downloads","issues_url":"https://api.github.com/repos/ktomk/cli/issues{/number}","pulls_url":"https://api.github.com/repos/ktomk/cli/pulls{/number}","milestones_url":"https://api.github.com/repos/ktomk/cli/milestones{/number}","notifications_url":"https://api.github.com/repos/ktomk/cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ktomk/cli/labels{/name}","releases_url":"https://api.github.com/repos/ktomk/cli/releases{/id}","deployments_url":"https://api.github.com/repos/ktomk/cli/deployments","created_at":"2018-04-22T15:50:17Z","updated_at":"2018-04-22T15:50:20Z","pushed_at":"2018-04-22T17:52:07Z","git_url":"git://github.com/ktomk/cli.git","ssh_url":"git@github.com:ktomk/cli.git","clone_url":"https://github.com/ktomk/cli.git","svn_url":"https://github.com/ktomk/cli","homepage":null,"size":17133,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"6c9232a5682cbfffc6a53ebb8ec9bfbb4b55381d","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars1.githubusercontent.com/u/5429470?v=4","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":88013053,"name":"cli","full_name":"docker/cli","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars1.githubusercontent.com/u/5429470?v=4","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/cli","description":"The Docker CLI","fork":false,"url":"https://api.github.com/repos/docker/cli","forks_url":"https://api.github.com/repos/docker/cli/forks","keys_url":"https://api.github.com/repos/docker/cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/cli/teams","hooks_url":"https://api.github.com/repos/docker/cli/hooks","issue_events_url":"https://api.github.com/repos/docker/cli/issues/events{/number}","events_url":"https://api.github.com/repos/docker/cli/events","assignees_url":"https://api.github.com/repos/docker/cli/assignees{/user}","branches_url":"https://api.github.com/repos/docker/cli/branches{/branch}","tags_url":"https://api.github.com/repos/docker/cli/tags","blobs_url":"https://api.github.com/repos/docker/cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/cli/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/cli/languages","stargazers_url":"https://api.github.com/repos/docker/cli/stargazers","contributors_url":"https://api.github.com/repos/docker/cli/contributors","subscribers_url":"https://api.github.com/repos/docker/cli/subscribers","subscription_url":"https://api.github.com/repos/docker/cli/subscription","commits_url":"https://api.github.com/repos/docker/cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/cli/contents/{+path}","compare_url":"https://api.github.com/repos/docker/cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/cli/merges","archive_url":"https://api.github.com/repos/docker/cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/cli/downloads","issues_url":"https://api.github.com/repos/docker/cli/issues{/number}","pulls_url":"https://api.github.com/repos/docker/cli/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/cli/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/cli/labels{/name}","releases_url":"https://api.github.com/repos/docker/cli/releases{/id}","deployments_url":"https://api.github.com/repos/docker/cli/deployments","created_at":"2017-04-12T05:27:42Z","updated_at":"2018-05-22T14:00:19Z","pushed_at":"2018-05-22T14:00:11Z","git_url":"git://github.com/docker/cli.git","ssh_url":"git@github.com:docker/cli.git","clone_url":"https://github.com/docker/cli.git","svn_url":"https://github.com/docker/cli","homepage":null,"size":17553,"stargazers_count":666,"watchers_count":666,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":420,"mirror_url":null,"archived":false,"open_issues_count":213,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":420,"open_issues":213,"watchers":666,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/cli/pulls/1019"},"html":{"href":"https://github.com/docker/cli/pull/1019"},"issue":{"href":"https://api.github.com/repos/docker/cli/issues/1019"},"comments":{"href":"https://api.github.com/repos/docker/cli/issues/1019/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/cli/pulls/1019/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/cli/pulls/1019/commits"},"statuses":{"href":"https://api.github.com/repos/docker/cli/statuses/1252a119d48ecb5b723647c267bd23f0e52d42ab"}},"author_association":"NONE"}}
{"actor":{"display_login":"ktomk"}}