Documentation ¶
Overview ¶
Package diff contains code for diffing sync-enabled resources, not necessarily known at compile time.
Index ¶
- Constants
- func CanManage(scope declared.Scope, syncName string, obj client.Object, ...) bool
- func IsManager(scope declared.Scope, syncName string, obj client.Object) bool
- func IsUnknown(obj client.Object) bool
- func Unknown() client.Object
- func ValidateManager(reconciler, manager string, id core.ID, op admissionv1.Operation) error
- type Diff
- type Operation
Constants ¶
const ( // NoOp indicates that no action should be taken. NoOp = Operation("no-op") // Create indicates the resource should be created. Create = Operation("create") // Update indicates the resource is declared and is on the API server, so we should // calculate a patch and apply it. Update = Operation("update") // Delete indicates the resource should be deleted. Delete = Operation("delete") // Error indicates the resource's management annotation in the API server is invalid. Error = Operation("error") // Abandon indicates the resource's management annotation should be removed from the API Server. Abandon = Operation("abandon") // ManagementConflict represents the case where Declared and Actual both exist, // but the Actual one is managed by a Reconciler that supersedes this one. ManagementConflict = Operation("management-conflict") )
const ( // OperationManage is a meta operation that implies full control: // CREATE + UPDATE + DELETE OperationManage = admissionv1.Operation("MANAGE") )
Variables ¶
This section is empty.
Functions ¶
func CanManage ¶
func CanManage(scope declared.Scope, syncName string, obj client.Object, op admissionv1.Operation) bool
CanManage returns true if the given reconciler is allowed to perform the specified operation on the specified resource object.
func IsUnknown ¶
IsUnknown returns true if the given Object is the sentinel marker of unknown state on the cluster.
func Unknown ¶
Unknown returns a sentinel Object which represents unknown state on the cluster. On failing to retrieve the current state of an Object on the cluster, a caller should use this to indicate that no action should be taken to reconcile the declared version of an Object.
func ValidateManager ¶
ValidateManager returns nil if the given reconciler is allowed to perform the specified operation on the resource object with the specified id.
It's not possible to parse a ReconcilerName into its component parts, because R*Sync names and namespaces may include a dash, which is used as the delimiter. But you CAN parse a manager name into scope (namespace) and name, and use that to build a reconciler name. So we have to compare reconciler names instead of manager names.
Types ¶
type Diff ¶
type Diff struct { // Declared is the resource as it exists in the repository. Declared client.Object // Actual is the resource as it exists in the cluster. Actual client.Object }
Diff is resource where Declared and Actual do not match. Both Declared and Actual are client.Object.
func ThreeWay ¶
ThreeWay does a three way diff and returns the FileObjectDiff list. Compare between previous declared and new declared to decide the delete list. Compare between the new declared and the actual states to decide the create and update.
func (Diff) Operation ¶
Operation returns the type of the difference between the repository and the API Server.
func (Diff) UnstructuredActual ¶
func (d Diff) UnstructuredActual() (*unstructured.Unstructured, status.Error)
UnstructuredActual returns the actual as an unstructured object.
func (Diff) UnstructuredDeclared ¶
func (d Diff) UnstructuredDeclared() (*unstructured.Unstructured, status.Error)
UnstructuredDeclared returns the declared as an unstructured object.