differ

package
v1.17.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package differ contains code for diffing sync-enabled resources, not necessarily known at compile time.

Index

Constants

View Source
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

SpecialNamespaces tracks the namespaces ACM should never remove from a cluster.

Functions

func IsManageableSystemNamespace

func IsManageableSystemNamespace(o client.Object) bool

IsManageableSystemNamespace returns if the input namespace is a manageable system namespace.

func ManagedByConfigSync

func ManagedByConfigSync(obj client.Object) bool

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

func ManagementDisabled(obj client.Object) bool

ManagementDisabled returns true if the resource in the repo explicitly has management disabled.

func ManagementEnabled

func ManagementEnabled(obj client.Object) bool

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

func ManagementUnset(obj client.Object) bool

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.

func (Diff) Type

func (d Diff) Type() Type

Type returns the type of the difference between the repository and the API Server.

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.

type Type

type Type string

Type indicates the state of the given resource

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL