{"action":"created","comment":{"url":"https://api.github.com/repos/rancher/rancher/pulls/comments/226445372","pull_request_review_id":166270668,"id":226445372,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjQ0NTM3Mg==","diff_hunk":"@@ -0,0 +1,276 @@\n+package store\n+\n+import (\n+\t\"fmt\"\n+\t\"strings\"\n+\n+\t\"github.com/rancher/norman/types/values\"\n+\n+\t\"github.com/rancher/norman/types/convert\"\n+\t\"k8s.io/apimachinery/pkg/api/errors\"\n+\n+\t\"github.com/rancher/norman/types\"\n+\t\"github.com/rancher/types/apis/core/v1\"\n+\tmanagementschema \"github.com/rancher/types/apis/management.cattle.io/v3/schema\"\n+\tprojectschema \"github.com/rancher/types/apis/project.cattle.io/v3/schema\"\n+\t\"github.com/rancher/types/config\"\n+\t\"github.com/sirupsen/logrus\"\n+\tcorev1 \"k8s.io/api/core/v1\"\n+\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n+)\n+\n+type PasswordStore struct {\n+\tSchemas     map[string]*types.Schema\n+\tFields      map[string]map[string]interface{}\n+\tStores      map[string]types.Store\n+\tsecretStore v1.SecretInterface\n+\tnsStore     v1.NamespaceInterface\n+}\n+\n+func SetPasswordStore(schemas *types.Schemas, secretStore v1.SecretInterface, nsStore v1.NamespaceInterface) {\n+\tmodifyProjectTypes := map[string]bool{\n+\t\t\"githubPipelineConfig\": true,\n+\t\t\"gitlabPipelineConfig\": true,\n+\t}\n+\n+\tpwdStore := &PasswordStore{\n+\t\tSchemas:     map[string]*types.Schema{},\n+\t\tFields:      map[string]map[string]interface{}{},\n+\t\tStores:      map[string]types.Store{},\n+\t\tsecretStore: secretStore,\n+\t\tnsStore:     nsStore,\n+\t}\n+\n+\tpwdTypes := []string{}\n+\n+\tfor _, storeType := range pwdTypes {\n+\t\tvar schema *types.Schema\n+\t\tif _, ok := modifyProjectTypes[storeType]; ok {\n+\t\t\tschema = schemas.Schema(&projectschema.Version, storeType)\n+\t\t} else {\n+\t\t\tschema = schemas.Schema(&managementschema.Version, storeType)\n+\t\t}\n+\t\tdata := getFields(schema, schemas)\n+\t\tid := schema.ID\n+\t\tpwdStore.Stores[id] = schema.Store\n+\t\tpwdStore.Fields[id] = data\n+\t\tschema.Store = pwdStore\n+\n+\t}\n+}\n+\n+func (p *PasswordStore) Create(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}) (map[string]interface{}, error) {\n+\tif err := p.replacePasswords(data, schema.ID); err != nil {\n+\t}\n+\treturn p.Stores[schema.ID].Create(apiContext, schema, data)\n+}\n+\n+func (p *PasswordStore) ByID(apiContext *types.APIContext, schema *types.Schema, id string) (map[string]interface{}, error) {\n+\tdata, err := p.Stores[schema.ID].ByID(apiContext, schema, id)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tif err := p.assignBack(data, schema.ID); err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn data, err\n+}\n+\n+func (p *PasswordStore) Context() types.StorageContext {\n+\treturn config.ManagementStorageContext\n+}\n+\n+func (p *PasswordStore) Delete(apiContext *types.APIContext, schema *types.Schema, id string) (map[string]interface{}, error) {\n+\treturn p.Stores[schema.ID].Delete(apiContext, schema, id)\n+}\n+\n+func (p *PasswordStore) List(apiContext *types.APIContext, schema *types.Schema, opt *types.QueryOptions) ([]map[string]interface{}, error) {\n+\treturn p.Stores[schema.ID].List(apiContext, schema, opt)\n+}\n+\n+func (p *PasswordStore) Update(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, id string) (map[string]interface{}, error) {\n+\tif err := p.replacePasswords(data, schema.ID); err != nil {\n+\t\treturn nil, err\n+\t}\n+\tdata, err := p.Stores[schema.ID].Update(apiContext, schema, data, id)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn data, err\n+}\n+\n+func (p *PasswordStore) Watch(apiContext *types.APIContext, schema *types.Schema, opt *types.QueryOptions) (chan map[string]interface{}, error) {\n+\treturn p.Stores[schema.ID].Watch(apiContext, schema, opt)\n+}\n+\n+type fieldInfo struct {\n+\tpaths []string\n+\tvalue string\n+}\n+\n+func (p *PasswordStore) replacePasswords(data map[string]interface{}, id string) error {\n+\tvar fieldData []fieldInfo\n+\tvar path []string\n+\tbuildFieldData(convert.ToMapInterface(p.Fields[id]), data, &fieldData, path)\n+\n+\tif err := p.handlePasswordFields(fieldData, data, id); err != nil {","path":"pkg/api/store/password/store.go","position":116,"original_position":116,"commit_id":"a8ca314e95fd11a80f67858ee1ac752b1bb3795c","original_commit_id":"a8ca314e95fd11a80f67858ee1ac752b1bb3795c","user":{"login":"alena1108","id":1562176,"node_id":"MDQ6VXNlcjE1NjIxNzY=","avatar_url":"https://avatars0.githubusercontent.com/u/1562176?v=4","gravatar_id":"","url":"https://api.github.com/users/alena1108","html_url":"https://github.com/alena1108","followers_url":"https://api.github.com/users/alena1108/followers","following_url":"https://api.github.com/users/alena1108/following{/other_user}","gists_url":"https://api.github.com/users/alena1108/gists{/gist_id}","starred_url":"https://api.github.com/users/alena1108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alena1108/subscriptions","organizations_url":"https://api.github.com/users/alena1108/orgs","repos_url":"https://api.github.com/users/alena1108/repos","events_url":"https://api.github.com/users/alena1108/events{/privacy}","received_events_url":"https://api.github.com/users/alena1108/received_events","type":"User","site_admin":false},"body":"Nit: you can just return handlePasswordFields","created_at":"2018-10-18T20:01:09Z","updated_at":"2018-10-18T20:01:09Z","html_url":"https://github.com/rancher/rancher/pull/15968#discussion_r226445372","pull_request_url":"https://api.github.com/repos/rancher/rancher/pulls/15968","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rancher/rancher/pulls/comments/226445372"},"html":{"href":"https://github.com/rancher/rancher/pull/15968#discussion_r226445372"},"pull_request":{"href":"https://api.github.com/repos/rancher/rancher/pulls/15968"}}},"pull_request":{"url":"https://api.github.com/repos/rancher/rancher/pulls/15968","id":220775175,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwNzc1MTc1","html_url":"https://github.com/rancher/rancher/pull/15968","diff_url":"https://github.com/rancher/rancher/pull/15968.diff","patch_url":"https://github.com/rancher/rancher/pull/15968.patch","issue_url":"https://api.github.com/repos/rancher/rancher/issues/15968","number":15968,"state":"open","locked":false,"title":"create secrets for password fields in authconfigs ","user":{"login":"kinarashah","id":16870565,"node_id":"MDQ6VXNlcjE2ODcwNTY1","avatar_url":"https://avatars3.githubusercontent.com/u/16870565?v=4","gravatar_id":"","url":"https://api.github.com/users/kinarashah","html_url":"https://github.com/kinarashah","followers_url":"https://api.github.com/users/kinarashah/followers","following_url":"https://api.github.com/users/kinarashah/following{/other_user}","gists_url":"https://api.github.com/users/kinarashah/gists{/gist_id}","starred_url":"https://api.github.com/users/kinarashah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinarashah/subscriptions","organizations_url":"https://api.github.com/users/kinarashah/orgs","repos_url":"https://api.github.com/users/kinarashah/repos","events_url":"https://api.github.com/users/kinarashah/events{/privacy}","received_events_url":"https://api.github.com/users/kinarashah/received_events","type":"User","site_admin":false},"body":"(Currently, this works only for authConfigs, more work to be done for \r\n- cluster and node types, should be done along with nodetemplate changes \r\n- project pipeline types, need to figure out if store can be used for them) \r\n\r\n`password/store.go` contains generic logic to create secret for any field that is of type password. To add a schema that has password fields, it needs to be added to `pwdTypes`. \r\n\r\nCreate/Update would create secret and store reference to it as value, ByID puts the actual data back. \r\n","created_at":"2018-10-05T17:42:10Z","updated_at":"2018-10-18T20:01:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"140f3df1f882a35513b63a9f3393a7d5f51f4007","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rancher/rancher/pulls/15968/commits","review_comments_url":"https://api.github.com/repos/rancher/rancher/pulls/15968/comments","review_comment_url":"https://api.github.com/repos/rancher/rancher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rancher/rancher/issues/15968/comments","statuses_url":"https://api.github.com/repos/rancher/rancher/statuses/a8ca314e95fd11a80f67858ee1ac752b1bb3795c","head":{"label":"kinarashah:newwrk","ref":"newwrk","sha":"a8ca314e95fd11a80f67858ee1ac752b1bb3795c","user":{"login":"kinarashah","id":16870565,"node_id":"MDQ6VXNlcjE2ODcwNTY1","avatar_url":"https://avatars3.githubusercontent.com/u/16870565?v=4","gravatar_id":"","url":"https://api.github.com/users/kinarashah","html_url":"https://github.com/kinarashah","followers_url":"https://api.github.com/users/kinarashah/followers","following_url":"https://api.github.com/users/kinarashah/following{/other_user}","gists_url":"https://api.github.com/users/kinarashah/gists{/gist_id}","starred_url":"https://api.github.com/users/kinarashah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinarashah/subscriptions","organizations_url":"https://api.github.com/users/kinarashah/orgs","repos_url":"https://api.github.com/users/kinarashah/repos","events_url":"https://api.github.com/users/kinarashah/events{/privacy}","received_events_url":"https://api.github.com/users/kinarashah/received_events","type":"User","site_admin":false},"repo":{"id":123647580,"node_id":"MDEwOlJlcG9zaXRvcnkxMjM2NDc1ODA=","name":"rancher","full_name":"kinarashah/rancher","private":false,"owner":{"login":"kinarashah","id":16870565,"node_id":"MDQ6VXNlcjE2ODcwNTY1","avatar_url":"https://avatars3.githubusercontent.com/u/16870565?v=4","gravatar_id":"","url":"https://api.github.com/users/kinarashah","html_url":"https://github.com/kinarashah","followers_url":"https://api.github.com/users/kinarashah/followers","following_url":"https://api.github.com/users/kinarashah/following{/other_user}","gists_url":"https://api.github.com/users/kinarashah/gists{/gist_id}","starred_url":"https://api.github.com/users/kinarashah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinarashah/subscriptions","organizations_url":"https://api.github.com/users/kinarashah/orgs","repos_url":"https://api.github.com/users/kinarashah/repos","events_url":"https://api.github.com/users/kinarashah/events{/privacy}","received_events_url":"https://api.github.com/users/kinarashah/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kinarashah/rancher","description":"Complete container management platform","fork":true,"url":"https://api.github.com/repos/kinarashah/rancher","forks_url":"https://api.github.com/repos/kinarashah/rancher/forks","keys_url":"https://api.github.com/repos/kinarashah/rancher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinarashah/rancher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinarashah/rancher/teams","hooks_url":"https://api.github.com/repos/kinarashah/rancher/hooks","issue_events_url":"https://api.github.com/repos/kinarashah/rancher/issues/events{/number}","events_url":"https://api.github.com/repos/kinarashah/rancher/events","assignees_url":"https://api.github.com/repos/kinarashah/rancher/assignees{/user}","branches_url":"https://api.github.com/repos/kinarashah/rancher/branches{/branch}","tags_url":"https://api.github.com/repos/kinarashah/rancher/tags","blobs_url":"https://api.github.com/repos/kinarashah/rancher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinarashah/rancher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinarashah/rancher/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinarashah/rancher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinarashah/rancher/statuses/{sha}","languages_url":"https://api.github.com/repos/kinarashah/rancher/languages","stargazers_url":"https://api.github.com/repos/kinarashah/rancher/stargazers","contributors_url":"https://api.github.com/repos/kinarashah/rancher/contributors","subscribers_url":"https://api.github.com/repos/kinarashah/rancher/subscribers","subscription_url":"https://api.github.com/repos/kinarashah/rancher/subscription","commits_url":"https://api.github.com/repos/kinarashah/rancher/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinarashah/rancher/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinarashah/rancher/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinarashah/rancher/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinarashah/rancher/contents/{+path}","compare_url":"https://api.github.com/repos/kinarashah/rancher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinarashah/rancher/merges","archive_url":"https://api.github.com/repos/kinarashah/rancher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinarashah/rancher/downloads","issues_url":"https://api.github.com/repos/kinarashah/rancher/issues{/number}","pulls_url":"https://api.github.com/repos/kinarashah/rancher/pulls{/number}","milestones_url":"https://api.github.com/repos/kinarashah/rancher/milestones{/number}","notifications_url":"https://api.github.com/repos/kinarashah/rancher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinarashah/rancher/labels{/name}","releases_url":"https://api.github.com/repos/kinarashah/rancher/releases{/id}","deployments_url":"https://api.github.com/repos/kinarashah/rancher/deployments","created_at":"2018-03-03T01:13:01Z","updated_at":"2018-03-03T01:13:05Z","pushed_at":"2018-10-18T18:00:14Z","git_url":"git://github.com/kinarashah/rancher.git","ssh_url":"git@github.com:kinarashah/rancher.git","clone_url":"https://github.com/kinarashah/rancher.git","svn_url":"https://github.com/kinarashah/rancher","homepage":"http://rancher.com","size":40936,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rancher:master","ref":"master","sha":"27ebd3e2f551a72e3e6633fe77da4f8f65127ff6","user":{"login":"rancher","id":9343010,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkzNDMwMTA=","avatar_url":"https://avatars3.githubusercontent.com/u/9343010?v=4","gravatar_id":"","url":"https://api.github.com/users/rancher","html_url":"https://github.com/rancher","followers_url":"https://api.github.com/users/rancher/followers","following_url":"https://api.github.com/users/rancher/following{/other_user}","gists_url":"https://api.github.com/users/rancher/gists{/gist_id}","starred_url":"https://api.github.com/users/rancher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancher/subscriptions","organizations_url":"https://api.github.com/users/rancher/orgs","repos_url":"https://api.github.com/users/rancher/repos","events_url":"https://api.github.com/users/rancher/events{/privacy}","received_events_url":"https://api.github.com/users/rancher/received_events","type":"Organization","site_admin":false},"repo":{"id":26337322,"node_id":"MDEwOlJlcG9zaXRvcnkyNjMzNzMyMg==","name":"rancher","full_name":"rancher/rancher","private":false,"owner":{"login":"rancher","id":9343010,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkzNDMwMTA=","avatar_url":"https://avatars3.githubusercontent.com/u/9343010?v=4","gravatar_id":"","url":"https://api.github.com/users/rancher","html_url":"https://github.com/rancher","followers_url":"https://api.github.com/users/rancher/followers","following_url":"https://api.github.com/users/rancher/following{/other_user}","gists_url":"https://api.github.com/users/rancher/gists{/gist_id}","starred_url":"https://api.github.com/users/rancher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancher/subscriptions","organizations_url":"https://api.github.com/users/rancher/orgs","repos_url":"https://api.github.com/users/rancher/repos","events_url":"https://api.github.com/users/rancher/events{/privacy}","received_events_url":"https://api.github.com/users/rancher/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/rancher/rancher","description":"Complete container management platform","fork":false,"url":"https://api.github.com/repos/rancher/rancher","forks_url":"https://api.github.com/repos/rancher/rancher/forks","keys_url":"https://api.github.com/repos/rancher/rancher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rancher/rancher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rancher/rancher/teams","hooks_url":"https://api.github.com/repos/rancher/rancher/hooks","issue_events_url":"https://api.github.com/repos/rancher/rancher/issues/events{/number}","events_url":"https://api.github.com/repos/rancher/rancher/events","assignees_url":"https://api.github.com/repos/rancher/rancher/assignees{/user}","branches_url":"https://api.github.com/repos/rancher/rancher/branches{/branch}","tags_url":"https://api.github.com/repos/rancher/rancher/tags","blobs_url":"https://api.github.com/repos/rancher/rancher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rancher/rancher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rancher/rancher/git/refs{/sha}","trees_url":"https://api.github.com/repos/rancher/rancher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rancher/rancher/statuses/{sha}","languages_url":"https://api.github.com/repos/rancher/rancher/languages","stargazers_url":"https://api.github.com/repos/rancher/rancher/stargazers","contributors_url":"https://api.github.com/repos/rancher/rancher/contributors","subscribers_url":"https://api.github.com/repos/rancher/rancher/subscribers","subscription_url":"https://api.github.com/repos/rancher/rancher/subscription","commits_url":"https://api.github.com/repos/rancher/rancher/commits{/sha}","git_commits_url":"https://api.github.com/repos/rancher/rancher/git/commits{/sha}","comments_url":"https://api.github.com/repos/rancher/rancher/comments{/number}","issue_comment_url":"https://api.github.com/repos/rancher/rancher/issues/comments{/number}","contents_url":"https://api.github.com/repos/rancher/rancher/contents/{+path}","compare_url":"https://api.github.com/repos/rancher/rancher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rancher/rancher/merges","archive_url":"https://api.github.com/repos/rancher/rancher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rancher/rancher/downloads","issues_url":"https://api.github.com/repos/rancher/rancher/issues{/number}","pulls_url":"https://api.github.com/repos/rancher/rancher/pulls{/number}","milestones_url":"https://api.github.com/repos/rancher/rancher/milestones{/number}","notifications_url":"https://api.github.com/repos/rancher/rancher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rancher/rancher/labels{/name}","releases_url":"https://api.github.com/repos/rancher/rancher/releases{/id}","deployments_url":"https://api.github.com/repos/rancher/rancher/deployments","created_at":"2014-11-07T20:49:31Z","updated_at":"2018-10-18T18:54:38Z","pushed_at":"2018-10-18T18:54:30Z","git_url":"git://github.com/rancher/rancher.git","ssh_url":"git@github.com:rancher/rancher.git","clone_url":"https://github.com/rancher/rancher.git","svn_url":"https://github.com/rancher/rancher","homepage":"http://rancher.com","size":40959,"stargazers_count":9737,"watchers_count":9737,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1006,"mirror_url":null,"archived":false,"open_issues_count":943,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1006,"open_issues":943,"watchers":9737,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rancher/rancher/pulls/15968"},"html":{"href":"https://github.com/rancher/rancher/pull/15968"},"issue":{"href":"https://api.github.com/repos/rancher/rancher/issues/15968"},"comments":{"href":"https://api.github.com/repos/rancher/rancher/issues/15968/comments"},"review_comments":{"href":"https://api.github.com/repos/rancher/rancher/pulls/15968/comments"},"review_comment":{"href":"https://api.github.com/repos/rancher/rancher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rancher/rancher/pulls/15968/commits"},"statuses":{"href":"https://api.github.com/repos/rancher/rancher/statuses/a8ca314e95fd11a80f67858ee1ac752b1bb3795c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"alena1108"}}