{"action":"created","comment":{"url":"https://api.github.com/repos/giantswarm/gsctl/pulls/comments/89518072","pull_request_review_id":10063277,"id":89518072,"diff_hunk":"@@ -0,0 +1,98 @@\n+package commands\n+\n+import (\n+\t\"encoding/base64\"\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"log\"\n+\t\"os\"\n+\n+\t\"github.com/fatih/color\"\n+\t\"github.com/giantswarm/gsclientgen\"\n+\t\"github.com/howeyc/gopass\"\n+\t\"github.com/spf13/cobra\"\n+\n+\t\"github.com/giantswarm/gsctl/config\"\n+)\n+\n+var (\n+\t// password given via command line flag\n+\tpassword string\n+\n+\t// LoginCommand is the \"login\" CLI command\n+\tLoginCommand = &cobra.Command{\n+\t\tUse:     \"login <email>\",\n+\t\tShort:   \"Sign in as a user\",\n+\t\tLong:    `Sign in with email address and password. Password has to be entered interactively or given as -p flag.`,\n+\t\tPreRunE: checkLogin,\n+\t\tRun:     login,\n+\t}\n+)\n+\n+func init() {\n+\tLoginCommand.Flags().StringVarP(&password, \"password\", \"p\", \"\", \"Password. If not given, will be prompted interactively.\")\n+}\n+\n+// checks if all arguments for the login command are given\n+func checkLogin(cmd *cobra.Command, args []string) error {\n+\tif len(args) < 1 {\n+\t\treturn errors.New(color.RedString(\"The email argument is required\"))\n+\t}\n+\n+\t// using auth token flag?\n+\tif cmdToken != \"\" {\n+\t\treturn errors.New(color.RedString(\"The 'login' command cannot be used with the '--auth-token' flag\"))\n+\t}\n+\n+\t// already logged in?\n+\tif config.Config.Token != \"\" {\n+\t\treturn errors.New(color.RedString(\"You are already logged in\"))\n+\t}\n+\n+\treturn nil\n+}\n+\n+// login creates a new session token\n+func login(cmd *cobra.Command, args []string) {\n+\tvar email = args[0]\n+\n+\t// interactive password prompt\n+\tif password == \"\" {\n+\t\tfmt.Printf(\"Password: \")\n+\t\tpass, err := gopass.GetPasswd()\n+\t\tif err != nil {\n+\t\t\tlog.Fatal(err)\n+\t\t}\n+\t\tpassword = string(pass)\n+\t}\n+\n+\tencodedPassword := base64.StdEncoding.EncodeToString([]byte(password))\n+\n+\tclient := gsclientgen.NewDefaultApi()\n+\trequestBody := gsclientgen.LoginBodyModel{Password: string(encodedPassword)}\n+\tloginResponse, apiResponse, err := client.UserLogin(email, requestBody)\n+\tif err != nil {\n+\t\tlog.Fatal(err)\n+\t}\n+\tif loginResponse.StatusCode == 10000 {\n+\t\t// successful login\n+\t\tfmt.Println(color.GreenString(\"Successfully logged in\"))\n+\t\tconfig.Config.Token = loginResponse.Data.Id\n+\t\tconfig.Config.Email = email\n+\t} else if loginResponse.StatusCode == 10010 {","path":"commands/login.go","position":82,"original_position":82,"commit_id":"1693e24075d93eaba349d72830d3287b01cf7f7e","original_commit_id":"1693e24075d93eaba349d72830d3287b01cf7f7e","user":{"login":"JosephSalisbury","id":297653,"avatar_url":"https://avatars.githubusercontent.com/u/297653?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephSalisbury","html_url":"https://github.com/JosephSalisbury","followers_url":"https://api.github.com/users/JosephSalisbury/followers","following_url":"https://api.github.com/users/JosephSalisbury/following{/other_user}","gists_url":"https://api.github.com/users/JosephSalisbury/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephSalisbury/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephSalisbury/subscriptions","organizations_url":"https://api.github.com/users/JosephSalisbury/orgs","repos_url":"https://api.github.com/users/JosephSalisbury/repos","events_url":"https://api.github.com/users/JosephSalisbury/events{/privacy}","received_events_url":"https://api.github.com/users/JosephSalisbury/received_events","type":"User","site_admin":false},"body":"Same here with the status codes, and in a few other places","created_at":"2016-11-24T15:38:00Z","updated_at":"2016-11-24T15:38:00Z","html_url":"https://github.com/giantswarm/gsctl/pull/1#discussion_r89518072","pull_request_url":"https://api.github.com/repos/giantswarm/gsctl/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/giantswarm/gsctl/pulls/comments/89518072"},"html":{"href":"https://github.com/giantswarm/gsctl/pull/1#discussion_r89518072"},"pull_request":{"href":"https://api.github.com/repos/giantswarm/gsctl/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/giantswarm/gsctl/pulls/1","id":94403269,"html_url":"https://github.com/giantswarm/gsctl/pull/1","diff_url":"https://github.com/giantswarm/gsctl/pull/1.diff","patch_url":"https://github.com/giantswarm/gsctl/pull/1.patch","issue_url":"https://api.github.com/repos/giantswarm/gsctl/issues/1","number":1,"state":"open","locked":false,"title":"gsctl: First version","user":{"login":"marians","id":273727,"avatar_url":"https://avatars.githubusercontent.com/u/273727?v=3","gravatar_id":"","url":"https://api.github.com/users/marians","html_url":"https://github.com/marians","followers_url":"https://api.github.com/users/marians/followers","following_url":"https://api.github.com/users/marians/following{/other_user}","gists_url":"https://api.github.com/users/marians/gists{/gist_id}","starred_url":"https://api.github.com/users/marians/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marians/subscriptions","organizations_url":"https://api.github.com/users/marians/orgs","repos_url":"https://api.github.com/users/marians/repos","events_url":"https://api.github.com/users/marians/events{/privacy}","received_events_url":"https://api.github.com/users/marians/received_events","type":"User","site_admin":false},"body":"In case you want to test:\r\n\r\n```\r\nmake\r\nmake install\r\n\r\ngsctl help\r\ngsctl info\r\ngsctl login name@example.com\r\ngsctl list organizations\r\ngsctl list clusters\r\ngsctl create kubeconfig [-c <cluster-id>]\r\ngsctl list keypairs [-c <cluster-id>]\r\ngsctl logout\r\n```\r\n\r\n### Related\r\n\r\n~~https://github.com/giantswarm/gsclientgen/pull/1~~\r\n\r\n### TODO\r\n\r\n- [x] Add VERSION file for builder\r\n- [x] Add a way to publish a release, including via homebrew\r\n- [x] Change `gsclientgen` to branch `master` when gsclientgen/#1 is merged.","created_at":"2016-11-18T17:28:40Z","updated_at":"2016-11-24T15:51:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"646d5a41a5a1ceaaae78549f63d6b9103000cfe6","assignee":{"login":"marians","id":273727,"avatar_url":"https://avatars.githubusercontent.com/u/273727?v=3","gravatar_id":"","url":"https://api.github.com/users/marians","html_url":"https://github.com/marians","followers_url":"https://api.github.com/users/marians/followers","following_url":"https://api.github.com/users/marians/following{/other_user}","gists_url":"https://api.github.com/users/marians/gists{/gist_id}","starred_url":"https://api.github.com/users/marians/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marians/subscriptions","organizations_url":"https://api.github.com/users/marians/orgs","repos_url":"https://api.github.com/users/marians/repos","events_url":"https://api.github.com/users/marians/events{/privacy}","received_events_url":"https://api.github.com/users/marians/received_events","type":"User","site_admin":false},"assignees":[{"login":"marians","id":273727,"avatar_url":"https://avatars.githubusercontent.com/u/273727?v=3","gravatar_id":"","url":"https://api.github.com/users/marians","html_url":"https://github.com/marians","followers_url":"https://api.github.com/users/marians/followers","following_url":"https://api.github.com/users/marians/following{/other_user}","gists_url":"https://api.github.com/users/marians/gists{/gist_id}","starred_url":"https://api.github.com/users/marians/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marians/subscriptions","organizations_url":"https://api.github.com/users/marians/orgs","repos_url":"https://api.github.com/users/marians/repos","events_url":"https://api.github.com/users/marians/events{/privacy}","received_events_url":"https://api.github.com/users/marians/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/giantswarm/gsctl/pulls/1/commits","review_comments_url":"https://api.github.com/repos/giantswarm/gsctl/pulls/1/comments","review_comment_url":"https://api.github.com/repos/giantswarm/gsctl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/giantswarm/gsctl/issues/1/comments","statuses_url":"https://api.github.com/repos/giantswarm/gsctl/statuses/1693e24075d93eaba349d72830d3287b01cf7f7e","head":{"label":"giantswarm:first-version","ref":"first-version","sha":"1693e24075d93eaba349d72830d3287b01cf7f7e","user":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars.githubusercontent.com/u/7556340?v=3","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"repo":{"id":74132145,"name":"gsctl","full_name":"giantswarm/gsctl","owner":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars.githubusercontent.com/u/7556340?v=3","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giantswarm/gsctl","description":"The next-generation command line interface for Giant Swarm","fork":false,"url":"https://api.github.com/repos/giantswarm/gsctl","forks_url":"https://api.github.com/repos/giantswarm/gsctl/forks","keys_url":"https://api.github.com/repos/giantswarm/gsctl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giantswarm/gsctl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giantswarm/gsctl/teams","hooks_url":"https://api.github.com/repos/giantswarm/gsctl/hooks","issue_events_url":"https://api.github.com/repos/giantswarm/gsctl/issues/events{/number}","events_url":"https://api.github.com/repos/giantswarm/gsctl/events","assignees_url":"https://api.github.com/repos/giantswarm/gsctl/assignees{/user}","branches_url":"https://api.github.com/repos/giantswarm/gsctl/branches{/branch}","tags_url":"https://api.github.com/repos/giantswarm/gsctl/tags","blobs_url":"https://api.github.com/repos/giantswarm/gsctl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giantswarm/gsctl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giantswarm/gsctl/git/refs{/sha}","trees_url":"https://api.github.com/repos/giantswarm/gsctl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giantswarm/gsctl/statuses/{sha}","languages_url":"https://api.github.com/repos/giantswarm/gsctl/languages","stargazers_url":"https://api.github.com/repos/giantswarm/gsctl/stargazers","contributors_url":"https://api.github.com/repos/giantswarm/gsctl/contributors","subscribers_url":"https://api.github.com/repos/giantswarm/gsctl/subscribers","subscription_url":"https://api.github.com/repos/giantswarm/gsctl/subscription","commits_url":"https://api.github.com/repos/giantswarm/gsctl/commits{/sha}","git_commits_url":"https://api.github.com/repos/giantswarm/gsctl/git/commits{/sha}","comments_url":"https://api.github.com/repos/giantswarm/gsctl/comments{/number}","issue_comment_url":"https://api.github.com/repos/giantswarm/gsctl/issues/comments{/number}","contents_url":"https://api.github.com/repos/giantswarm/gsctl/contents/{+path}","compare_url":"https://api.github.com/repos/giantswarm/gsctl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giantswarm/gsctl/merges","archive_url":"https://api.github.com/repos/giantswarm/gsctl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giantswarm/gsctl/downloads","issues_url":"https://api.github.com/repos/giantswarm/gsctl/issues{/number}","pulls_url":"https://api.github.com/repos/giantswarm/gsctl/pulls{/number}","milestones_url":"https://api.github.com/repos/giantswarm/gsctl/milestones{/number}","notifications_url":"https://api.github.com/repos/giantswarm/gsctl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giantswarm/gsctl/labels{/name}","releases_url":"https://api.github.com/repos/giantswarm/gsctl/releases{/id}","deployments_url":"https://api.github.com/repos/giantswarm/gsctl/deployments","created_at":"2016-11-18T13:31:19Z","updated_at":"2016-11-18T13:38:06Z","pushed_at":"2016-11-24T15:25:59Z","git_url":"git://github.com/giantswarm/gsctl.git","ssh_url":"git@github.com:giantswarm/gsctl.git","clone_url":"https://github.com/giantswarm/gsctl.git","svn_url":"https://github.com/giantswarm/gsctl","homepage":null,"size":51,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"giantswarm:master","ref":"master","sha":"92079cda8132b26c590acb0b86496d6ab7fa1d0a","user":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars.githubusercontent.com/u/7556340?v=3","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"repo":{"id":74132145,"name":"gsctl","full_name":"giantswarm/gsctl","owner":{"login":"giantswarm","id":7556340,"avatar_url":"https://avatars.githubusercontent.com/u/7556340?v=3","gravatar_id":"","url":"https://api.github.com/users/giantswarm","html_url":"https://github.com/giantswarm","followers_url":"https://api.github.com/users/giantswarm/followers","following_url":"https://api.github.com/users/giantswarm/following{/other_user}","gists_url":"https://api.github.com/users/giantswarm/gists{/gist_id}","starred_url":"https://api.github.com/users/giantswarm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giantswarm/subscriptions","organizations_url":"https://api.github.com/users/giantswarm/orgs","repos_url":"https://api.github.com/users/giantswarm/repos","events_url":"https://api.github.com/users/giantswarm/events{/privacy}","received_events_url":"https://api.github.com/users/giantswarm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/giantswarm/gsctl","description":"The next-generation command line interface for Giant Swarm","fork":false,"url":"https://api.github.com/repos/giantswarm/gsctl","forks_url":"https://api.github.com/repos/giantswarm/gsctl/forks","keys_url":"https://api.github.com/repos/giantswarm/gsctl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giantswarm/gsctl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giantswarm/gsctl/teams","hooks_url":"https://api.github.com/repos/giantswarm/gsctl/hooks","issue_events_url":"https://api.github.com/repos/giantswarm/gsctl/issues/events{/number}","events_url":"https://api.github.com/repos/giantswarm/gsctl/events","assignees_url":"https://api.github.com/repos/giantswarm/gsctl/assignees{/user}","branches_url":"https://api.github.com/repos/giantswarm/gsctl/branches{/branch}","tags_url":"https://api.github.com/repos/giantswarm/gsctl/tags","blobs_url":"https://api.github.com/repos/giantswarm/gsctl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giantswarm/gsctl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giantswarm/gsctl/git/refs{/sha}","trees_url":"https://api.github.com/repos/giantswarm/gsctl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giantswarm/gsctl/statuses/{sha}","languages_url":"https://api.github.com/repos/giantswarm/gsctl/languages","stargazers_url":"https://api.github.com/repos/giantswarm/gsctl/stargazers","contributors_url":"https://api.github.com/repos/giantswarm/gsctl/contributors","subscribers_url":"https://api.github.com/repos/giantswarm/gsctl/subscribers","subscription_url":"https://api.github.com/repos/giantswarm/gsctl/subscription","commits_url":"https://api.github.com/repos/giantswarm/gsctl/commits{/sha}","git_commits_url":"https://api.github.com/repos/giantswarm/gsctl/git/commits{/sha}","comments_url":"https://api.github.com/repos/giantswarm/gsctl/comments{/number}","issue_comment_url":"https://api.github.com/repos/giantswarm/gsctl/issues/comments{/number}","contents_url":"https://api.github.com/repos/giantswarm/gsctl/contents/{+path}","compare_url":"https://api.github.com/repos/giantswarm/gsctl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giantswarm/gsctl/merges","archive_url":"https://api.github.com/repos/giantswarm/gsctl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giantswarm/gsctl/downloads","issues_url":"https://api.github.com/repos/giantswarm/gsctl/issues{/number}","pulls_url":"https://api.github.com/repos/giantswarm/gsctl/pulls{/number}","milestones_url":"https://api.github.com/repos/giantswarm/gsctl/milestones{/number}","notifications_url":"https://api.github.com/repos/giantswarm/gsctl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giantswarm/gsctl/labels{/name}","releases_url":"https://api.github.com/repos/giantswarm/gsctl/releases{/id}","deployments_url":"https://api.github.com/repos/giantswarm/gsctl/deployments","created_at":"2016-11-18T13:31:19Z","updated_at":"2016-11-18T13:38:06Z","pushed_at":"2016-11-24T15:25:59Z","git_url":"git://github.com/giantswarm/gsctl.git","ssh_url":"git@github.com:giantswarm/gsctl.git","clone_url":"https://github.com/giantswarm/gsctl.git","svn_url":"https://github.com/giantswarm/gsctl","homepage":null,"size":51,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/giantswarm/gsctl/pulls/1"},"html":{"href":"https://github.com/giantswarm/gsctl/pull/1"},"issue":{"href":"https://api.github.com/repos/giantswarm/gsctl/issues/1"},"comments":{"href":"https://api.github.com/repos/giantswarm/gsctl/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/giantswarm/gsctl/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/giantswarm/gsctl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/giantswarm/gsctl/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/giantswarm/gsctl/statuses/1693e24075d93eaba349d72830d3287b01cf7f7e"}}}}
{"actor":{"display_login":"JosephSalisbury"}}