@@ -172,53 +172,78 @@ func (d *DeploymentConfigDescriber) Describe(namespace, name string) (string, er
172
172
})
173
173
}
174
174
175
- func printStrategy (strategy deployapi.DeploymentStrategy , w * tabwriter.Writer ) {
176
- switch strategy .Type {
177
- case deployapi .DeploymentStrategyTypeRecreate :
178
- if strategy .RecreateParams != nil {
179
- pre := strategy .RecreateParams .Pre
180
- mid := strategy .RecreateParams .Mid
181
- post := strategy .RecreateParams .Post
182
- if pre != nil {
183
- printHook ("Pre-deployment" , pre , w )
184
- }
185
- if mid != nil {
186
- printHook ("Mid-deployment" , mid , w )
187
- }
188
- if post != nil {
189
- printHook ("Post-deployment" , post , w )
190
- }
175
+ func multilineStringArray (sep , indent string , args ... string ) string {
176
+ for i , s := range args {
177
+ if strings .HasSuffix (s , "\n " ) {
178
+ s = strings .TrimSuffix (s , "\n " )
191
179
}
192
- case deployapi .DeploymentStrategyTypeRolling :
193
- if strategy .RollingParams != nil {
194
- pre := strategy .RollingParams .Pre
195
- post := strategy .RollingParams .Post
196
- if pre != nil {
197
- printHook ("Pre-deployment" , pre , w )
198
- }
199
- if post != nil {
200
- printHook ("Post-deployment" , post , w )
201
- }
180
+ if strings .Contains (s , "\n " ) {
181
+ s = "\n " + indent + strings .Join (strings .Split (s , "\n " ), "\n " + indent )
182
+ }
183
+ args [i ] = s
184
+ }
185
+ strings .TrimRight (args [len (args )- 1 ], "\n " )
186
+ return strings .Join (args , " " )
187
+ }
188
+
189
+ func printStrategy (strategy deployapi.DeploymentStrategy , indent string , w * tabwriter.Writer ) {
190
+ if strategy .CustomParams != nil {
191
+ if len (strategy .CustomParams .Image ) == 0 {
192
+ fmt .Fprintf (w , "%sImage:\t %s\n " , indent , "<default>" )
193
+ } else {
194
+ fmt .Fprintf (w , "%sImage:\t %s\n " , indent , strategy .CustomParams .Image )
202
195
}
203
- case deployapi .DeploymentStrategyTypeCustom :
204
- fmt .Fprintf (w , "\t Image:\t %s\n " , strategy .CustomParams .Image )
205
196
206
197
if len (strategy .CustomParams .Environment ) > 0 {
207
- fmt .Fprintf (w , "\t Environment :\t %s\n " , formatLabels (convertEnv (strategy .CustomParams .Environment )))
198
+ fmt .Fprintf (w , "%sEnvironment :\t %s\n " , indent , formatLabels (convertEnv (strategy .CustomParams .Environment )))
208
199
}
209
200
210
201
if len (strategy .CustomParams .Command ) > 0 {
211
- fmt .Fprintf (w , "\t Command:\t %v\n " , strings .Join (strategy .CustomParams .Command , " " ))
202
+ fmt .Fprintf (w , "%sCommand:\t %v\n " , indent , multilineStringArray (" " , "\t " , strategy .CustomParams .Command ... ))
203
+ }
204
+ }
205
+
206
+ if strategy .RecreateParams != nil {
207
+ pre := strategy .RecreateParams .Pre
208
+ mid := strategy .RecreateParams .Mid
209
+ post := strategy .RecreateParams .Post
210
+ if pre != nil {
211
+ printHook ("Pre-deployment" , pre , indent , w )
212
+ }
213
+ if mid != nil {
214
+ printHook ("Mid-deployment" , mid , indent , w )
215
+ }
216
+ if post != nil {
217
+ printHook ("Post-deployment" , post , indent , w )
218
+ }
219
+ }
220
+
221
+ if strategy .RollingParams != nil {
222
+ pre := strategy .RollingParams .Pre
223
+ post := strategy .RollingParams .Post
224
+ if pre != nil {
225
+ printHook ("Pre-deployment" , pre , indent , w )
226
+ }
227
+ if post != nil {
228
+ printHook ("Post-deployment" , post , indent , w )
212
229
}
213
230
}
214
231
}
215
232
216
- func printHook (prefix string , hook * deployapi.LifecycleHook , w io.Writer ) {
233
+ func printHook (prefix string , hook * deployapi.LifecycleHook , indent string , w io.Writer ) {
217
234
if hook .ExecNewPod != nil {
218
- fmt .Fprintf (w , "\t %s hook (pod type, failure policy: %s):\n " , prefix , hook .FailurePolicy )
219
- fmt .Fprintf (w , "\t Container:\t %s\n " , hook .ExecNewPod .ContainerName )
220
- fmt .Fprintf (w , "\t Command:\t %v\n " , strings .Join (hook .ExecNewPod .Command , " " ))
221
- fmt .Fprintf (w , "\t Env:\t %s\n " , formatLabels (convertEnv (hook .ExecNewPod .Env )))
235
+ fmt .Fprintf (w , "%s%s hook (pod type, failure policy: %s):\n " , indent , prefix , hook .FailurePolicy )
236
+ fmt .Fprintf (w , "%s Container:\t %s\n " , indent , hook .ExecNewPod .ContainerName )
237
+ fmt .Fprintf (w , "%s Command:\t %v\n " , indent , multilineStringArray (" " , "\t " , hook .ExecNewPod .Command ... ))
238
+ if len (hook .ExecNewPod .Env ) > 0 {
239
+ fmt .Fprintf (w , "%s Env:\t %s\n " , indent , formatLabels (convertEnv (hook .ExecNewPod .Env )))
240
+ }
241
+ }
242
+ if len (hook .TagImages ) > 0 {
243
+ fmt .Fprintf (w , "%s%s hook (tag images, failure policy: %s):\n " , indent , prefix , hook .FailurePolicy )
244
+ for _ , image := range hook .TagImages {
245
+ fmt .Fprintf (w , "%s Tag:\t container %s to %s %s %s\n " , indent , image .ContainerName , image .To .Kind , image .To .Name , image .To .Namespace )
246
+ }
222
247
}
223
248
}
224
249
@@ -262,7 +287,7 @@ func printDeploymentConfigSpec(spec deployapi.DeploymentConfigSpec, w *tabwriter
262
287
263
288
// Strategy
264
289
formatString (w , "Strategy" , spec .Strategy .Type )
265
- printStrategy (spec .Strategy , w )
290
+ printStrategy (spec .Strategy , " " , w )
266
291
267
292
// Pod template
268
293
fmt .Fprintf (w , "Template:\n " )
0 commit comments