manager.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. Copyright 2022 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package internal
  14. import (
  15. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  16. "k8s.io/apimachinery/pkg/runtime"
  17. "sigs.k8s.io/structured-merge-diff/v4/fieldpath"
  18. )
  19. // Managed groups a fieldpath.ManagedFields together with the timestamps associated with each operation.
  20. type Managed interface {
  21. // Fields gets the fieldpath.ManagedFields.
  22. Fields() fieldpath.ManagedFields
  23. // Times gets the timestamps associated with each operation.
  24. Times() map[string]*metav1.Time
  25. }
  26. // Manager updates the managed fields and merges applied configurations.
  27. type Manager interface {
  28. // Update is used when the object has already been merged (non-apply
  29. // use-case), and simply updates the managed fields in the output
  30. // object.
  31. // * `liveObj` is not mutated by this function
  32. // * `newObj` may be mutated by this function
  33. // Returns the new object with managedFields removed, and the object's new
  34. // proposed managedFields separately.
  35. Update(liveObj, newObj runtime.Object, managed Managed, manager string) (runtime.Object, Managed, error)
  36. // Apply is used when server-side apply is called, as it merges the
  37. // object and updates the managed fields.
  38. // * `liveObj` is not mutated by this function
  39. // * `newObj` may be mutated by this function
  40. // Returns the new object with managedFields removed, and the object's new
  41. // proposed managedFields separately.
  42. Apply(liveObj, appliedObj runtime.Object, managed Managed, fieldManager string, force bool) (runtime.Object, Managed, error)
  43. }