{"action":"created","comment":{"url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/comments/223958793","pull_request_review_id":163210650,"id":223958793,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzk1ODc5Mw==","diff_hunk":"@@ -0,0 +1,121 @@\n+// Copyright 2018 The Operator-SDK Authors\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+// Modified from github.com/kubernetes-sigs/controller-tools/pkg/scaffold/input/input.go\n+\n+package input\n+\n+// IfExistsAction determines what to do if the scaffold file already exists\n+type IfExistsAction int\n+\n+const (\n+\t// Overwrite truncates and overwrites the existing file (default)\n+\tOverwrite IfExistsAction = iota\n+\n+\t// Error returns an error and stops processing\n+\tError\n+\n+\t// Skip skips the file and moves to the next one\n+\tSkip\n+)\n+\n+// Input is the input for scaffoldig a file\n+type Input struct {\n+\t// Path is the file to write\n+\tPath string\n+\n+\t// IfExistsAction determines what to do if the file exists\n+\tIfExistsAction IfExistsAction\n+\t\n+\t// IsExec indicates whether the file should be written with executable\n+\t// permissions.\n+\t// Defaults to false\n+\tIsExec bool\n+\n+\t// TemplateBody is the template body to execute\n+\tTemplateBody string\n+\n+\t// Repo is the go project package\n+\tRepo string\n+\n+\t// ProjectPath is the relative path to the project root\n+\tProjectPath string\n+\n+\t// ProjectName is the operator's name, ex. app-operator\n+\tProjectName string\n+}\n+\n+// Repo allows a repo to be set on an object\n+type Repo interface {\n+\t// SetRepo sets the repo\n+\tSetRepo(string)\n+}\n+\n+// SetRepo sets the repo\n+func (i *Input) SetRepo(r string) {\n+\tif i.Repo == \"\" {\n+\t\ti.Repo = r\n+\t}\n+}\n+\n+// ProjectPath allows the project path to be set on an object\n+type ProjectPath interface {\n+\t// SetProjectPath sets the project file location\n+\tSetProjectPath(string)\n+}\n+\n+// SetProjectPath sets the project path\n+func (i *Input) SetProjectPath(p string) {\n+\tif i.ProjectPath == \"\" {\n+\t\ti.ProjectPath = p\n+\t}\n+}\n+\n+// ProjectName allows the project name to be set on an object\n+type ProjectName interface {\n+\t// SetProjectName sets the project name\n+\tSetProjectName(string)\n+}\n+\n+// SetProjectName sets the project name\n+func (i *Input) SetProjectName(n string) {\n+\tif i.ProjectName == \"\" {\n+\t\ti.ProjectName = n\n+\t}\n+}\n+\n+// File is a scaffoldable file\n+type File interface {\n+\t// GetInput returns the Input for creating a scaffold file\n+\tGetInput() (Input, error)\n+}\n+\n+// Validate validates input\n+type Validate interface {\n+\t// Validate returns nil if the inputs' validation logic approves of\n+\t// field values, the template, etc.\n+\tValidate() error\n+}\n+\n+// Config configures the execution scaffold templates\n+type Config struct {\n+\t// Repo is the go project package\n+\tRepo string\n+\n+\t// ProjectPath is the relative path to the project root","path":"pkg/scaffold/input/input.go","position":116,"original_position":116,"commit_id":"b678a05ec3f7b11beff273a70249588b74145dd3","original_commit_id":"b678a05ec3f7b11beff273a70249588b74145dd3","user":{"login":"hasbro17","id":6660644,"node_id":"MDQ6VXNlcjY2NjA2NDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/6660644?v=4","gravatar_id":"","url":"https://api.github.com/users/hasbro17","html_url":"https://github.com/hasbro17","followers_url":"https://api.github.com/users/hasbro17/followers","following_url":"https://api.github.com/users/hasbro17/following{/other_user}","gists_url":"https://api.github.com/users/hasbro17/gists{/gist_id}","starred_url":"https://api.github.com/users/hasbro17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasbro17/subscriptions","organizations_url":"https://api.github.com/users/hasbro17/orgs","repos_url":"https://api.github.com/users/hasbro17/repos","events_url":"https://api.github.com/users/hasbro17/events{/privacy}","received_events_url":"https://api.github.com/users/hasbro17/received_events","type":"User","site_admin":false},"body":"Absolute path to the project directory","created_at":"2018-10-10T07:11:18Z","updated_at":"2018-10-10T07:11:18Z","html_url":"https://github.com/operator-framework/operator-sdk/pull/581#discussion_r223958793","pull_request_url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/comments/223958793"},"html":{"href":"https://github.com/operator-framework/operator-sdk/pull/581#discussion_r223958793"},"pull_request":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581"}}},"pull_request":{"url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581","id":220837529,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwODM3NTI5","html_url":"https://github.com/operator-framework/operator-sdk/pull/581","diff_url":"https://github.com/operator-framework/operator-sdk/pull/581.diff","patch_url":"https://github.com/operator-framework/operator-sdk/pull/581.patch","issue_url":"https://api.github.com/repos/operator-framework/operator-sdk/issues/581","number":581,"state":"open","locked":false,"title":"Refactor file generation using abstractions","user":{"login":"estroz","id":12985147,"node_id":"MDQ6VXNlcjEyOTg1MTQ3","avatar_url":"https://avatars2.githubusercontent.com/u/12985147?v=4","gravatar_id":"","url":"https://api.github.com/users/estroz","html_url":"https://github.com/estroz","followers_url":"https://api.github.com/users/estroz/followers","following_url":"https://api.github.com/users/estroz/following{/other_user}","gists_url":"https://api.github.com/users/estroz/gists{/gist_id}","starred_url":"https://api.github.com/users/estroz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estroz/subscriptions","organizations_url":"https://api.github.com/users/estroz/orgs","repos_url":"https://api.github.com/users/estroz/repos","events_url":"https://api.github.com/users/estroz/events{/privacy}","received_events_url":"https://api.github.com/users/estroz/received_events","type":"User","site_admin":false},"body":"Previously file generation involved a lot of repeated code for creating directories, filepaths, and writing files. Using the abstraction mechanism implemented in [`kubernetes-sigs/controller-tools`](https://github.com/kubernetes-sigs/controller-tools), `operator-sdk` file sub-commands that generate files, specifically `new` and `add`, succinctly generate files in a configurable manner. This abstraction allows additions to the project scaffold with few code changes.\r\n\r\n**Note**: this PR is large. The important interfaces can be found in `pkg/scaffold/scaffold.go`, `pkg/scaffold/input`; other files in `pkg/scaffold` serve as constant state stores, ex. path information and templates.","created_at":"2018-10-05T22:16:11Z","updated_at":"2018-10-10T07:11:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6127fee0ec65d7a5ad65878fd5cebb450bfda950","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":955684118,"node_id":"MDU6TGFiZWw5NTU2ODQxMTg=","url":"https://api.github.com/repos/operator-framework/operator-sdk/labels/design","name":"design","color":"db1ed1","default":false},{"id":955679398,"node_id":"MDU6TGFiZWw5NTU2NzkzOTg=","url":"https://api.github.com/repos/operator-framework/operator-sdk/labels/refactoring","name":"refactoring","color":"1d76db","default":false},{"id":1076893593,"node_id":"MDU6TGFiZWwxMDc2ODkzNTkz","url":"https://api.github.com/repos/operator-framework/operator-sdk/labels/size/XXL","name":"size/XXL","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581/commits","review_comments_url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581/comments","review_comment_url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/operator-framework/operator-sdk/issues/581/comments","statuses_url":"https://api.github.com/repos/operator-framework/operator-sdk/statuses/b678a05ec3f7b11beff273a70249588b74145dd3","head":{"label":"estroz:refactor/re-codegen","ref":"refactor/re-codegen","sha":"b678a05ec3f7b11beff273a70249588b74145dd3","user":{"login":"estroz","id":12985147,"node_id":"MDQ6VXNlcjEyOTg1MTQ3","avatar_url":"https://avatars2.githubusercontent.com/u/12985147?v=4","gravatar_id":"","url":"https://api.github.com/users/estroz","html_url":"https://github.com/estroz","followers_url":"https://api.github.com/users/estroz/followers","following_url":"https://api.github.com/users/estroz/following{/other_user}","gists_url":"https://api.github.com/users/estroz/gists{/gist_id}","starred_url":"https://api.github.com/users/estroz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estroz/subscriptions","organizations_url":"https://api.github.com/users/estroz/orgs","repos_url":"https://api.github.com/users/estroz/repos","events_url":"https://api.github.com/users/estroz/events{/privacy}","received_events_url":"https://api.github.com/users/estroz/received_events","type":"User","site_admin":false},"repo":{"id":145748873,"node_id":"MDEwOlJlcG9zaXRvcnkxNDU3NDg4NzM=","name":"operator-sdk","full_name":"estroz/operator-sdk","private":false,"owner":{"login":"estroz","id":12985147,"node_id":"MDQ6VXNlcjEyOTg1MTQ3","avatar_url":"https://avatars2.githubusercontent.com/u/12985147?v=4","gravatar_id":"","url":"https://api.github.com/users/estroz","html_url":"https://github.com/estroz","followers_url":"https://api.github.com/users/estroz/followers","following_url":"https://api.github.com/users/estroz/following{/other_user}","gists_url":"https://api.github.com/users/estroz/gists{/gist_id}","starred_url":"https://api.github.com/users/estroz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estroz/subscriptions","organizations_url":"https://api.github.com/users/estroz/orgs","repos_url":"https://api.github.com/users/estroz/repos","events_url":"https://api.github.com/users/estroz/events{/privacy}","received_events_url":"https://api.github.com/users/estroz/received_events","type":"User","site_admin":false},"html_url":"https://github.com/estroz/operator-sdk","description":"SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.","fork":true,"url":"https://api.github.com/repos/estroz/operator-sdk","forks_url":"https://api.github.com/repos/estroz/operator-sdk/forks","keys_url":"https://api.github.com/repos/estroz/operator-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/estroz/operator-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/estroz/operator-sdk/teams","hooks_url":"https://api.github.com/repos/estroz/operator-sdk/hooks","issue_events_url":"https://api.github.com/repos/estroz/operator-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/estroz/operator-sdk/events","assignees_url":"https://api.github.com/repos/estroz/operator-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/estroz/operator-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/estroz/operator-sdk/tags","blobs_url":"https://api.github.com/repos/estroz/operator-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/estroz/operator-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/estroz/operator-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/estroz/operator-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/estroz/operator-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/estroz/operator-sdk/languages","stargazers_url":"https://api.github.com/repos/estroz/operator-sdk/stargazers","contributors_url":"https://api.github.com/repos/estroz/operator-sdk/contributors","subscribers_url":"https://api.github.com/repos/estroz/operator-sdk/subscribers","subscription_url":"https://api.github.com/repos/estroz/operator-sdk/subscription","commits_url":"https://api.github.com/repos/estroz/operator-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/estroz/operator-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/estroz/operator-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/estroz/operator-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/estroz/operator-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/estroz/operator-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/estroz/operator-sdk/merges","archive_url":"https://api.github.com/repos/estroz/operator-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/estroz/operator-sdk/downloads","issues_url":"https://api.github.com/repos/estroz/operator-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/estroz/operator-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/estroz/operator-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/estroz/operator-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/estroz/operator-sdk/labels{/name}","releases_url":"https://api.github.com/repos/estroz/operator-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/estroz/operator-sdk/deployments","created_at":"2018-08-22T18:42:42Z","updated_at":"2018-10-10T00:52:46Z","pushed_at":"2018-10-10T01:06:43Z","git_url":"git://github.com/estroz/operator-sdk.git","ssh_url":"git@github.com:estroz/operator-sdk.git","clone_url":"https://github.com/estroz/operator-sdk.git","svn_url":"https://github.com/estroz/operator-sdk","homepage":"https://coreos.com/operators","size":1490,"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":"operator-framework:refactor/controller-runtime","ref":"refactor/controller-runtime","sha":"909013f462419f8b60d58641b6234ec5b12a18c8","user":{"login":"operator-framework","id":38202270,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MjAyMjcw","avatar_url":"https://avatars0.githubusercontent.com/u/38202270?v=4","gravatar_id":"","url":"https://api.github.com/users/operator-framework","html_url":"https://github.com/operator-framework","followers_url":"https://api.github.com/users/operator-framework/followers","following_url":"https://api.github.com/users/operator-framework/following{/other_user}","gists_url":"https://api.github.com/users/operator-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/operator-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/operator-framework/subscriptions","organizations_url":"https://api.github.com/users/operator-framework/orgs","repos_url":"https://api.github.com/users/operator-framework/repos","events_url":"https://api.github.com/users/operator-framework/events{/privacy}","received_events_url":"https://api.github.com/users/operator-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":120650407,"node_id":"MDEwOlJlcG9zaXRvcnkxMjA2NTA0MDc=","name":"operator-sdk","full_name":"operator-framework/operator-sdk","private":false,"owner":{"login":"operator-framework","id":38202270,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4MjAyMjcw","avatar_url":"https://avatars0.githubusercontent.com/u/38202270?v=4","gravatar_id":"","url":"https://api.github.com/users/operator-framework","html_url":"https://github.com/operator-framework","followers_url":"https://api.github.com/users/operator-framework/followers","following_url":"https://api.github.com/users/operator-framework/following{/other_user}","gists_url":"https://api.github.com/users/operator-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/operator-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/operator-framework/subscriptions","organizations_url":"https://api.github.com/users/operator-framework/orgs","repos_url":"https://api.github.com/users/operator-framework/repos","events_url":"https://api.github.com/users/operator-framework/events{/privacy}","received_events_url":"https://api.github.com/users/operator-framework/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/operator-framework/operator-sdk","description":"SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.","fork":false,"url":"https://api.github.com/repos/operator-framework/operator-sdk","forks_url":"https://api.github.com/repos/operator-framework/operator-sdk/forks","keys_url":"https://api.github.com/repos/operator-framework/operator-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/operator-framework/operator-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/operator-framework/operator-sdk/teams","hooks_url":"https://api.github.com/repos/operator-framework/operator-sdk/hooks","issue_events_url":"https://api.github.com/repos/operator-framework/operator-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/operator-framework/operator-sdk/events","assignees_url":"https://api.github.com/repos/operator-framework/operator-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/operator-framework/operator-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/operator-framework/operator-sdk/tags","blobs_url":"https://api.github.com/repos/operator-framework/operator-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/operator-framework/operator-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/operator-framework/operator-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/operator-framework/operator-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/operator-framework/operator-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/operator-framework/operator-sdk/languages","stargazers_url":"https://api.github.com/repos/operator-framework/operator-sdk/stargazers","contributors_url":"https://api.github.com/repos/operator-framework/operator-sdk/contributors","subscribers_url":"https://api.github.com/repos/operator-framework/operator-sdk/subscribers","subscription_url":"https://api.github.com/repos/operator-framework/operator-sdk/subscription","commits_url":"https://api.github.com/repos/operator-framework/operator-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/operator-framework/operator-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/operator-framework/operator-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/operator-framework/operator-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/operator-framework/operator-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/operator-framework/operator-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/operator-framework/operator-sdk/merges","archive_url":"https://api.github.com/repos/operator-framework/operator-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/operator-framework/operator-sdk/downloads","issues_url":"https://api.github.com/repos/operator-framework/operator-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/operator-framework/operator-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/operator-framework/operator-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/operator-framework/operator-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/operator-framework/operator-sdk/labels{/name}","releases_url":"https://api.github.com/repos/operator-framework/operator-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/operator-framework/operator-sdk/deployments","created_at":"2018-02-07T17:53:51Z","updated_at":"2018-10-09T17:43:14Z","pushed_at":"2018-10-10T01:06:45Z","git_url":"git://github.com/operator-framework/operator-sdk.git","ssh_url":"git@github.com:operator-framework/operator-sdk.git","clone_url":"https://github.com/operator-framework/operator-sdk.git","svn_url":"https://github.com/operator-framework/operator-sdk","homepage":"https://coreos.com/operators","size":1328,"stargazers_count":842,"watchers_count":842,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":148,"mirror_url":null,"archived":false,"open_issues_count":89,"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":148,"open_issues":89,"watchers":842,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581"},"html":{"href":"https://github.com/operator-framework/operator-sdk/pull/581"},"issue":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/issues/581"},"comments":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/issues/581/comments"},"review_comments":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581/comments"},"review_comment":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/pulls/581/commits"},"statuses":{"href":"https://api.github.com/repos/operator-framework/operator-sdk/statuses/b678a05ec3f7b11beff273a70249588b74145dd3"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"hasbro17"}}