apply

package
v0.0.0-...-83bd9c0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2019 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// ApplySetToolingAnnotation is the key of the label that indicates which tool is used to manage this ApplySet.
	// Tooling should refuse to mutate ApplySets belonging to other tools.
	// The value must be in the format <toolname>/<semver>.
	// Example value: "kubectl/v1.27" or "helm/v3" or "kpt/v1.0.0"
	ApplySetToolingAnnotation = "applyset.kubernetes.io/tooling"

	// ApplySetAdditionalNamespacesAnnotation annotation extends the scope of the ApplySet beyond the parent
	// object's own namespace (if any) to include the listed namespaces. The value is a comma-separated
	// list of the names of namespaces other than the parent's namespace in which objects are found
	// Example value: "kube-system,ns1,ns2".
	ApplySetAdditionalNamespacesAnnotation = "applyset.kubernetes.io/additional-namespaces"

	// Deprecated: ApplySetGRsAnnotation is a list of group-resources used to optimize listing of ApplySet member objects.
	// It is optional in the ApplySet specification, as tools can perform discovery or use a different optimization.
	// However, it is currently required in kubectl.
	// When present, the value of this annotation must be a comma separated list of the group-resources,
	// in the fully-qualified name format, i.e. <resourcename>.<group>.
	// Example value: "certificates.cert-manager.io,configmaps,deployments.apps,secrets,services"
	DeprecatedApplySetGRsAnnotation = "applyset.kubernetes.io/contains-group-resources"

	// ApplySetGKsAnnotation is a list of group-kinds used to optimize listing of ApplySet member objects.
	// It is optional in the ApplySet specification, as tools can perform discovery or use a different optimization.
	// However, it is currently required in kubectl.
	// When present, the value of this annotation must be a comma separated list of the group-kinds,
	// in the fully-qualified name format, i.e. <kind>.<group>.
	// Example value: "Certificate.cert-manager.io,ConfigMap,deployments.apps,Secret,Service"
	ApplySetGKsAnnotation = "applyset.kubernetes.io/contains-group-kinds"

	// ApplySetParentIDLabel is the key of the label that makes object an ApplySet parent object.
	// Its value MUST use the format specified in V1ApplySetIdFormat below
	ApplySetParentIDLabel = "applyset.kubernetes.io/id"

	// V1ApplySetIdFormat is the format required for the value of ApplySetParentIDLabel (and ApplysetPartOfLabel).
	// The %s segment is the unique ID of the object itself, which MUST be the base64 encoding
	// (using the URL safe encoding of RFC4648) of the hash of the GKNN of the object it is on, in the form:
	// base64(sha256(<name>.<namespace>.<kind>.<group>)).
	V1ApplySetIdFormat = "applyset-%s-v1"

	// ApplysetPartOfLabel is the key of the label which indicates that the object is a member of an ApplySet.
	// The value of the label MUST match the value of ApplySetParentIDLabel on the parent object.
	ApplysetPartOfLabel = "applyset.kubernetes.io/part-of"

	// ApplysetParentCRDLabel is the key of the label that can be set on a CRD to identify
	// the custom resource type it defines (not the CRD itself) as an allowed parent for an ApplySet.
	ApplysetParentCRDLabel = "applyset.kubernetes.io/is-parent-type"
)

Label and annotation keys from the ApplySet specification. https://git.k8s.io/enhancements/keps/sig-cli/3659-kubectl-apply-prune#design-details-applyset-specification

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplySet

type ApplySet struct {
	// contains filtered or unexported fields
}

ApplySet tracks the information about an applyset apply/prune

func NewApplySet

func NewApplySet(parent *ApplySetParentRef, tooling ApplySetTooling, mapper meta.RESTMapper) *ApplySet

NewApplySet creates a new ApplySet object tracked by the given parent object.

func (*ApplySet) AddResource

func (a *ApplySet) AddResource(restMapping *meta.RESTMapping, namespace string)

Modified. change private to public addResource registers the given resource and namespace as being part of the updated set of resources being applied by the current operation.

func (*ApplySet) AllPrunableNamespaces

func (a *ApplySet) AllPrunableNamespaces() []string

AllPrunableNamespaces returns the list of all namespaces that should be considered for pruning. This is potentially a superset of the namespaces that actually contain resources.

func (*ApplySet) AllPrunableResources

func (a *ApplySet) AllPrunableResources() []*kindInfo

AllPrunableResources returns the list of all resources that should be considered for pruning. This is potentially a superset of the resources types that actually contain resources.

func (*ApplySet) BuildParentPatch

func (a *ApplySet) BuildParentPatch(mode ApplySetUpdateMode) *metav1.PartialObjectMetadata

Modified from private to public buildParentPatch --> BuildParentPatch

func (*ApplySet) FetchParent

func (a *ApplySet) FetchParent(obj runtime.Object) error

func (ApplySet) FieldManager

func (a ApplySet) FieldManager() string

func (*ApplySet) FindAllObjectsToPrune

func (a *ApplySet) FindAllObjectsToPrune(ctx context.Context, dynamicClient dynamic.Interface, visitedUids sets.Set[types.UID]) ([]PruneObject, error)

FindAllObjectsToPrune returns the list of objects that will be pruned. Calling this instead of Prune can be useful for dry-run / diff behaviour.

func (ApplySet) ID

func (a ApplySet) ID() string

func (*ApplySet) LabelSelectorForMembers

func (a *ApplySet) LabelSelectorForMembers() string

func (*ApplySet) LabelsForMember

func (a *ApplySet) LabelsForMember() map[string]string

func (ApplySet) Validate

func (a ApplySet) Validate(ctx context.Context, client dynamic.Interface) error

Validate imposes restrictions on the parent object that is used to track the applyset.

type ApplySetDeleteOptions

type ApplySetDeleteOptions struct {
	CascadingStrategy metav1.DeletionPropagation
	// DryRunStrategy    cmdutil.DryRunStrategy
	GracePeriod int
}

type ApplySetParentRef

type ApplySetParentRef struct {
	Name      string
	Namespace string
	*meta.RESTMapping
}

ApplySetParentRef stores object and type meta for the parent object that is used to track the applyset.

func (ApplySetParentRef) IsNamespaced

func (p ApplySetParentRef) IsNamespaced() bool

func (ApplySetParentRef) String

func (p ApplySetParentRef) String() string

String returns the string representation of the parent object using the same format that we expect to receive in the --applyset flag on the CLI.

type ApplySetTooling

type ApplySetTooling struct {
	Name    string
	Version string
}

func (ApplySetTooling) String

func (t ApplySetTooling) String() string

type ApplySetUpdateMode

type ApplySetUpdateMode string

type PruneObject

type PruneObject struct {
	Name      string
	Namespace string
	Mapping   *meta.RESTMapping
	Object    runtime.Object
}

PruneObject is an apiserver object that should be deleted as part of prune.

func (*PruneObject) String

func (p *PruneObject) String() string

String returns a human-readable name of the object, for use in debug messages.

Jump to

Keyboard shortcuts

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