fix bugs that break processing when printing errors occur in kubectl

pull/8/head
WanLinghao 2018-05-24 09:48:24 +08:00
parent b5cd7d81bd
commit b020a4ba8c
7 changed files with 21 additions and 13 deletions

View File

@ -153,7 +153,9 @@ func (o PauseConfig) RunPause() error {
allErrs = append(allErrs, err)
continue
}
printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out)
if err = printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out); err != nil {
allErrs = append(allErrs, err)
}
continue
}
@ -169,7 +171,9 @@ func (o PauseConfig) RunPause() error {
allErrs = append(allErrs, err)
continue
}
printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out)
if err = printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out); err != nil {
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)

View File

@ -158,7 +158,9 @@ func (o ResumeConfig) RunResume() error {
allErrs = append(allErrs, err)
continue
}
printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out)
if err = printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out); err != nil {
allErrs = append(allErrs, err)
}
}
obj, err := resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, types.StrategicMergePatchType, patch.Patch)
@ -173,7 +175,9 @@ func (o ResumeConfig) RunResume() error {
allErrs = append(allErrs, err)
continue
}
printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out)
if err = printer.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out); err != nil {
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)

View File

@ -415,7 +415,7 @@ func (o *EnvOptions) RunEnv() error {
if o.Local || o.dryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
continue
}
@ -433,7 +433,7 @@ func (o *EnvOptions) RunEnv() error {
}
if err := o.PrintObj(actual, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)

View File

@ -276,7 +276,7 @@ func (o *SetImageOptions) Run() error {
if o.Local || o.DryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
continue
}
@ -289,7 +289,7 @@ func (o *SetImageOptions) Run() error {
}
if err := o.PrintObj(actual, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)

View File

@ -277,7 +277,7 @@ func (o *SetResourcesOptions) Run() error {
if o.Local || o.DryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
continue
}
@ -289,7 +289,7 @@ func (o *SetResourcesOptions) Run() error {
}
if err := o.PrintObj(actual, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
}
return utilerrors.NewAggregate(allErrs)

View File

@ -198,7 +198,7 @@ func (o *SetServiceAccountOptions) Run() error {
}
if o.local || o.dryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
return err
patchErrs = append(patchErrs, err)
}
continue
}
@ -209,7 +209,7 @@ func (o *SetServiceAccountOptions) Run() error {
}
if err := o.PrintObj(actual, o.Out); err != nil {
return err
patchErrs = append(patchErrs, err)
}
}
return utilerrors.NewAggregate(patchErrs)

View File

@ -251,7 +251,7 @@ func (o *SubjectOptions) Run(fn updateSubjects) error {
if o.Local || o.DryRun {
if err := o.PrintObj(info.Object, o.Out); err != nil {
return err
allErrs = append(allErrs, err)
}
continue
}