Documentation ¶
Overview ¶
Package differ contains code for diffing sync-enabled resources, not necessarily known at compile time.
Index ¶
- Constants
- Variables
- func IsManageableSystemNamespace(o client.Object) bool
- func ManagedByConfigSync(obj client.Object) bool
- func ManagementDisabled(obj client.Object) bool
- func ManagementEnabled(obj client.Object) bool
- func ManagementUnset(obj client.Object) bool
- type Diff
- type NamespaceDiff
- type Type
Constants ¶
const ( // NoOp indicates that no action should be taken. NoOp = Type("no-op") // Create indicates the resource should be created. Create = Type("create") // Update indicates the resource is declared and is on the API server, so we should // calculate a patch and apply it. Update = Type("update") // Delete indicates the resource should be deleted. Delete = Type("delete") // DeleteNsConfig indicates the namespaceconfig should be deleted. DeleteNsConfig = Type("deletensconfig") // Error indicates the resource's management annotation in the API server is invalid. Error = Type("error") // Unmanage indicates the resource's management annotation should be removed from the API Server. Unmanage = Type("unmanage") // UnmanageNamespace indicates that the resource is a special Namespace // which should not be deleted directly by ACM. It should be unmanaged instead. UnmanageNamespace = Type("unmanage-namespace") )
Variables ¶
var SpecialNamespaces = map[string]bool{ metav1.NamespaceDefault: true, metav1.NamespaceSystem: true, metav1.NamespacePublic: true, corev1.NamespaceNodeLease: true, policycontroller.NamespaceSystem: true, }
SpecialNamespaces tracks the namespaces ACM should never remove from a cluster.
Functions ¶
func IsManageableSystemNamespace ¶
IsManageableSystemNamespace returns if the input namespace is a manageable system namespace.
func ManagedByConfigSync ¶
ManagedByConfigSync returns true if a resource is managed by Config Sync.
A resource is managed by Config Sync if it meets the following two criteria: 1) the `configmanagement.gke.io/managed` anntation is `enabled`; 2) the `configsync.gke.io/resource-id` annotation matches the resource.
A resource whose `configmanagement.gke.io/managed` anntation is `enabled` may not be managed by Config Sync, because the annotation may be copied from another resource managed by Config Sync.
func ManagementDisabled ¶
ManagementDisabled returns true if the resource in the repo explicitly has management disabled.
func ManagementEnabled ¶
ManagementEnabled returns true if the resource explicitly has management enabled on a resource on the API server.
A resource whose `configmanagement.gke.io/managed` anntation is `enabled` may not be managed by Config Sync, because the annotation may be copied from another resource managed by Config Sync.
Use `ManagedByConfigSync` to decide whether a resource is managed by Config Sync.
func ManagementUnset ¶
ManagementUnset returns true if the resource has no Nomos ResourceManagementKey.
Types ¶
type Diff ¶
type Diff struct { // Name is the name of the resource this diff is for. Name string // Declared is the resource as it exists in the repository. Declared *unstructured.Unstructured // Actual is the resource as it exists in the cluster. Actual *unstructured.Unstructured }
Diff is resource where Declared and Actual do not match.
func Diffs ¶
func Diffs(declared []*unstructured.Unstructured, actuals []*unstructured.Unstructured, allDeclaredVersions map[string]bool) []*Diff
Diffs returns the diffs between declared and actual state. We generate a diff for each GroupVersionKind. The actual resources are for all versions of a GroupKind and the declared resources are for a particular GroupKind. We need to ensure there is not a declared resource across all possible versions before we delete it. The diffs will be returned in an arbitrary order.
type NamespaceDiff ¶
type NamespaceDiff struct { Name string Declared *v1.NamespaceConfig Actual *corev1.Namespace }
NamespaceDiff represents a diff between a Namespace config and the one on the cluster.
func (*NamespaceDiff) Type ¶
func (d *NamespaceDiff) Type() Type
Type returns the type of the NamespaceDiff. TODO: Merge NamespaceDiff with Diff since there's overlap.