Browse code

Merge pull request #9750 from kargakis/rollout-new-subs

Merged by openshift-bot

OpenShift Bot authored on 2016/10/09 12:42:06
Showing 14 changed files
... ...
@@ -11491,6 +11491,51 @@ _oc_rollout_history()
11491 11491
     noun_aliases+=("deployments")
11492 11492
 }
11493 11493
 
11494
+_oc_rollout_latest()
11495
+{
11496
+    last_command="oc_rollout_latest"
11497
+    commands=()
11498
+
11499
+    flags=()
11500
+    two_word_flags=()
11501
+    local_nonpersistent_flags=()
11502
+    flags_with_completion=()
11503
+    flags_completion=()
11504
+
11505
+    flags+=("--output=")
11506
+    two_word_flags+=("-o")
11507
+    local_nonpersistent_flags+=("--output=")
11508
+    flags+=("--as=")
11509
+    flags+=("--certificate-authority=")
11510
+    flags_with_completion+=("--certificate-authority")
11511
+    flags_completion+=("_filedir")
11512
+    flags+=("--client-certificate=")
11513
+    flags_with_completion+=("--client-certificate")
11514
+    flags_completion+=("_filedir")
11515
+    flags+=("--client-key=")
11516
+    flags_with_completion+=("--client-key")
11517
+    flags_completion+=("_filedir")
11518
+    flags+=("--cluster=")
11519
+    flags+=("--config=")
11520
+    flags_with_completion+=("--config")
11521
+    flags_completion+=("_filedir")
11522
+    flags+=("--context=")
11523
+    flags+=("--insecure-skip-tls-verify")
11524
+    flags+=("--log-flush-frequency=")
11525
+    flags+=("--loglevel=")
11526
+    flags+=("--logspec=")
11527
+    flags+=("--match-server-version")
11528
+    flags+=("--namespace=")
11529
+    two_word_flags+=("-n")
11530
+    flags+=("--server=")
11531
+    flags+=("--token=")
11532
+    flags+=("--user=")
11533
+
11534
+    must_have_one_flag=()
11535
+    must_have_one_noun=()
11536
+    noun_aliases=()
11537
+}
11538
+
11494 11539
 _oc_rollout_pause()
11495 11540
 {
11496 11541
     last_command="oc_rollout_pause"
... ...
@@ -11663,6 +11708,7 @@ _oc_rollout()
11663 11663
     last_command="oc_rollout"
11664 11664
     commands=()
11665 11665
     commands+=("history")
11666
+    commands+=("latest")
11666 11667
     commands+=("pause")
11667 11668
     commands+=("resume")
11668 11669
     commands+=("undo")
... ...
@@ -16052,6 +16052,52 @@ _openshift_cli_rollout_history()
16052 16052
     noun_aliases+=("deployments")
16053 16053
 }
16054 16054
 
16055
+_openshift_cli_rollout_latest()
16056
+{
16057
+    last_command="openshift_cli_rollout_latest"
16058
+    commands=()
16059
+
16060
+    flags=()
16061
+    two_word_flags=()
16062
+    local_nonpersistent_flags=()
16063
+    flags_with_completion=()
16064
+    flags_completion=()
16065
+
16066
+    flags+=("--output=")
16067
+    two_word_flags+=("-o")
16068
+    local_nonpersistent_flags+=("--output=")
16069
+    flags+=("--as=")
16070
+    flags+=("--certificate-authority=")
16071
+    flags_with_completion+=("--certificate-authority")
16072
+    flags_completion+=("_filedir")
16073
+    flags+=("--client-certificate=")
16074
+    flags_with_completion+=("--client-certificate")
16075
+    flags_completion+=("_filedir")
16076
+    flags+=("--client-key=")
16077
+    flags_with_completion+=("--client-key")
16078
+    flags_completion+=("_filedir")
16079
+    flags+=("--cluster=")
16080
+    flags+=("--config=")
16081
+    flags_with_completion+=("--config")
16082
+    flags_completion+=("_filedir")
16083
+    flags+=("--context=")
16084
+    flags+=("--google-json-key=")
16085
+    flags+=("--insecure-skip-tls-verify")
16086
+    flags+=("--log-flush-frequency=")
16087
+    flags+=("--loglevel=")
16088
+    flags+=("--logspec=")
16089
+    flags+=("--match-server-version")
16090
+    flags+=("--namespace=")
16091
+    two_word_flags+=("-n")
16092
+    flags+=("--server=")
16093
+    flags+=("--token=")
16094
+    flags+=("--user=")
16095
+
16096
+    must_have_one_flag=()
16097
+    must_have_one_noun=()
16098
+    noun_aliases=()
16099
+}
16100
+
16055 16101
 _openshift_cli_rollout_pause()
16056 16102
 {
16057 16103
     last_command="openshift_cli_rollout_pause"
... ...
@@ -16227,6 +16273,7 @@ _openshift_cli_rollout()
16227 16227
     last_command="openshift_cli_rollout"
16228 16228
     commands=()
16229 16229
     commands+=("history")
16230
+    commands+=("latest")
16230 16231
     commands+=("pause")
16231 16232
     commands+=("resume")
16232 16233
     commands+=("undo")
... ...
@@ -11652,6 +11652,51 @@ _oc_rollout_history()
11652 11652
     noun_aliases+=("deployments")
11653 11653
 }
11654 11654
 
11655
+_oc_rollout_latest()
11656
+{
11657
+    last_command="oc_rollout_latest"
11658
+    commands=()
11659
+
11660
+    flags=()
11661
+    two_word_flags=()
11662
+    local_nonpersistent_flags=()
11663
+    flags_with_completion=()
11664
+    flags_completion=()
11665
+
11666
+    flags+=("--output=")
11667
+    two_word_flags+=("-o")
11668
+    local_nonpersistent_flags+=("--output=")
11669
+    flags+=("--as=")
11670
+    flags+=("--certificate-authority=")
11671
+    flags_with_completion+=("--certificate-authority")
11672
+    flags_completion+=("_filedir")
11673
+    flags+=("--client-certificate=")
11674
+    flags_with_completion+=("--client-certificate")
11675
+    flags_completion+=("_filedir")
11676
+    flags+=("--client-key=")
11677
+    flags_with_completion+=("--client-key")
11678
+    flags_completion+=("_filedir")
11679
+    flags+=("--cluster=")
11680
+    flags+=("--config=")
11681
+    flags_with_completion+=("--config")
11682
+    flags_completion+=("_filedir")
11683
+    flags+=("--context=")
11684
+    flags+=("--insecure-skip-tls-verify")
11685
+    flags+=("--log-flush-frequency=")
11686
+    flags+=("--loglevel=")
11687
+    flags+=("--logspec=")
11688
+    flags+=("--match-server-version")
11689
+    flags+=("--namespace=")
11690
+    two_word_flags+=("-n")
11691
+    flags+=("--server=")
11692
+    flags+=("--token=")
11693
+    flags+=("--user=")
11694
+
11695
+    must_have_one_flag=()
11696
+    must_have_one_noun=()
11697
+    noun_aliases=()
11698
+}
11699
+
11655 11700
 _oc_rollout_pause()
11656 11701
 {
11657 11702
     last_command="oc_rollout_pause"
... ...
@@ -11824,6 +11869,7 @@ _oc_rollout()
11824 11824
     last_command="oc_rollout"
11825 11825
     commands=()
11826 11826
     commands+=("history")
11827
+    commands+=("latest")
11827 11828
     commands+=("pause")
11828 11829
     commands+=("resume")
11829 11830
     commands+=("undo")
... ...
@@ -16213,6 +16213,52 @@ _openshift_cli_rollout_history()
16213 16213
     noun_aliases+=("deployments")
16214 16214
 }
16215 16215
 
16216
+_openshift_cli_rollout_latest()
16217
+{
16218
+    last_command="openshift_cli_rollout_latest"
16219
+    commands=()
16220
+
16221
+    flags=()
16222
+    two_word_flags=()
16223
+    local_nonpersistent_flags=()
16224
+    flags_with_completion=()
16225
+    flags_completion=()
16226
+
16227
+    flags+=("--output=")
16228
+    two_word_flags+=("-o")
16229
+    local_nonpersistent_flags+=("--output=")
16230
+    flags+=("--as=")
16231
+    flags+=("--certificate-authority=")
16232
+    flags_with_completion+=("--certificate-authority")
16233
+    flags_completion+=("_filedir")
16234
+    flags+=("--client-certificate=")
16235
+    flags_with_completion+=("--client-certificate")
16236
+    flags_completion+=("_filedir")
16237
+    flags+=("--client-key=")
16238
+    flags_with_completion+=("--client-key")
16239
+    flags_completion+=("_filedir")
16240
+    flags+=("--cluster=")
16241
+    flags+=("--config=")
16242
+    flags_with_completion+=("--config")
16243
+    flags_completion+=("_filedir")
16244
+    flags+=("--context=")
16245
+    flags+=("--google-json-key=")
16246
+    flags+=("--insecure-skip-tls-verify")
16247
+    flags+=("--log-flush-frequency=")
16248
+    flags+=("--loglevel=")
16249
+    flags+=("--logspec=")
16250
+    flags+=("--match-server-version")
16251
+    flags+=("--namespace=")
16252
+    two_word_flags+=("-n")
16253
+    flags+=("--server=")
16254
+    flags+=("--token=")
16255
+    flags+=("--user=")
16256
+
16257
+    must_have_one_flag=()
16258
+    must_have_one_noun=()
16259
+    noun_aliases=()
16260
+}
16261
+
16216 16262
 _openshift_cli_rollout_pause()
16217 16263
 {
16218 16264
     last_command="openshift_cli_rollout_pause"
... ...
@@ -16388,6 +16434,7 @@ _openshift_cli_rollout()
16388 16388
     last_command="openshift_cli_rollout"
16389 16389
     commands=()
16390 16390
     commands+=("history")
16391
+    commands+=("latest")
16391 16392
     commands+=("pause")
16392 16393
     commands+=("resume")
16393 16394
     commands+=("undo")
... ...
@@ -2203,6 +2203,20 @@ View rollout history
2203 2203
 ====
2204 2204
 
2205 2205
 
2206
+== oc rollout latest
2207
+Start a new rollout for a deployment config with the latest state from its triggers
2208
+
2209
+====
2210
+
2211
+[options="nowrap"]
2212
+----
2213
+  # Start a new rollout based on the latest images defined in the image change triggers.
2214
+  oc rollout latest dc/nginx
2215
+
2216
+----
2217
+====
2218
+
2219
+
2206 2220
 == oc rollout pause
2207 2221
 Mark the provided resource as paused
2208 2222
 
... ...
@@ -182,6 +182,7 @@ oc-proxy.1
182 182
 oc-replace.1
183 183
 oc-rollback.1
184 184
 oc-rollout-history.1
185
+oc-rollout-latest.1
185 186
 oc-rollout-pause.1
186 187
 oc-rollout-resume.1
187 188
 oc-rollout-undo.1
... ...
@@ -271,6 +271,7 @@ openshift-cli-proxy.1
271 271
 openshift-cli-replace.1
272 272
 openshift-cli-rollback.1
273 273
 openshift-cli-rollout-history.1
274
+openshift-cli-rollout-latest.1
274 275
 openshift-cli-rollout-pause.1
275 276
 openshift-cli-rollout-resume.1
276 277
 openshift-cli-rollout-undo.1
277 278
new file mode 100644
... ...
@@ -0,0 +1,118 @@
0
+.TH "OC ROLLOUT" "1" " Openshift CLI User Manuals" "Openshift" "June 2016"  ""
1
+
2
+
3
+.SH NAME
4
+.PP
5
+oc rollout latest \- Start a new rollout for a deployment config with the latest state from its triggers
6
+
7
+
8
+.SH SYNOPSIS
9
+.PP
10
+\fBoc rollout latest\fP [OPTIONS]
11
+
12
+
13
+.SH DESCRIPTION
14
+.PP
15
+Start a new rollout for a deployment config with the latest state from its triggers
16
+
17
+.PP
18
+This command is appropriate for running manual rollouts. If you want full control over
19
+running new rollouts, use "oc set triggers \-\-manual" to disable all triggers in your
20
+deployment config and then whenever you want to run a new deployment process, use this
21
+command in order to pick up the latest images found in the cluster that are pointed by
22
+your image change triggers.
23
+
24
+
25
+.SH OPTIONS
26
+.PP
27
+\fB\-o\fP, \fB\-\-output\fP=""
28
+    Output mode. Use "\-o name" for shorter output (resource/name).
29
+
30
+
31
+.SH OPTIONS INHERITED FROM PARENT COMMANDS
32
+.PP
33
+\fB\-\-api\-version\fP=""
34
+    DEPRECATED: The API version to use when talking to the server
35
+
36
+.PP
37
+\fB\-\-as\fP=""
38
+    Username to impersonate for the operation
39
+
40
+.PP
41
+\fB\-\-certificate\-authority\fP=""
42
+    Path to a cert. file for the certificate authority
43
+
44
+.PP
45
+\fB\-\-client\-certificate\fP=""
46
+    Path to a client certificate file for TLS
47
+
48
+.PP
49
+\fB\-\-client\-key\fP=""
50
+    Path to a client key file for TLS
51
+
52
+.PP
53
+\fB\-\-cluster\fP=""
54
+    The name of the kubeconfig cluster to use
55
+
56
+.PP
57
+\fB\-\-config\fP=""
58
+    Path to the config file to use for CLI requests.
59
+
60
+.PP
61
+\fB\-\-context\fP=""
62
+    The name of the kubeconfig context to use
63
+
64
+.PP
65
+\fB\-\-google\-json\-key\fP=""
66
+    The Google Cloud Platform Service Account JSON Key to use for authentication.
67
+
68
+.PP
69
+\fB\-\-insecure\-skip\-tls\-verify\fP=false
70
+    If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
71
+
72
+.PP
73
+\fB\-\-log\-flush\-frequency\fP=0
74
+    Maximum number of seconds between log flushes
75
+
76
+.PP
77
+\fB\-\-match\-server\-version\fP=false
78
+    Require server version to match client version
79
+
80
+.PP
81
+\fB\-n\fP, \fB\-\-namespace\fP=""
82
+    If present, the namespace scope for this CLI request
83
+
84
+.PP
85
+\fB\-\-server\fP=""
86
+    The address and port of the Kubernetes API server
87
+
88
+.PP
89
+\fB\-\-token\fP=""
90
+    Bearer token for authentication to the API server
91
+
92
+.PP
93
+\fB\-\-user\fP=""
94
+    The name of the kubeconfig user to use
95
+
96
+
97
+.SH EXAMPLE
98
+.PP
99
+.RS
100
+
101
+.nf
102
+  # Start a new rollout based on the latest images defined in the image change triggers.
103
+  oc rollout latest dc/nginx
104
+
105
+
106
+.fi
107
+.RE
108
+
109
+
110
+.SH SEE ALSO
111
+.PP
112
+\fBoc\-rollout(1)\fP,
113
+
114
+
115
+.SH HISTORY
116
+.PP
117
+June 2016, Ported from the Kubernetes man\-doc generator
... ...
@@ -13,8 +13,28 @@ oc rollout \- rollout manages a deployment
13 13
 
14 14
 .SH DESCRIPTION
15 15
 .PP
16
-Manage deployments.
16
+Start a new rollout, view its status or history, rollback to a previous revision of your app
17 17
 
18
+.PP
19
+This command allows you to control a deployment config. Each individual rollout is exposed
20
+as a replication controller, and the deployment process manages scaling down old replication
21
+controllers and scaling up new ones.
22
+
23
+.PP
24
+There are several deployment strategies defined:
25
+.IP 
26
+
27
+.IP
28
+\(bu Rolling (default) \- scales up the new replication controller in stages, gradually reducing the
29
+number of old pods. If one of the new deployed pods never becomes "ready", the new rollout
30
+will be rolled back (scaled down to zero). Use when your application can tolerate two versions
31
+of code running at the same time (many web applications, scalable databases)
32
+.IP
33
+\(bu Recreate \- scales the old replication controller down to zero, then scales the new replication
34
+controller up to full. Use when your application cannot tolerate two versions of code running
35
+at the same time
36
+.IP
37
+\(bu Custom \- run your own deployment process inside a Docker container using your own scripts.
18 38
 
19 39
 .SH OPTIONS INHERITED FROM PARENT COMMANDS
20 40
 .PP
... ...
@@ -84,7 +104,7 @@ Manage deployments.
84 84
 
85 85
 .SH SEE ALSO
86 86
 .PP
87
-\fBoc(1)\fP, \fBoc\-rollout\-history(1)\fP, \fBoc\-rollout\-pause(1)\fP, \fBoc\-rollout\-resume(1)\fP, \fBoc\-rollout\-undo(1)\fP,
87
+\fBoc(1)\fP, \fBoc\-rollout\-history(1)\fP, \fBoc\-rollout\-latest(1)\fP, \fBoc\-rollout\-pause(1)\fP, \fBoc\-rollout\-resume(1)\fP, \fBoc\-rollout\-undo(1)\fP,
88 88
 
89 89
 
90 90
 .SH HISTORY
91 91
new file mode 100644
... ...
@@ -0,0 +1,118 @@
0
+.TH "OPENSHIFT CLI ROLLOUT" "1" " Openshift CLI User Manuals" "Openshift" "June 2016"  ""
1
+
2
+
3
+.SH NAME
4
+.PP
5
+openshift cli rollout latest \- Start a new rollout for a deployment config with the latest state from its triggers
6
+
7
+
8
+.SH SYNOPSIS
9
+.PP
10
+\fBopenshift cli rollout latest\fP [OPTIONS]
11
+
12
+
13
+.SH DESCRIPTION
14
+.PP
15
+Start a new rollout for a deployment config with the latest state from its triggers
16
+
17
+.PP
18
+This command is appropriate for running manual rollouts. If you want full control over
19
+running new rollouts, use "oc set triggers \-\-manual" to disable all triggers in your
20
+deployment config and then whenever you want to run a new deployment process, use this
21
+command in order to pick up the latest images found in the cluster that are pointed by
22
+your image change triggers.
23
+
24
+
25
+.SH OPTIONS
26
+.PP
27
+\fB\-o\fP, \fB\-\-output\fP=""
28
+    Output mode. Use "\-o name" for shorter output (resource/name).
29
+
30
+
31
+.SH OPTIONS INHERITED FROM PARENT COMMANDS
32
+.PP
33
+\fB\-\-api\-version\fP=""
34
+    DEPRECATED: The API version to use when talking to the server
35
+
36
+.PP
37
+\fB\-\-as\fP=""
38
+    Username to impersonate for the operation
39
+
40
+.PP
41
+\fB\-\-certificate\-authority\fP=""
42
+    Path to a cert. file for the certificate authority
43
+
44
+.PP
45
+\fB\-\-client\-certificate\fP=""
46
+    Path to a client certificate file for TLS
47
+
48
+.PP
49
+\fB\-\-client\-key\fP=""
50
+    Path to a client key file for TLS
51
+
52
+.PP
53
+\fB\-\-cluster\fP=""
54
+    The name of the kubeconfig cluster to use
55
+
56
+.PP
57
+\fB\-\-config\fP=""
58
+    Path to the config file to use for CLI requests.
59
+
60
+.PP
61
+\fB\-\-context\fP=""
62
+    The name of the kubeconfig context to use
63
+
64
+.PP
65
+\fB\-\-google\-json\-key\fP=""
66
+    The Google Cloud Platform Service Account JSON Key to use for authentication.
67
+
68
+.PP
69
+\fB\-\-insecure\-skip\-tls\-verify\fP=false
70
+    If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
71
+
72
+.PP
73
+\fB\-\-log\-flush\-frequency\fP=0
74
+    Maximum number of seconds between log flushes
75
+
76
+.PP
77
+\fB\-\-match\-server\-version\fP=false
78
+    Require server version to match client version
79
+
80
+.PP
81
+\fB\-n\fP, \fB\-\-namespace\fP=""
82
+    If present, the namespace scope for this CLI request
83
+
84
+.PP
85
+\fB\-\-server\fP=""
86
+    The address and port of the Kubernetes API server
87
+
88
+.PP
89
+\fB\-\-token\fP=""
90
+    Bearer token for authentication to the API server
91
+
92
+.PP
93
+\fB\-\-user\fP=""
94
+    The name of the kubeconfig user to use
95
+
96
+
97
+.SH EXAMPLE
98
+.PP
99
+.RS
100
+
101
+.nf
102
+  # Start a new rollout based on the latest images defined in the image change triggers.
103
+  openshift cli rollout latest dc/nginx
104
+
105
+
106
+.fi
107
+.RE
108
+
109
+
110
+.SH SEE ALSO
111
+.PP
112
+\fBopenshift\-cli\-rollout(1)\fP,
113
+
114
+
115
+.SH HISTORY
116
+.PP
117
+June 2016, Ported from the Kubernetes man\-doc generator
... ...
@@ -13,8 +13,28 @@ openshift cli rollout \- rollout manages a deployment
13 13
 
14 14
 .SH DESCRIPTION
15 15
 .PP
16
-Manage deployments.
16
+Start a new rollout, view its status or history, rollback to a previous revision of your app
17 17
 
18
+.PP
19
+This command allows you to control a deployment config. Each individual rollout is exposed
20
+as a replication controller, and the deployment process manages scaling down old replication
21
+controllers and scaling up new ones.
22
+
23
+.PP
24
+There are several deployment strategies defined:
25
+.IP 
26
+
27
+.IP
28
+\(bu Rolling (default) \- scales up the new replication controller in stages, gradually reducing the
29
+number of old pods. If one of the new deployed pods never becomes "ready", the new rollout
30
+will be rolled back (scaled down to zero). Use when your application can tolerate two versions
31
+of code running at the same time (many web applications, scalable databases)
32
+.IP
33
+\(bu Recreate \- scales the old replication controller down to zero, then scales the new replication
34
+controller up to full. Use when your application cannot tolerate two versions of code running
35
+at the same time
36
+.IP
37
+\(bu Custom \- run your own deployment process inside a Docker container using your own scripts.
18 38
 
19 39
 .SH OPTIONS INHERITED FROM PARENT COMMANDS
20 40
 .PP
... ...
@@ -84,7 +104,7 @@ Manage deployments.
84 84
 
85 85
 .SH SEE ALSO
86 86
 .PP
87
-\fBopenshift\-cli(1)\fP, \fBopenshift\-cli\-rollout\-history(1)\fP, \fBopenshift\-cli\-rollout\-pause(1)\fP, \fBopenshift\-cli\-rollout\-resume(1)\fP, \fBopenshift\-cli\-rollout\-undo(1)\fP,
87
+\fBopenshift\-cli(1)\fP, \fBopenshift\-cli\-rollout\-history(1)\fP, \fBopenshift\-cli\-rollout\-latest(1)\fP, \fBopenshift\-cli\-rollout\-pause(1)\fP, \fBopenshift\-cli\-rollout\-resume(1)\fP, \fBopenshift\-cli\-rollout\-undo(1)\fP,
88 88
 
89 89
 
90 90
 .SH HISTORY
91 91
new file mode 100644
... ...
@@ -0,0 +1,167 @@
0
+package rollout
1
+
2
+import (
3
+	"errors"
4
+	"fmt"
5
+	"io"
6
+
7
+	"github.com/spf13/cobra"
8
+	kerrors "k8s.io/kubernetes/pkg/api/errors"
9
+	"k8s.io/kubernetes/pkg/api/meta"
10
+	kclient "k8s.io/kubernetes/pkg/client/unversioned"
11
+	kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
12
+	"k8s.io/kubernetes/pkg/kubectl/resource"
13
+	"k8s.io/kubernetes/pkg/runtime"
14
+
15
+	"github.com/openshift/origin/pkg/client"
16
+	"github.com/openshift/origin/pkg/cmd/util/clientcmd"
17
+	deployapi "github.com/openshift/origin/pkg/deploy/api"
18
+	deployutil "github.com/openshift/origin/pkg/deploy/util"
19
+)
20
+
21
+const (
22
+	rolloutLatestLong = `
23
+Start a new rollout for a deployment config with the latest state from its triggers
24
+
25
+This command is appropriate for running manual rollouts. If you want full control over
26
+running new rollouts, use "oc set triggers --manual" to disable all triggers in your
27
+deployment config and then whenever you want to run a new deployment process, use this
28
+command in order to pick up the latest images found in the cluster that are pointed by
29
+your image change triggers.`
30
+
31
+	rolloutLatestExample = `  # Start a new rollout based on the latest images defined in the image change triggers.
32
+  %[1]s rollout latest dc/nginx
33
+`
34
+)
35
+
36
+// RolloutLatestOptions holds all the options for the `rollout latest` command.
37
+// TODO: Support --dry-run
38
+type RolloutLatestOptions struct {
39
+	mapper meta.RESTMapper
40
+	typer  runtime.ObjectTyper
41
+	infos  []*resource.Info
42
+
43
+	out         io.Writer
44
+	shortOutput bool
45
+
46
+	oc              client.Interface
47
+	kc              kclient.Interface
48
+	baseCommandName string
49
+}
50
+
51
+// NewCmdRolloutLatest implements the oc rollout latest subcommand.
52
+func NewCmdRolloutLatest(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
53
+	opts := &RolloutLatestOptions{
54
+		baseCommandName: fullName,
55
+	}
56
+
57
+	cmd := &cobra.Command{
58
+		Use:     "latest DEPLOYMENTCONFIG",
59
+		Short:   "Start a new rollout for a deployment config with the latest state from its triggers",
60
+		Long:    rolloutLatestLong,
61
+		Example: fmt.Sprintf(rolloutLatestExample, fullName),
62
+		Run: func(cmd *cobra.Command, args []string) {
63
+			err := opts.Complete(f, cmd, args, out)
64
+			kcmdutil.CheckErr(err)
65
+
66
+			if err := opts.Validate(); err != nil {
67
+				kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error()))
68
+			}
69
+
70
+			err = opts.RunRolloutLatest()
71
+			kcmdutil.CheckErr(err)
72
+		},
73
+	}
74
+
75
+	kcmdutil.AddOutputFlagsForMutation(cmd)
76
+
77
+	return cmd
78
+}
79
+
80
+func (o *RolloutLatestOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, args []string, out io.Writer) error {
81
+	if len(args) != 1 {
82
+		return errors.New("one deployment config name is needed as argument.")
83
+	}
84
+
85
+	namespace, _, err := f.DefaultNamespace()
86
+	if err != nil {
87
+		return err
88
+	}
89
+
90
+	o.oc, o.kc, err = f.Clients()
91
+	if err != nil {
92
+		return err
93
+	}
94
+
95
+	o.mapper, o.typer = f.Object(false)
96
+	o.infos, err = resource.NewBuilder(o.mapper, o.typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
97
+		ContinueOnError().
98
+		NamespaceParam(namespace).
99
+		ResourceNames("deploymentconfigs", args[0]).
100
+		SingleResourceType().
101
+		Do().Infos()
102
+	if err != nil {
103
+		return err
104
+	}
105
+
106
+	o.out = out
107
+	o.shortOutput = kcmdutil.GetFlagString(cmd, "output") == "name"
108
+
109
+	return nil
110
+}
111
+
112
+func (o RolloutLatestOptions) Validate() error {
113
+	if len(o.infos) != 1 {
114
+		return errors.New("a deployment config name is required.")
115
+	}
116
+	return nil
117
+}
118
+
119
+func (o RolloutLatestOptions) RunRolloutLatest() error {
120
+	info := o.infos[0]
121
+	config, ok := info.Object.(*deployapi.DeploymentConfig)
122
+	if !ok {
123
+		return fmt.Errorf("%s is not a deployment config", info.Name)
124
+	}
125
+
126
+	// TODO: Consider allowing one-off deployments for paused configs
127
+	// See https://github.com/openshift/origin/issues/9903
128
+	if config.Spec.Paused {
129
+		return fmt.Errorf("cannot deploy a paused deployment config")
130
+	}
131
+
132
+	deploymentName := deployutil.LatestDeploymentNameForConfig(config)
133
+	deployment, err := o.kc.ReplicationControllers(config.Namespace).Get(deploymentName)
134
+	switch {
135
+	case err == nil:
136
+		// Reject attempts to start a concurrent deployment.
137
+		if !deployutil.IsTerminatedDeployment(deployment) {
138
+			status := deployutil.DeploymentStatusFor(deployment)
139
+			return fmt.Errorf("#%d is already in progress (%s).", config.Status.LatestVersion, status)
140
+		}
141
+	case !kerrors.IsNotFound(err):
142
+		return err
143
+	}
144
+
145
+	request := &deployapi.DeploymentRequest{
146
+		Name:   config.Name,
147
+		Latest: true,
148
+		Force:  true,
149
+	}
150
+
151
+	dc, err := o.oc.DeploymentConfigs(config.Namespace).Instantiate(request)
152
+	// Pre 1.4 servers don't support the instantiate endpoint. Fallback to incrementing
153
+	// latestVersion on them.
154
+	if kerrors.IsNotFound(err) || kerrors.IsForbidden(err) {
155
+		config.Status.LatestVersion++
156
+		dc, err = o.oc.DeploymentConfigs(config.Namespace).Update(config)
157
+	}
158
+	if err != nil {
159
+		return err
160
+	}
161
+
162
+	info.Refresh(dc, true)
163
+
164
+	kcmdutil.PrintSuccess(o.mapper, o.shortOutput, o.out, info.Mapping.Resource, info.Name, "rolled out")
165
+	return nil
166
+}
... ...
@@ -12,7 +12,22 @@ import (
12 12
 
13 13
 const (
14 14
 	rolloutLong = `
15
-Manage deployments.
15
+Start a new rollout, view its status or history, rollback to a previous revision of your app
16
+
17
+This command allows you to control a deployment config. Each individual rollout is exposed
18
+as a replication controller, and the deployment process manages scaling down old replication
19
+controllers and scaling up new ones.
20
+
21
+There are several deployment strategies defined:
22
+
23
+* Rolling (default) - scales up the new replication controller in stages, gradually reducing the
24
+  number of old pods. If one of the new deployed pods never becomes "ready", the new rollout
25
+  will be rolled back (scaled down to zero). Use when your application can tolerate two versions
26
+  of code running at the same time (many web applications, scalable databases)
27
+* Recreate - scales the old replication controller down to zero, then scales the new replication
28
+  controller up to full. Use when your application cannot tolerate two versions of code running
29
+  at the same time
30
+* Custom - run your own deployment process inside a Docker container using your own scripts.
16 31
 `
17 32
 )
18 33
 
... ...
@@ -32,6 +47,7 @@ func NewCmdRollout(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.
32 32
 	cmd.AddCommand(NewCmdRolloutPause(fullName, f, out))
33 33
 	cmd.AddCommand(NewCmdRolloutResume(fullName, f, out))
34 34
 	cmd.AddCommand(NewCmdRolloutUndo(fullName, f, out))
35
+	cmd.AddCommand(NewCmdRolloutLatest(fullName, f, out))
35 36
 
36 37
 	return cmd
37 38
 }
... ...
@@ -487,7 +487,7 @@ var _ = g.Describe("deploymentconfigs", func() {
487 487
 			o.Expect(err).NotTo(o.HaveOccurred())
488 488
 
489 489
 			g.By("deploying a second time [new client]")
490
-			_, err = oc.Run("deploy").Args("--latest", name).Output()
490
+			_, err = oc.Run("rollout").Args("latest", name).Output()
491 491
 			o.Expect(err).NotTo(o.HaveOccurred())
492 492
 
493 493
 			g.By("verifying that both latestVersion and generation are updated")
... ...
@@ -600,16 +600,25 @@ var _ = g.Describe("deploymentconfigs", func() {
600 600
 
601 601
 			o.Expect(waitForLatestCondition(oc, name, deploymentRunTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred())
602 602
 
603
-			_, err = oc.Run("deploy").Args(name, "--latest").Output()
603
+			_, err = oc.Run("rollout").Args("latest", name).Output()
604 604
 			o.Expect(err).NotTo(o.HaveOccurred())
605 605
 
606
-			o.Expect(waitForLatestCondition(oc, name, deploymentRunTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred())
607
-
608 606
 			g.By("verifying that we are on the second version")
609
-			version, err := oc.Run("get").Args(resource, "--output=jsonpath=\"{.status.latestVersion}\"").Output()
607
+			version := "1"
608
+			err = wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) {
609
+				latestVersion, err := oc.Run("get").Args(resource, "--output=jsonpath=\"{.status.latestVersion}\"").Output()
610
+				if err != nil {
611
+					return false, err
612
+				}
613
+				version = strings.Trim(latestVersion, "\"")
614
+				return strings.Contains(version, "2"), nil
615
+			})
616
+			if err == wait.ErrWaitTimeout {
617
+				err = fmt.Errorf("expected latestVersion: 2, got: %s", version)
618
+			}
610 619
 			o.Expect(err).NotTo(o.HaveOccurred())
611
-			version = strings.Trim(version, "\"")
612
-			o.Expect(version).To(o.ContainSubstring("2"))
620
+
621
+			o.Expect(waitForLatestCondition(oc, name, deploymentRunTimeout, deploymentReachedCompletion)).NotTo(o.HaveOccurred())
613 622
 
614 623
 			g.By("verifying that we can rollback")
615 624
 			_, err = oc.Run("rollout").Args("undo", resource).Output()