{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/30193726","id":30193726,"diff_hunk":"@@ -0,0 +1,121 @@\n+package build\n+\n+import (\n+\t\"fmt\"\n+\t\"time\"\n+\n+\t\"code.google.com/p/go-uuid/uuid\"\n+\tkapi \"github.com/GoogleCloudPlatform/kubernetes/pkg/api\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/fields\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/labels\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/generic\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/util\"\n+\t\"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors\"\n+\n+\t\"github.com/openshift/origin/pkg/build/api\"\n+\t\"github.com/openshift/origin/pkg/build/api/validation\"\n+\tbuildutil \"github.com/openshift/origin/pkg/build/util\"\n+)\n+\n+// strategy implements behavior for nodes\n+type strategy struct {\n+\truntime.ObjectTyper\n+}\n+\n+// Decorator is used to compute duration of a build since its not stored in etcd yet\n+var Decorator = func(obj runtime.Object) error {\n+\tbuild := obj.(*api.Build)\n+\tif build.StartTimestamp == nil {\n+\t\tbuild.Duration = time.Duration(0)\n+\t} else {\n+\t\tcompletionTimestamp := build.CompletionTimestamp\n+\t\tif completionTimestamp == nil {\n+\t\t\tdummy := util.Now()\n+\t\t\tcompletionTimestamp = &dummy\n+\t\t}\n+\t\tbuild.Duration = completionTimestamp.Rfc3339Copy().Time.Sub(build.StartTimestamp.Rfc3339Copy().Time)\n+\t}\n+\treturn nil\n+}\n+\n+// Strategy is the default logic that applies when creating and updating ClusterPolicy objects.\n+var Strategy = strategy{kapi.Scheme}\n+\n+func (strategy) NamespaceScoped() bool {\n+\treturn true\n+}\n+\n+// AllowCreateOnUpdate is false for policies.\n+func (strategy) AllowCreateOnUpdate() bool {\n+\treturn false\n+}\n+\n+func (strategy) GenerateName(base string) string {\n+\treturn base\n+}\n+\n+// PrepareForCreate clears fields that are not allowed to be set by end users on creation.\n+func (strategy) PrepareForCreate(obj runtime.Object) {\n+\tbuild := obj.(*api.Build)\n+\n+\t// TODO this is preserving the old behavior, ideally we could do this in generateName but generateName\n+\t// does not have access to the full build object\n+\tif len(build.Name) == 0 {\n+\t\tif len(build.Labels[api.BuildConfigLabel]) != 0 {\n+\t\t\tbuild.Name = fmt.Sprintf(\"%s-%s\", build.Labels[api.BuildConfigLabel], uuid.NewUUID().String())\n+\t\t} else {\n+\t\t\tbuild.Name = uuid.NewUUID().String()\n+\t\t}\n+\t}\n+\n+\tif len(build.Status) == 0 {\n+\t\tbuild.Status = api.BuildStatusNew\n+\t}\n+\n+}\n+\n+// PrepareForUpdate clears fields that are not allowed to be set by end users on update.\n+func (strategy) PrepareForUpdate(obj, old runtime.Object) {\n+\t_ = obj.(*api.Build)\n+}\n+\n+// Validate validates a new policy.\n+func (strategy) Validate(ctx kapi.Context, obj runtime.Object) fielderrors.ValidationErrorList {\n+\treturn validation.ValidateBuild(obj.(*api.Build))\n+}\n+\n+// ValidateUpdate is the default update validation for an end user.\n+func (strategy) ValidateUpdate(ctx kapi.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {\n+\t// TODO: distinguish updates from create, for now, this is preserving old implementation behavior\n+\treturn validation.ValidateBuild(obj.(*api.Build))\n+}\n+\n+// CheckGracefulDelete allows a build to be gracefully deleted.\n+func (strategy) CheckGracefulDelete(obj runtime.Object, options *kapi.DeleteOptions) bool {\n+\treturn false\n+}\n+\n+// Matcher returns a generic matcher for a given label and field selector.\n+func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {\n+\treturn &generic.SelectionPredicate{\n+\t\tLabel: label,\n+\t\tField: field,\n+\t\tGetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {\n+\t\t\tbuild, ok := obj.(*api.Build)\n+\t\t\tif !ok {\n+\t\t\t\treturn nil, nil, fmt.Errorf(\"not a build\")\n+\t\t\t}\n+\t\t\treturn labels.Set(build.ObjectMeta.Labels), SelectableFields(build), nil\n+\t\t},\n+\t}\n+}\n+\n+// SelectableFields returns a label set that represents the object\n+func SelectableFields(build *api.Build) fields.Set {","path":"pkg/build/registry/build/strategy.go","position":115,"original_position":115,"commit_id":"95cdba7f8977c3363c80cd4fb1df5b4f048038cd","original_commit_id":"95cdba7f8977c3363c80cd4fb1df5b4f048038cd","user":{"login":"liggitt","id":980082,"avatar_url":"https://avatars.githubusercontent.com/u/980082?v=3","gravatar_id":"","url":"https://api.github.com/users/liggitt","html_url":"https://github.com/liggitt","followers_url":"https://api.github.com/users/liggitt/followers","following_url":"https://api.github.com/users/liggitt/following{/other_user}","gists_url":"https://api.github.com/users/liggitt/gists{/gist_id}","starred_url":"https://api.github.com/users/liggitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liggitt/subscriptions","organizations_url":"https://api.github.com/users/liggitt/orgs","repos_url":"https://api.github.com/users/liggitt/repos","events_url":"https://api.github.com/users/liggitt/events{/privacy}","received_events_url":"https://api.github.com/users/liggitt/received_events","type":"User","site_admin":false},"body":"Actually, we probably need to sweep all our objects for that... so, opened #2207","created_at":"2015-05-13T00:22:08Z","updated_at":"2015-05-13T00:22:08Z","html_url":"https://github.com/openshift/origin/pull/2204#discussion_r30193726","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/2204","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/30193726"},"html":{"href":"https://github.com/openshift/origin/pull/2204#discussion_r30193726"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/2204"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/2204","id":35267090,"html_url":"https://github.com/openshift/origin/pull/2204","diff_url":"https://github.com/openshift/origin/pull/2204.diff","patch_url":"https://github.com/openshift/origin/pull/2204.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/2204","number":2204,"state":"open","locked":false,"title":"WIP: Migrate build and build config to latest patterns in storage","user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"body":"@smarterclayton @csrwng @bparees \r\n\r\nNeed unit tests on the strategy pieces, and need to test more in general, but this is compiling at least.\r\n\r\nGive any feedback thus far ;-)","created_at":"2015-05-12T20:28:29Z","updated_at":"2015-05-13T00:22:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"298caf08aec8796519faf9946a491cbe9ffd7a90","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/2204/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/2204/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/2204/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/95cdba7f8977c3363c80cd4fb1df5b4f048038cd","head":{"label":"derekwaynecarr:build_updates","ref":"build_updates","sha":"95cdba7f8977c3363c80cd4fb1df5b4f048038cd","user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"repo":{"id":23581199,"name":"origin","full_name":"derekwaynecarr/origin","owner":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/derekwaynecarr/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/derekwaynecarr/origin","forks_url":"https://api.github.com/repos/derekwaynecarr/origin/forks","keys_url":"https://api.github.com/repos/derekwaynecarr/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/derekwaynecarr/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/derekwaynecarr/origin/teams","hooks_url":"https://api.github.com/repos/derekwaynecarr/origin/hooks","issue_events_url":"https://api.github.com/repos/derekwaynecarr/origin/issues/events{/number}","events_url":"https://api.github.com/repos/derekwaynecarr/origin/events","assignees_url":"https://api.github.com/repos/derekwaynecarr/origin/assignees{/user}","branches_url":"https://api.github.com/repos/derekwaynecarr/origin/branches{/branch}","tags_url":"https://api.github.com/repos/derekwaynecarr/origin/tags","blobs_url":"https://api.github.com/repos/derekwaynecarr/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/derekwaynecarr/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/derekwaynecarr/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/derekwaynecarr/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/derekwaynecarr/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/derekwaynecarr/origin/languages","stargazers_url":"https://api.github.com/repos/derekwaynecarr/origin/stargazers","contributors_url":"https://api.github.com/repos/derekwaynecarr/origin/contributors","subscribers_url":"https://api.github.com/repos/derekwaynecarr/origin/subscribers","subscription_url":"https://api.github.com/repos/derekwaynecarr/origin/subscription","commits_url":"https://api.github.com/repos/derekwaynecarr/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/derekwaynecarr/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/derekwaynecarr/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/derekwaynecarr/origin/issues/comments{/number}","contents_url":"https://api.github.com/repos/derekwaynecarr/origin/contents/{+path}","compare_url":"https://api.github.com/repos/derekwaynecarr/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/derekwaynecarr/origin/merges","archive_url":"https://api.github.com/repos/derekwaynecarr/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/derekwaynecarr/origin/downloads","issues_url":"https://api.github.com/repos/derekwaynecarr/origin/issues{/number}","pulls_url":"https://api.github.com/repos/derekwaynecarr/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/derekwaynecarr/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/derekwaynecarr/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/derekwaynecarr/origin/labels{/name}","releases_url":"https://api.github.com/repos/derekwaynecarr/origin/releases{/id}","created_at":"2014-09-02T14:13:12Z","updated_at":"2014-09-11T20:20:31Z","pushed_at":"2015-05-13T00:10:35Z","git_url":"git://github.com/derekwaynecarr/origin.git","ssh_url":"git@github.com:derekwaynecarr/origin.git","clone_url":"https://github.com/derekwaynecarr/origin.git","svn_url":"https://github.com/derekwaynecarr/origin","homepage":"https://openshift.github.io","size":103103,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openshift:master","ref":"master","sha":"df30dfaab7bb2bdc3c48120560fdf6b1e92c1b65","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-05-12T17:39:15Z","pushed_at":"2015-05-13T00:10:36Z","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":184570,"stargazers_count":421,"watchers_count":421,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":202,"mirror_url":null,"open_issues_count":231,"forks":202,"open_issues":231,"watchers":421,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/2204"},"html":{"href":"https://github.com/openshift/origin/pull/2204"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/2204"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/2204/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/2204/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/2204/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/95cdba7f8977c3363c80cd4fb1df5b4f048038cd"}}}}