Even with build error, kubectl apply should apply all valid resources

Kubernetes-commit: 748ad74245778a93a68652cd7e804d6a1e13ad9d
This commit is contained in:
Sean R. Sullivan 2020-04-03 19:50:25 -07:00 committed by Kubernetes Publisher
parent 36d8bba27a
commit 34abefcfa8
1 changed files with 9 additions and 15 deletions

View File

@ -316,13 +316,14 @@ func isIncompatibleServerError(err error) bool {
return err.(*errors.StatusError).Status().Code == http.StatusUnsupportedMediaType
}
// GetObjects returns a (possibly cached) version of all the objects to apply
// as a slice of pointer to resource.Info. The resource.Info contains the object
// and some other denormalized data. This function should not be called until
// AFTER the "complete" and "validate" methods have been called to ensure that
// the ApplyOptions is filled in and valid. Returns an error if the resource
// builder returns an error retrieving the objects.
// GetObjects returns a (possibly cached) version of all the valid objects to apply
// as a slice of pointer to resource.Info and an error if one or more occurred.
// IMPORTANT: This function can return both valid objects AND an error, since
// "ContinueOnError" is set on the builder. This function should not be called
// until AFTER the "complete" and "validate" methods have been called to ensure that
// the ApplyOptions is filled in and valid.
func (o *ApplyOptions) GetObjects() ([]*resource.Info, error) {
var err error = nil
if !o.objectsCached {
// include the uninitialized objects by default if --prune is true
// unless explicitly set --include-uninitialized=false
@ -335,17 +336,10 @@ func (o *ApplyOptions) GetObjects() ([]*resource.Info, error) {
LabelSelectorParam(o.Selector).
Flatten().
Do()
if err := r.Err(); err != nil {
return nil, err
}
infos, err := r.Infos()
if err != nil {
return nil, err
}
o.objects = infos
o.objects, err = r.Infos()
o.objectsCached = true
}
return o.objects, nil
return o.objects, err
}
// SetObjects stores the set of objects (as resource.Info) to be