{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/26381100","id":26381100,"diff_hunk":"@@ -0,0 +1,325 @@\n+package cmd\n+\n+import (\n+\t\"fmt\"\n+\t\"io\"\n+\t\"os\"\n+\t\"sort\"\n+\t\"strings\"\n+\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/labels\"\n+\t\"github.com/golang/glog\"\n+\t\"github.com/openshift/origin/pkg/client\"\n+\n+\tkerrors \"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors\"\n+\tkclient \"github.com/GoogleCloudPlatform/kubernetes/pkg/client\"\n+\tkclientcmd \"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd\"\n+\tclientcmdapi \"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd/api\"\n+\t\"github.com/openshift/origin/pkg/cmd/cli/config\"\n+\t\"github.com/openshift/origin/pkg/cmd/util\"\n+\t\"github.com/openshift/origin/pkg/cmd/util/clientcmd\"\n+\tosclientcmd \"github.com/openshift/origin/pkg/cmd/util/clientcmd\"\n+\t\"github.com/openshift/origin/pkg/cmd/util/tokencmd\"\n+\t\"github.com/openshift/origin/pkg/user/api\"\n+)\n+\n+const defaultClusterURL = \"https://localhost:8443\"\n+\n+// Helper for the login and setup process, gathers all information required for a\n+// successful login and eventual update of config files.\n+// Depending on the Reader present it can be interactive, asking for terminal input in\n+// case of any missing information.\n+type LoginOptions struct {\n+\t// flags and printing helpers\n+\tUsername string\n+\tPassword string\n+\tProject  string\n+\n+\t// infra\n+\tClientConfig clientcmd.ClientConfig\n+\tConfig       *kclient.Config\n+\tReader       io.Reader\n+\n+\t// flow controllers\n+\tgatherServerInfo  bool\n+\tgatherAuthInfo    bool\n+\tgatherProjectInfo bool\n+}\n+\n+// Gather all required information in a comprehensive order.\n+func (o *LoginOptions) GatherInfo() error {\n+\tif err := o.GatherServerInfo(); err != nil {\n+\t\treturn err\n+\t}\n+\tif err := o.GatherAuthInfo(); err != nil {\n+\t\treturn err\n+\t}\n+\tif err := o.GatherProjectInfo(); err != nil {\n+\t\treturn err\n+\t}\n+\treturn nil\n+}\n+\n+// Makes sure it has all the needed information about the server we are connecting to,\n+// particularly the host address and certificate information. For every information not\n+// present ask for interactive user input. Will also ping the server to make sure we can\n+// connect to it, and if any problem is found (e.g. certificate issues), ask the user about\n+// connecting insecurely.\n+func (o *LoginOptions) GatherServerInfo() error {\n+\t// we need to have a server to talk to\n+\n+\tif util.IsTerminal(o.Reader) {\n+\t\tfor !o.serverProvided() {\n+\t\t\tdefaultServer := defaultClusterURL\n+\t\t\tpromptMsg := fmt.Sprintf(\"Please provide the server URL or just <enter> to use '%v': \", defaultServer)\n+\n+\t\t\tserver := util.PromptForStringWithDefault(o.Reader, defaultServer, promptMsg)\n+\t\t\tkclientcmd.DefaultCluster = clientcmdapi.Cluster{Server: server}","path":"pkg/cmd/cli/cmd/loginoptions.go","position":77,"original_position":77,"commit_id":"0163c849393bd7279666da791235d002761af336","original_commit_id":"0163c849393bd7279666da791235d002761af336","user":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"body":"Twiddle the server setting directly rather than setting a global (yeah, we need to fix that) in another place and relying on side effects throughout.","created_at":"2015-03-13T12:19:38Z","updated_at":"2015-03-13T12:19:38Z","html_url":"https://github.com/openshift/origin/pull/992#discussion_r26381100","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/992","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/26381100"},"html":{"href":"https://github.com/openshift/origin/pull/992#discussion_r26381100"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/992"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/992","id":29184348,"html_url":"https://github.com/openshift/origin/pull/992","diff_url":"https://github.com/openshift/origin/pull/992.diff","patch_url":"https://github.com/openshift/origin/pull/992.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/992","number":992,"state":"open","locked":false,"title":"Client setup (better login, config files and switch projects)","user":{"login":"fabianofranz","id":158611,"avatar_url":"https://avatars.githubusercontent.com/u/158611?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianofranz","html_url":"https://github.com/fabianofranz","followers_url":"https://api.github.com/users/fabianofranz/followers","following_url":"https://api.github.com/users/fabianofranz/following{/other_user}","gists_url":"https://api.github.com/users/fabianofranz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianofranz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianofranz/subscriptions","organizations_url":"https://api.github.com/users/fabianofranz/orgs","repos_url":"https://api.github.com/users/fabianofranz/repos","events_url":"https://api.github.com/users/fabianofranz/events{/privacy}","received_events_url":"https://api.github.com/users/fabianofranz/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-12T14:47:44Z","updated_at":"2015-03-13T12:19:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a3070aeaf432b6b27392e1685934ebe86a874bd1","assignee":{"login":"deads2k","id":8225098,"avatar_url":"https://avatars.githubusercontent.com/u/8225098?v=3","gravatar_id":"","url":"https://api.github.com/users/deads2k","html_url":"https://github.com/deads2k","followers_url":"https://api.github.com/users/deads2k/followers","following_url":"https://api.github.com/users/deads2k/following{/other_user}","gists_url":"https://api.github.com/users/deads2k/gists{/gist_id}","starred_url":"https://api.github.com/users/deads2k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads2k/subscriptions","organizations_url":"https://api.github.com/users/deads2k/orgs","repos_url":"https://api.github.com/users/deads2k/repos","events_url":"https://api.github.com/users/deads2k/events{/privacy}","received_events_url":"https://api.github.com/users/deads2k/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/992/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/992/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/992/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/0163c849393bd7279666da791235d002761af336","head":{"label":"fabianofranz:osc_login_further","ref":"osc_login_further","sha":"0163c849393bd7279666da791235d002761af336","user":{"login":"fabianofranz","id":158611,"avatar_url":"https://avatars.githubusercontent.com/u/158611?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianofranz","html_url":"https://github.com/fabianofranz","followers_url":"https://api.github.com/users/fabianofranz/followers","following_url":"https://api.github.com/users/fabianofranz/following{/other_user}","gists_url":"https://api.github.com/users/fabianofranz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianofranz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianofranz/subscriptions","organizations_url":"https://api.github.com/users/fabianofranz/orgs","repos_url":"https://api.github.com/users/fabianofranz/repos","events_url":"https://api.github.com/users/fabianofranz/events{/privacy}","received_events_url":"https://api.github.com/users/fabianofranz/received_events","type":"User","site_admin":false},"repo":{"id":23366851,"name":"origin","full_name":"fabianofranz/origin","owner":{"login":"fabianofranz","id":158611,"avatar_url":"https://avatars.githubusercontent.com/u/158611?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianofranz","html_url":"https://github.com/fabianofranz","followers_url":"https://api.github.com/users/fabianofranz/followers","following_url":"https://api.github.com/users/fabianofranz/following{/other_user}","gists_url":"https://api.github.com/users/fabianofranz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianofranz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianofranz/subscriptions","organizations_url":"https://api.github.com/users/fabianofranz/orgs","repos_url":"https://api.github.com/users/fabianofranz/repos","events_url":"https://api.github.com/users/fabianofranz/events{/privacy}","received_events_url":"https://api.github.com/users/fabianofranz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabianofranz/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/fabianofranz/origin","forks_url":"https://api.github.com/repos/fabianofranz/origin/forks","keys_url":"https://api.github.com/repos/fabianofranz/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabianofranz/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabianofranz/origin/teams","hooks_url":"https://api.github.com/repos/fabianofranz/origin/hooks","issue_events_url":"https://api.github.com/repos/fabianofranz/origin/issues/events{/number}","events_url":"https://api.github.com/repos/fabianofranz/origin/events","assignees_url":"https://api.github.com/repos/fabianofranz/origin/assignees{/user}","branches_url":"https://api.github.com/repos/fabianofranz/origin/branches{/branch}","tags_url":"https://api.github.com/repos/fabianofranz/origin/tags","blobs_url":"https://api.github.com/repos/fabianofranz/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabianofranz/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabianofranz/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabianofranz/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabianofranz/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/fabianofranz/origin/languages","stargazers_url":"https://api.github.com/repos/fabianofranz/origin/stargazers","contributors_url":"https://api.github.com/repos/fabianofranz/origin/contributors","subscribers_url":"https://api.github.com/repos/fabianofranz/origin/subscribers","subscription_url":"https://api.github.com/repos/fabianofranz/origin/subscription","commits_url":"https://api.github.com/repos/fabianofranz/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabianofranz/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabianofranz/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabianofranz/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabianofranz/origin/contents/{+path}","compare_url":"https://api.github.com/repos/fabianofranz/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabianofranz/origin/merges","archive_url":"https://api.github.com/repos/fabianofranz/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabianofranz/origin/downloads","issues_url":"https://api.github.com/repos/fabianofranz/origin/issues{/number}","pulls_url":"https://api.github.com/repos/fabianofranz/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/fabianofranz/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/fabianofranz/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabianofranz/origin/labels{/name}","releases_url":"https://api.github.com/repos/fabianofranz/origin/releases{/id}","created_at":"2014-08-26T21:06:40Z","updated_at":"2015-03-12T14:05:35Z","pushed_at":"2015-03-12T20:39:56Z","git_url":"git://github.com/fabianofranz/origin.git","ssh_url":"git@github.com:fabianofranz/origin.git","clone_url":"https://github.com/fabianofranz/origin.git","svn_url":"https://github.com/fabianofranz/origin","homepage":"https://openshift.github.io","size":50766,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"8dc7a6e52a4b842b90f2c1899246194bb3b69847","user":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"repo":{"id":22442668,"name":"origin","full_name":"openshift/origin","owner":{"login":"openshift","id":792337,"avatar_url":"https://avatars.githubusercontent.com/u/792337?v=3","gravatar_id":"","url":"https://api.github.com/users/openshift","html_url":"https://github.com/openshift","followers_url":"https://api.github.com/users/openshift/followers","following_url":"https://api.github.com/users/openshift/following{/other_user}","gists_url":"https://api.github.com/users/openshift/gists{/gist_id}","starred_url":"https://api.github.com/users/openshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openshift/subscriptions","organizations_url":"https://api.github.com/users/openshift/orgs","repos_url":"https://api.github.com/users/openshift/repos","events_url":"https://api.github.com/users/openshift/events{/privacy}","received_events_url":"https://api.github.com/users/openshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openshift/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":false,"url":"https://api.github.com/repos/openshift/origin","forks_url":"https://api.github.com/repos/openshift/origin/forks","keys_url":"https://api.github.com/repos/openshift/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openshift/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openshift/origin/teams","hooks_url":"https://api.github.com/repos/openshift/origin/hooks","issue_events_url":"https://api.github.com/repos/openshift/origin/issues/events{/number}","events_url":"https://api.github.com/repos/openshift/origin/events","assignees_url":"https://api.github.com/repos/openshift/origin/assignees{/user}","branches_url":"https://api.github.com/repos/openshift/origin/branches{/branch}","tags_url":"https://api.github.com/repos/openshift/origin/tags","blobs_url":"https://api.github.com/repos/openshift/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openshift/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openshift/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/openshift/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/openshift/origin/languages","stargazers_url":"https://api.github.com/repos/openshift/origin/stargazers","contributors_url":"https://api.github.com/repos/openshift/origin/contributors","subscribers_url":"https://api.github.com/repos/openshift/origin/subscribers","subscription_url":"https://api.github.com/repos/openshift/origin/subscription","commits_url":"https://api.github.com/repos/openshift/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/openshift/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/openshift/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/openshift/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/openshift/origin/contents/{+path}","compare_url":"https://api.github.com/repos/openshift/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openshift/origin/merges","archive_url":"https://api.github.com/repos/openshift/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openshift/origin/downloads","issues_url":"https://api.github.com/repos/openshift/origin/issues{/number}","pulls_url":"https://api.github.com/repos/openshift/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/openshift/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/openshift/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openshift/origin/labels{/name}","releases_url":"https://api.github.com/repos/openshift/origin/releases{/id}","created_at":"2014-07-30T20:04:05Z","updated_at":"2015-03-13T04:29:30Z","pushed_at":"2015-03-13T04:29:30Z","git_url":"git://github.com/openshift/origin.git","ssh_url":"git@github.com:openshift/origin.git","clone_url":"https://github.com/openshift/origin.git","svn_url":"https://github.com/openshift/origin","homepage":"http://www.openshift.org","size":72094,"stargazers_count":307,"watchers_count":307,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":164,"mirror_url":null,"open_issues_count":114,"forks":164,"open_issues":114,"watchers":307,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/992"},"html":{"href":"https://github.com/openshift/origin/pull/992"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/992"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/992/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/992/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/992/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/0163c849393bd7279666da791235d002761af336"}}}}