mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #43882 from ymqytw/check_error
Automatic merge from submit-queue (batch tested with PRs 42325, 43882) Fix bug of not checking error Fix bug of not checking error ```release-note None ``` cc: @shiywang
This commit is contained in:
commit
667f3ef42f
@ -132,16 +132,19 @@ func (o *ViewLastAppliedOptions) Validate(cmd *cobra.Command) error {
|
|||||||
|
|
||||||
func (o *ViewLastAppliedOptions) RunApplyViewLastApplied() error {
|
func (o *ViewLastAppliedOptions) RunApplyViewLastApplied() error {
|
||||||
for _, str := range o.LastAppliedConfigurationList {
|
for _, str := range o.LastAppliedConfigurationList {
|
||||||
yamlOutput, err := yaml.JSONToYAML([]byte(str))
|
|
||||||
switch o.OutputFormat {
|
switch o.OutputFormat {
|
||||||
case "json":
|
case "json":
|
||||||
jsonBuffer := &bytes.Buffer{}
|
jsonBuffer := &bytes.Buffer{}
|
||||||
err = json.Indent(jsonBuffer, []byte(str), "", " ")
|
err := json.Indent(jsonBuffer, []byte(str), "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Fprintf(o.Out, string(jsonBuffer.Bytes()))
|
fmt.Fprintf(o.Out, string(jsonBuffer.Bytes()))
|
||||||
case "yaml":
|
case "yaml":
|
||||||
|
yamlOutput, err := yaml.JSONToYAML([]byte(str))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
fmt.Fprintf(o.Out, string(yamlOutput))
|
fmt.Fprintf(o.Out, string(yamlOutput))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user