{"action":"created","comment":{"url":"https://api.github.com/repos/openshift/origin/pulls/comments/23870487","id":23870487,"diff_hunk":"@@ -0,0 +1,122 @@\n+package cmd\n+\n+import (\n+\t\"fmt\"\n+\t\"io\"\n+\n+\t\"github.com/spf13/cobra\"\n+\n+\tkubectl \"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl\"\n+\tkcmd \"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd\"\n+\n+\tdescribe \"github.com/openshift/origin/pkg/cmd/cli/describe\"\n+\tdeployapi \"github.com/openshift/origin/pkg/deploy/api\"\n+)\n+\n+const rollbackLongDesc = `\n+Revert part of an application back to a previous deployment.\n+\n+When you run this command your deployment configuration will be updated to match\n+the provided deployment. By default only the pod and container configuration\n+will be changed and scaling or trigger settings will be left as-is. Note that\n+environment variables and volumes are included in rollbacks, so if you've\n+recently updated security credentials in your environment your previous\n+deployment may not have the correct values.\n+\n+If you would like to review the outcome of the rollback, pass '--dry-run' to print\n+a human-readable representation of the updated deployment configuration instead of\n+executing the rollback. This is useful if you're not quite sure what the outcome\n+will be.\n+\n+Examples:\n+  Perform a rollback:\n+\n+  $ %[1]s %[2]s deployment-2\n+\n+  See what the rollback will look like, but don't perform the rollback:\n+\n+  $ %[1]s %[2]s deployment-1 --dry-run\n+\n+  Perform the rollback manually by piping the JSON of the new config back to %[1]s:\n+\n+  $ %[1]s %[2]s deployment-1 --output=json | %[1]s update deploymentConfigs deployment -f -\n+`\n+\n+func NewCmdRollback(parentName string, name string, f *Factory, out io.Writer) *cobra.Command {\n+\trollback := &deployapi.DeploymentConfigRollback{\n+\t\tSpec: deployapi.DeploymentConfigRollbackSpec{\n+\t\t\tIncludeTemplate: true,\n+\t\t},\n+\t}\n+\n+\tcmd := &cobra.Command{\n+\t\tUse:   fmt.Sprintf(\"%s <from-deployment>\", name),\n+\t\tShort: \"Revert part of an application back to a previous deployment.\",\n+\t\tLong:  fmt.Sprintf(rollbackLongDesc, parentName, name),\n+\t\tRun: func(cmd *cobra.Command, args []string) {\n+\t\t\tif len(args) == 0 || len(args[0]) == 0 {\n+\t\t\t\tusageError(cmd, \"A deployment name is required.\")\n+\t\t\t}\n+\n+\t\t\trollback.Spec.From.Name = args[0]\n+\n+\t\t\toutputFormat := kcmd.GetFlagString(cmd, \"output\")\n+\t\t\toutputTemplate := kcmd.GetFlagString(cmd, \"template\")\n+\t\t\tdryRun := kcmd.GetFlagBool(cmd, \"dry-run\")\n+\n+\t\t\tosClient, _, err := f.Clients(cmd)\n+\t\t\tcheckErr(err)\n+\n+\t\t\tnamespace := getOriginNamespace(cmd)\n+\n+\t\t\t// Generate the rollback config\n+\t\t\tnewConfig, err := osClient.DeploymentConfigs(namespace).Rollback(rollback)\n+\t\t\tcheckErr(err)\n+\n+\t\t\t// If dry-run is specified, describe the rollback and exit\n+\t\t\tif dryRun {\n+\t\t\t\tdescriber := &describe.DeploymentConfigDescriber{\n+\t\t\t\t\tClient: &rollbackDeploymentDescriberClient{\n+\t\t\t\t\t\tgetDeploymentConfig: func(namespace, name string) (*deployapi.DeploymentConfig, error) {\n+\t\t\t\t\t\t\treturn newConfig, nil\n+\t\t\t\t\t\t},\n+\t\t\t\t\t},\n+\t\t\t\t}\n+\t\t\t\tdescription, descErr := describer.Describe(newConfig.Namespace, newConfig.Name)\n+\t\t\t\tcheckErr(descErr)\n+\t\t\t\tout.Write([]byte(description))\n+\t\t\t\treturn\n+\t\t\t}\n+\n+\t\t\t// If an output format is specified, display the rollback config JSON and exit\n+\t\t\t// WITHOUT performing a rollback.\n+\t\t\tif len(outputFormat) > 0 {\n+\t\t\t\tprinter, _, perr := kubectl.GetPrinter(outputFormat, outputTemplate)\n+\t\t\t\tcheckErr(perr)\n+\t\t\t\tprinter.PrintObj(newConfig, out)\n+\t\t\t\treturn\n+\t\t\t}\n+\n+\t\t\t// Apply the rollback config\n+\t\t\t_, updateErr := osClient.DeploymentConfigs(namespace).Update(newConfig)\n+\t\t\tcheckErr(updateErr)\n+\t\t},\n+\t}\n+\n+\tcmd.Flags().BoolVar(&rollback.Spec.IncludeTriggers, \"change-triggers\", false, \"Include the previous deployment's triggers in the rollback\")\n+\tcmd.Flags().BoolVar(&rollback.Spec.IncludeStrategy, \"change-strategy\", false, \"Include the previous deployment's strategy in the rollback\")\n+\tcmd.Flags().BoolVar(&rollback.Spec.IncludeReplicationMeta, \"change-scaling-settings\", false, \"Include the previous deployment's replicationController replica count and selector in the rollback\")\n+\tcmd.Flags().BoolP(\"dry-run\", \"d\", false, \"Instead of performing the rollback, describe what the rollback will look like in human-readable form\")\n+\tcmd.Flags().StringP(\"output\", \"o\", \"\", \"Instead of performing the rollback, output the rollback deploymenConfig in the specified format (json|yaml|template|templatefile)\")","path":"pkg/cmd/cli/cmd/rollback.go","position":110,"original_position":110,"commit_id":"a0c306aef55ecd60ce3e10b05168ce7cae6d7e88","original_commit_id":"f7add7502f753ca481c96b810f3f53ee051d3dee","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"Still wrong, see other comment.","created_at":"2015-01-30T20:35:40Z","updated_at":"2015-01-30T20:35:40Z","html_url":"https://github.com/openshift/origin/pull/786#discussion_r23870487","pull_request_url":"https://api.github.com/repos/openshift/origin/pulls/786","_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/23870487"},"html":{"href":"https://github.com/openshift/origin/pull/786#discussion_r23870487"},"pull_request":{"href":"https://api.github.com/repos/openshift/origin/pulls/786"}}},"pull_request":{"url":"https://api.github.com/repos/openshift/origin/pulls/786","id":28279654,"html_url":"https://github.com/openshift/origin/pull/786","diff_url":"https://github.com/openshift/origin/pull/786.diff","patch_url":"https://github.com/openshift/origin/pull/786.patch","issue_url":"https://api.github.com/repos/openshift/origin/issues/786","number":786,"state":"open","locked":false,"title":"Implement deployment rollback CLI support","user":{"login":"ironcladlou","id":298299,"avatar_url":"https://avatars.githubusercontent.com/u/298299?v=3","gravatar_id":"","url":"https://api.github.com/users/ironcladlou","html_url":"https://github.com/ironcladlou","followers_url":"https://api.github.com/users/ironcladlou/followers","following_url":"https://api.github.com/users/ironcladlou/following{/other_user}","gists_url":"https://api.github.com/users/ironcladlou/gists{/gist_id}","starred_url":"https://api.github.com/users/ironcladlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironcladlou/subscriptions","organizations_url":"https://api.github.com/users/ironcladlou/orgs","repos_url":"https://api.github.com/users/ironcladlou/repos","events_url":"https://api.github.com/users/ironcladlou/events{/privacy}","received_events_url":"https://api.github.com/users/ironcladlou/received_events","type":"User","site_admin":false},"body":"Add a new 'rollback' osc command which exposes deployment rollback\r\nfunctionality for end-users.","created_at":"2015-01-29T13:49:48Z","updated_at":"2015-01-30T20:35:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51472a84e64562ff9401ede1fd849ce6c76ad27d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openshift/origin/pulls/786/commits","review_comments_url":"https://api.github.com/repos/openshift/origin/pulls/786/comments","review_comment_url":"https://api.github.com/repos/openshift/origin/pulls/comments/{number}","comments_url":"https://api.github.com/repos/openshift/origin/issues/786/comments","statuses_url":"https://api.github.com/repos/openshift/origin/statuses/a0c306aef55ecd60ce3e10b05168ce7cae6d7e88","head":{"label":"ironcladlou:rollback-cli","ref":"rollback-cli","sha":"a0c306aef55ecd60ce3e10b05168ce7cae6d7e88","user":{"login":"ironcladlou","id":298299,"avatar_url":"https://avatars.githubusercontent.com/u/298299?v=3","gravatar_id":"","url":"https://api.github.com/users/ironcladlou","html_url":"https://github.com/ironcladlou","followers_url":"https://api.github.com/users/ironcladlou/followers","following_url":"https://api.github.com/users/ironcladlou/following{/other_user}","gists_url":"https://api.github.com/users/ironcladlou/gists{/gist_id}","starred_url":"https://api.github.com/users/ironcladlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironcladlou/subscriptions","organizations_url":"https://api.github.com/users/ironcladlou/orgs","repos_url":"https://api.github.com/users/ironcladlou/repos","events_url":"https://api.github.com/users/ironcladlou/events{/privacy}","received_events_url":"https://api.github.com/users/ironcladlou/received_events","type":"User","site_admin":false},"repo":{"id":23721352,"name":"origin","full_name":"ironcladlou/origin","owner":{"login":"ironcladlou","id":298299,"avatar_url":"https://avatars.githubusercontent.com/u/298299?v=3","gravatar_id":"","url":"https://api.github.com/users/ironcladlou","html_url":"https://github.com/ironcladlou","followers_url":"https://api.github.com/users/ironcladlou/followers","following_url":"https://api.github.com/users/ironcladlou/following{/other_user}","gists_url":"https://api.github.com/users/ironcladlou/gists{/gist_id}","starred_url":"https://api.github.com/users/ironcladlou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ironcladlou/subscriptions","organizations_url":"https://api.github.com/users/ironcladlou/orgs","repos_url":"https://api.github.com/users/ironcladlou/repos","events_url":"https://api.github.com/users/ironcladlou/events{/privacy}","received_events_url":"https://api.github.com/users/ironcladlou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ironcladlou/origin","description":"OpenShift 3 - build, deploy, and manage your applications with Docker and Kubernetes","fork":true,"url":"https://api.github.com/repos/ironcladlou/origin","forks_url":"https://api.github.com/repos/ironcladlou/origin/forks","keys_url":"https://api.github.com/repos/ironcladlou/origin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ironcladlou/origin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ironcladlou/origin/teams","hooks_url":"https://api.github.com/repos/ironcladlou/origin/hooks","issue_events_url":"https://api.github.com/repos/ironcladlou/origin/issues/events{/number}","events_url":"https://api.github.com/repos/ironcladlou/origin/events","assignees_url":"https://api.github.com/repos/ironcladlou/origin/assignees{/user}","branches_url":"https://api.github.com/repos/ironcladlou/origin/branches{/branch}","tags_url":"https://api.github.com/repos/ironcladlou/origin/tags","blobs_url":"https://api.github.com/repos/ironcladlou/origin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ironcladlou/origin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ironcladlou/origin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ironcladlou/origin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ironcladlou/origin/statuses/{sha}","languages_url":"https://api.github.com/repos/ironcladlou/origin/languages","stargazers_url":"https://api.github.com/repos/ironcladlou/origin/stargazers","contributors_url":"https://api.github.com/repos/ironcladlou/origin/contributors","subscribers_url":"https://api.github.com/repos/ironcladlou/origin/subscribers","subscription_url":"https://api.github.com/repos/ironcladlou/origin/subscription","commits_url":"https://api.github.com/repos/ironcladlou/origin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ironcladlou/origin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ironcladlou/origin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ironcladlou/origin/issues/comments/{number}","contents_url":"https://api.github.com/repos/ironcladlou/origin/contents/{+path}","compare_url":"https://api.github.com/repos/ironcladlou/origin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ironcladlou/origin/merges","archive_url":"https://api.github.com/repos/ironcladlou/origin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ironcladlou/origin/downloads","issues_url":"https://api.github.com/repos/ironcladlou/origin/issues{/number}","pulls_url":"https://api.github.com/repos/ironcladlou/origin/pulls{/number}","milestones_url":"https://api.github.com/repos/ironcladlou/origin/milestones{/number}","notifications_url":"https://api.github.com/repos/ironcladlou/origin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ironcladlou/origin/labels{/name}","releases_url":"https://api.github.com/repos/ironcladlou/origin/releases{/id}","created_at":"2014-09-05T23:22:09Z","updated_at":"2015-01-23T18:43:50Z","pushed_at":"2015-01-30T20:35:17Z","git_url":"git://github.com/ironcladlou/origin.git","ssh_url":"git@github.com:ironcladlou/origin.git","clone_url":"https://github.com/ironcladlou/origin.git","svn_url":"https://github.com/ironcladlou/origin","homepage":"https://openshift.github.io","size":27174,"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":"d0fa2436f1ac5f730bb074a66b9b9ca53e5344ae","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-01-30T20:13:03Z","pushed_at":"2015-01-30T20:13:02Z","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":"https://openshift.github.io","size":45110,"stargazers_count":254,"watchers_count":254,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":138,"mirror_url":null,"open_issues_count":83,"forks":138,"open_issues":83,"watchers":254,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openshift/origin/pulls/786"},"html":{"href":"https://github.com/openshift/origin/pull/786"},"issue":{"href":"https://api.github.com/repos/openshift/origin/issues/786"},"comments":{"href":"https://api.github.com/repos/openshift/origin/issues/786/comments"},"review_comments":{"href":"https://api.github.com/repos/openshift/origin/pulls/786/comments"},"review_comment":{"href":"https://api.github.com/repos/openshift/origin/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/openshift/origin/pulls/786/commits"},"statuses":{"href":"https://api.github.com/repos/openshift/origin/statuses/a0c306aef55ecd60ce3e10b05168ce7cae6d7e88"}}}}