mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 14:53:44 +00:00
fix nits
This commit is contained in:
parent
ddf0d4b803
commit
a252628649
@ -65,12 +65,12 @@ func (f *stripMetaManager) Update(liveObj, newObj runtime.Object, managed Manage
|
|||||||
|
|
||||||
// Apply implements Manager.
|
// Apply implements Manager.
|
||||||
func (f *stripMetaManager) Apply(liveObj, appliedObj runtime.Object, managed Managed, manager string, force bool) (runtime.Object, Managed, error) {
|
func (f *stripMetaManager) Apply(liveObj, appliedObj runtime.Object, managed Managed, manager string, force bool) (runtime.Object, Managed, error) {
|
||||||
appliedObj, managed, err := f.fieldManager.Apply(liveObj, appliedObj, managed, manager, force)
|
newObj, managed, err := f.fieldManager.Apply(liveObj, appliedObj, managed, manager, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
f.stripFields(managed.Fields(), manager)
|
f.stripFields(managed.Fields(), manager)
|
||||||
return appliedObj, managed, nil
|
return newObj, managed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// stripFields removes a predefined set of paths found in typed from managed
|
// stripFields removes a predefined set of paths found in typed from managed
|
||||||
|
@ -137,15 +137,18 @@ func (f *structuredMergeManager) Update(liveObj, newObj runtime.Object, managed
|
|||||||
// Apply implements Manager.
|
// Apply implements Manager.
|
||||||
func (f *structuredMergeManager) Apply(liveObj, patchObj runtime.Object, managed Managed, manager string, force bool) (runtime.Object, Managed, error) {
|
func (f *structuredMergeManager) Apply(liveObj, patchObj runtime.Object, managed Managed, manager string, force bool) (runtime.Object, Managed, error) {
|
||||||
// Check that the patch object has the same version as the live object
|
// Check that the patch object has the same version as the live object
|
||||||
if patchObj.GetObjectKind().GroupVersionKind().GroupVersion() != f.groupVersion {
|
if patchVersion := patchObj.GetObjectKind().GroupVersionKind().GroupVersion(); patchVersion != f.groupVersion {
|
||||||
return nil, nil,
|
return nil, nil,
|
||||||
errors.NewBadRequest(
|
errors.NewBadRequest(
|
||||||
fmt.Sprintf("Incorrect version specified in apply patch. "+
|
fmt.Sprintf("Incorrect version specified in apply patch. "+
|
||||||
"Specified patch version: %s, expected: %s",
|
"Specified patch version: %s, expected: %s",
|
||||||
patchObj.GetObjectKind().GroupVersionKind().GroupVersion(), f.groupVersion))
|
patchVersion, f.groupVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
patchObjMeta, err := meta.Accessor(patchObj)
|
patchObjMeta, err := meta.Accessor(patchObj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("couldn't get accessor: %v", err)
|
||||||
|
}
|
||||||
if patchObjMeta.GetManagedFields() != nil {
|
if patchObjMeta.GetManagedFields() != nil {
|
||||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("metadata.managedFields must be nil"))
|
return nil, nil, errors.NewBadRequest(fmt.Sprintf("metadata.managedFields must be nil"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user