{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/vic/pulls/comments/73052873","id":73052873,"diff_hunk":"@@ -1756,75 +1523,150 @@ func clientFriendlyContainerName(name string) string {\n \treturn fmt.Sprintf(\"/%s\", name)\n }\n \n-//This function is used to turn any call from docker create -v <stuff> into a volumeFields object.\n-//the -v has 3 forms. 1: -v <anonymouse mount path>, -v <Volume Name>:<Destination Mount Path>, and -v <Volume Name>:<Destination Mount Path>:<mount flags>\n-func processVolumeParam(volString string) (volumeFields, error) {\n-\tvolumeStrings := strings.Split(volString, \":\")\n-\tfields := volumeFields{}\n+//------------------------------------\n+// ContainerCreate() Utility Functions\n+//------------------------------------\n \n-\t//This switch determines which type of -v was invoked.\n-\tswitch len(volumeStrings) {\n-\tcase 1:\n-\t\tVolumeID, err := uuid.NewUUID()\n-\t\tif err != nil {\n-\t\t\treturn volumeFields{}, nil\n-\t\t}\n-\t\tfields.ID = VolumeID.String()\n-\t\tfields.Dest = volumeStrings[0]\n-\t\tfields.Flags = \"rw\"\n-\tcase 2:\n-\t\tfields.ID = volumeStrings[0]\n-\t\tfields.Dest = volumeStrings[1]\n-\t\tfields.Flags = \"rw\"\n-\tcase 3:\n-\t\tfields.ID = volumeStrings[0]\n-\t\tfields.Dest = volumeStrings[1]\n-\t\tfields.Flags = volumeStrings[2]\n-\tdefault:\n-\t\t//NOTE: the docker cli should cover this case. This is here for posterity.\n-\t\treturn volumeFields{}, fmt.Errorf(\"Volume bind input is invalid : -v %s\", volString)\n-\t}\n-\treturn fields, nil\n+// createInternalVicContainer() creates an container representation (for docker personality)\n+// This is called by ContainerCreate()\n+func createInternalVicContainer(image *metadata.ImageConfig, config *types.ContainerCreateConfig) (*viccontainer.VicContainer, error) {\n+\t// provide basic container config via the image\n+\tcontainer := viccontainer.NewVicContainer()\n+\tcontainer.ID = image.ID\n+\tcontainer.Config = image.Config //Set defaults.  Overrides will get copied below.\n+\n+\treturn container, nil\n }\n \n-func processAnonymousVolumes(h *string, volumes map[string]struct{}, client *client.PortLayer) ([]volumeFields, error) {\n-\tvar volumeFields []volumeFields\n+// SetConfigOptions is a place to add necessary container configuration\n+// values that were not explicitly supplied by the user\n+func setCreateConfigOptions(config, imageConfig *containertypes.Config) {\n+\t// Overwrite or append the image's config from the CLI with the metadata from the image's\n+\t// layer metadata where appropriate\n+\tif len(config.Cmd) == 0 {\n+\t\tconfig.Cmd = imageConfig.Cmd\n+\t}\n+\tif config.WorkingDir == \"\" {\n+\t\tconfig.WorkingDir = imageConfig.WorkingDir\n+\t}\n+\tif len(config.Entrypoint) == 0 {\n+\t\tconfig.Entrypoint = imageConfig.Entrypoint\n+\t}\n+\n+\t// set up environment\n+\tsetEnvFromImageConfig(config, imageConfig)\n+}\n \n-\tfor v := range volumes {\n-\t\tfields, err := processVolumeParam(v)\n-\t\tlog.Infof(\"Processed Volume arguments : %#v\", fields)\n-\t\tif err != nil {\n-\t\t\treturn nil, err\n+func setEnvFromImageConfig(config, imageConfig *containertypes.Config) {\n+\t// Set PATH in ENV if needed\n+\tsetPathFromImageConfig(config, imageConfig)\n+\n+\tcontainerEnv := make(map[string]string, len(config.Env))\n+\tfor _, env := range config.Env {\n+\t\tkv := strings.Split(env, \"=\")\n+\t\tcontainerEnv[kv[0]] = kv[1]\n+\t}\n+\n+\t// Set TERM to xterm if tty is set, unless user supplied a different TERM\n+\tif config.Tty {\n+\t\tif _, ok := containerEnv[\"TERM\"]; !ok {\n+\t\t\tconfig.Env = append(config.Env, \"TERM=xterm\")\n \t\t}\n-\t\t//NOTE: This should be the guard for the case of an anonymous volume.\n-\t\t//NOTE: we should not expect any driver args if the drive is anonymous.\n-\t\tlog.Infof(\"anonymous volume being created - Container Create - volume mount section ID: %s \", fields.ID)\n-\t\tmetadata := make(map[string]string)\n-\t\tmetadata[\"flags\"] = fields.Flags\n-\t\tvolumeRequest := models.VolumeRequest{\n-\t\t\tCapacity: -1,\n-\t\t\tDriver:   \"vsphere\",\n-\t\t\tStore:    \"default\",\n-\t\t\tName:     fields.ID,\n-\t\t\tMetadata: metadata,\n+\t}\n+\n+\t// add remaining environment variables from the image config to the container\n+\t// config, taking care not to overwrite anything\n+\tfor _, imageEnv := range imageConfig.Env {\n+\t\tkey := strings.Split(imageEnv, \"=\")[0]","path":"lib/apiservers/engine/backends/container.go","position":599,"original_position":599,"commit_id":"1be9de75f6305031006cedcb0b4ca9165b8365ed","original_commit_id":"1be9de75f6305031006cedcb0b4ca9165b8365ed","user":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"body":"sure","created_at":"2016-08-01T21:06:10Z","updated_at":"2016-08-01T21:06:10Z","html_url":"https://github.com/vmware/vic/pull/1727#discussion_r73052873","pull_request_url":"https://api.github.com/repos/vmware/vic/pulls/1727","_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments/73052873"},"html":{"href":"https://github.com/vmware/vic/pull/1727#discussion_r73052873"},"pull_request":{"href":"https://api.github.com/repos/vmware/vic/pulls/1727"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/vic/pulls/1727","id":79265286,"html_url":"https://github.com/vmware/vic/pull/1727","diff_url":"https://github.com/vmware/vic/pull/1727.diff","patch_url":"https://github.com/vmware/vic/pull/1727.patch","issue_url":"https://api.github.com/repos/vmware/vic/issues/1727","number":1727,"state":"open","locked":false,"title":"Refactored ContainerCreate","user":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"body":"Refactored ContainerCreate().  Simplified the function.  Moved all\r\nremoting code out to ../backends/portlayer/container_proxy.go.  Also\r\nadded some infrastructure to do unit testing on the personality server\r\nand perform some error injection.","created_at":"2016-07-28T20:45:30Z","updated_at":"2016-08-01T21:06:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64faa5f0d7a36fc5bdefd9d6c224aae784f6dc41","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/vic/pulls/1727/commits","review_comments_url":"https://api.github.com/repos/vmware/vic/pulls/1727/comments","review_comment_url":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/vic/issues/1727/comments","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/1be9de75f6305031006cedcb0b4ca9165b8365ed","head":{"label":"sflxn:refactor-container-create","ref":"refactor-container-create","sha":"1be9de75f6305031006cedcb0b4ca9165b8365ed","user":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"repo":{"id":55453338,"name":"vic","full_name":"sflxn/vic","owner":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sflxn/vic","description":"Integrated containers on vSphere","fork":true,"url":"https://api.github.com/repos/sflxn/vic","forks_url":"https://api.github.com/repos/sflxn/vic/forks","keys_url":"https://api.github.com/repos/sflxn/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sflxn/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sflxn/vic/teams","hooks_url":"https://api.github.com/repos/sflxn/vic/hooks","issue_events_url":"https://api.github.com/repos/sflxn/vic/issues/events{/number}","events_url":"https://api.github.com/repos/sflxn/vic/events","assignees_url":"https://api.github.com/repos/sflxn/vic/assignees{/user}","branches_url":"https://api.github.com/repos/sflxn/vic/branches{/branch}","tags_url":"https://api.github.com/repos/sflxn/vic/tags","blobs_url":"https://api.github.com/repos/sflxn/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sflxn/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sflxn/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/sflxn/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sflxn/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/sflxn/vic/languages","stargazers_url":"https://api.github.com/repos/sflxn/vic/stargazers","contributors_url":"https://api.github.com/repos/sflxn/vic/contributors","subscribers_url":"https://api.github.com/repos/sflxn/vic/subscribers","subscription_url":"https://api.github.com/repos/sflxn/vic/subscription","commits_url":"https://api.github.com/repos/sflxn/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/sflxn/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/sflxn/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/sflxn/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/sflxn/vic/contents/{+path}","compare_url":"https://api.github.com/repos/sflxn/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sflxn/vic/merges","archive_url":"https://api.github.com/repos/sflxn/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sflxn/vic/downloads","issues_url":"https://api.github.com/repos/sflxn/vic/issues{/number}","pulls_url":"https://api.github.com/repos/sflxn/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/sflxn/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/sflxn/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sflxn/vic/labels{/name}","releases_url":"https://api.github.com/repos/sflxn/vic/releases{/id}","deployments_url":"https://api.github.com/repos/sflxn/vic/deployments","created_at":"2016-04-04T23:42:42Z","updated_at":"2016-04-04T23:42:44Z","pushed_at":"2016-08-01T17:22:26Z","git_url":"git://github.com/sflxn/vic.git","ssh_url":"git@github.com:sflxn/vic.git","clone_url":"https://github.com/sflxn/vic.git","svn_url":"https://github.com/sflxn/vic","homepage":null,"size":27052,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vmware:master","ref":"master","sha":"156488c87d37cd9598cf5df135415e3822418d03","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":49597898,"name":"vic","full_name":"vmware/vic","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/vic","description":"Integrated containers on vSphere","fork":false,"url":"https://api.github.com/repos/vmware/vic","forks_url":"https://api.github.com/repos/vmware/vic/forks","keys_url":"https://api.github.com/repos/vmware/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/vic/teams","hooks_url":"https://api.github.com/repos/vmware/vic/hooks","issue_events_url":"https://api.github.com/repos/vmware/vic/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/vic/events","assignees_url":"https://api.github.com/repos/vmware/vic/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/vic/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/vic/tags","blobs_url":"https://api.github.com/repos/vmware/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/vic/languages","stargazers_url":"https://api.github.com/repos/vmware/vic/stargazers","contributors_url":"https://api.github.com/repos/vmware/vic/contributors","subscribers_url":"https://api.github.com/repos/vmware/vic/subscribers","subscription_url":"https://api.github.com/repos/vmware/vic/subscription","commits_url":"https://api.github.com/repos/vmware/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/vic/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/vic/merges","archive_url":"https://api.github.com/repos/vmware/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/vic/downloads","issues_url":"https://api.github.com/repos/vmware/vic/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/vic/labels{/name}","releases_url":"https://api.github.com/repos/vmware/vic/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/vic/deployments","created_at":"2016-01-13T19:53:57Z","updated_at":"2016-07-28T21:42:20Z","pushed_at":"2016-08-01T21:00:58Z","git_url":"git://github.com/vmware/vic.git","ssh_url":"git@github.com:vmware/vic.git","clone_url":"https://github.com/vmware/vic.git","svn_url":"https://github.com/vmware/vic","homepage":null,"size":74567,"stargazers_count":107,"watchers_count":107,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":37,"mirror_url":null,"open_issues_count":481,"forks":37,"open_issues":481,"watchers":107,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/1727"},"html":{"href":"https://github.com/vmware/vic/pull/1727"},"issue":{"href":"https://api.github.com/repos/vmware/vic/issues/1727"},"comments":{"href":"https://api.github.com/repos/vmware/vic/issues/1727/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/vic/pulls/1727/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/vic/pulls/1727/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/vic/statuses/1be9de75f6305031006cedcb0b4ca9165b8365ed"}}}}
{"actor":{"display_login":"sflxn"}}