From 8d14b19cd7a830675a102b4bb62b2a37911b3917 Mon Sep 17 00:00:00 2001 From: ymqytw Date: Thu, 30 Mar 2017 17:47:18 -0700 Subject: [PATCH] check error --- pkg/kubectl/cmd/apply_view_last_applied.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl/cmd/apply_view_last_applied.go b/pkg/kubectl/cmd/apply_view_last_applied.go index e6546405456..1a7661ee3c3 100644 --- a/pkg/kubectl/cmd/apply_view_last_applied.go +++ b/pkg/kubectl/cmd/apply_view_last_applied.go @@ -132,16 +132,19 @@ func (o *ViewLastAppliedOptions) Validate(cmd *cobra.Command) error { func (o *ViewLastAppliedOptions) RunApplyViewLastApplied() error { for _, str := range o.LastAppliedConfigurationList { - yamlOutput, err := yaml.JSONToYAML([]byte(str)) switch o.OutputFormat { case "json": jsonBuffer := &bytes.Buffer{} - err = json.Indent(jsonBuffer, []byte(str), "", " ") + err := json.Indent(jsonBuffer, []byte(str), "", " ") if err != nil { return err } fmt.Fprintf(o.Out, string(jsonBuffer.Bytes())) case "yaml": + yamlOutput, err := yaml.JSONToYAML([]byte(str)) + if err != nil { + return err + } fmt.Fprintf(o.Out, string(yamlOutput)) } }