Merge pull request #64242 from WanLinghao/ctl_print_fix

Automatic merge from submit-queue (batch tested with PRs 63417, 64249, 64242, 64128, 64275). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix bugs that break processing when printing errors occur in kubectl

**What this PR does / why we need it**:
The process should continue when error happens, this patch fix the problem
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-05-24 20:49:15 -07:00 committed by GitHub
commit 7a7ab200ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 13 deletions

View File

@ -154,7 +154,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
}
@ -170,7 +172,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

@ -159,7 +159,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)
@ -174,7 +176,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

@ -482,7 +482,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
}
@ -500,7 +500,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
}