Skip to content

Commit 00b3e34

Browse files
author
OpenShift Bot
committed
Merge pull request #8787 from smarterclayton/manage_deploy_logs
Merged by openshift-bot
2 parents ba8a56f + f92fe67 commit 00b3e34

File tree

24 files changed

+653
-258
lines changed

24 files changed

+653
-258
lines changed

Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/rolling_updater.go

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/completions/bash/openshift

+1
Original file line numberDiff line numberDiff line change
@@ -15788,6 +15788,7 @@ _openshift_infra_deploy()
1578815788

1578915789
flags+=("--deployment=")
1579015790
flags+=("--namespace=")
15791+
flags+=("--until=")
1579115792
flags+=("--google-json-key=")
1579215793
flags+=("--log-flush-frequency=")
1579315794

pkg/cmd/cli/describe/deployments.go

+61-36
Original file line numberDiff line numberDiff line change
@@ -172,53 +172,78 @@ func (d *DeploymentConfigDescriber) Describe(namespace, name string) (string, er
172172
})
173173
}
174174

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")
191179
}
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)
202195
}
203-
case deployapi.DeploymentStrategyTypeCustom:
204-
fmt.Fprintf(w, "\t Image:\t%s\n", strategy.CustomParams.Image)
205196

206197
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)))
208199
}
209200

210201
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)
212229
}
213230
}
214231
}
215232

216-
func printHook(prefix string, hook *deployapi.LifecycleHook, w io.Writer) {
233+
func printHook(prefix string, hook *deployapi.LifecycleHook, indent string, w io.Writer) {
217234
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:\tcontainer %s to %s %s %s\n", indent, image.ContainerName, image.To.Kind, image.To.Name, image.To.Namespace)
246+
}
222247
}
223248
}
224249

@@ -262,7 +287,7 @@ func printDeploymentConfigSpec(spec deployapi.DeploymentConfigSpec, w *tabwriter
262287

263288
// Strategy
264289
formatString(w, "Strategy", spec.Strategy.Type)
265-
printStrategy(spec.Strategy, w)
290+
printStrategy(spec.Strategy, " ", w)
266291

267292
// Pod template
268293
fmt.Fprintf(w, "Template:\n")

0 commit comments

Comments
 (0)