check error

pull/6/head
ymqytw 2017-03-30 17:47:18 -07:00
parent 7543bac563
commit 8d14b19cd7
1 changed files with 5 additions and 2 deletions

View File

@ -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))
}
}