metadata

package
v4.0.0-...-b0ab343 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AnnotationTrue  = "true"
	AnnotationFalse = "false"

	AnnotationPrefix = "pulumi.com/"

	AnnotationAutonamed      = AnnotationPrefix + "autonamed"
	AnnotationSkipAwait      = AnnotationPrefix + "skipAwait"
	AnnotationWaitFor        = AnnotationPrefix + "waitFor"
	AnnotationTimeoutSeconds = AnnotationPrefix + "timeoutSeconds"
	AnnotationReplaceUnready = AnnotationPrefix + "replaceUnready"

	AnnotationPatchForce        = AnnotationPrefix + "patchForce"
	AnnotationPatchFieldManager = AnnotationPrefix + "patchFieldManager"

	AnnotationDeletionPropagation = AnnotationPrefix + "deletionPropagationPolicy"

	AnnotationHelmHook = "helm.sh/hook"
)
View Source
const (
	LabelManagedBy = "app.kubernetes.io/managed-by"
)

Variables

This section is empty.

Functions

func AdoptOldAutonameIfUnnamed

func AdoptOldAutonameIfUnnamed(newObj, oldObj *unstructured.Unstructured, newObjMap resource.PropertyMap)

AdoptOldAutonameIfUnnamed checks if `newObj` has a name, and if not, "adopts" the name of `oldObj` instead. If `oldObj` was autonamed, then we mark `newObj` as autonamed, too. Note that autonaming is preferred over generateName for backwards compatibility.

func AssignNameIfAutonamable

func AssignNameIfAutonamable(randomSeed []byte, obj *unstructured.Unstructured, propMap resource.PropertyMap, urn resource.URN)

AssignNameIfAutonamable generates a name for an object. Uses DNS-1123-compliant characters. All auto-named resources get the annotation `pulumi.com/autonamed` for tooling purposes.

func DeletedCondition

func DeletedCondition(
	ctx context.Context,
	source condition.Source,
	clientset clientGetter,
	logger *logging.DedupLogger,
	inputs *unstructured.Unstructured,
	obj *unstructured.Unstructured,
) (condition.Satisfier, error)

DeletedCondition inspects the object's annotations and returns a condition.Satisfier appropriate for using when awaiting deletion.

The "inputs" parameter is the source of truth for user-provided annotations, but it is not guaranteed to be named. The "obj" parameter should be used for conditions.

func DeletionPropagation

func DeletionPropagation(obj *unstructured.Unstructured) metav1.DeletionPropagation

DeletionPropagation returns the delete propagation policy, Foreground by default.

func GetAnnotationValue

func GetAnnotationValue(obj *unstructured.Unstructured, key string) string

GetAnnotationValue returns the value of the specified annotation on the provided Unstructured object.

func GetLabel

func GetLabel(obj *unstructured.Unstructured, key string) any

GetLabel gets the value of the specified label from the given object.

func HasManagedByLabel

func HasManagedByLabel(obj *unstructured.Unstructured) bool

HasManagedByLabel returns true if the object has the `app.kubernetes.io/managed-by` label set to the value of `PULUMI_KUBERNETES_MANAGED_BY_LABEL` EnvVar, `pulumi`, or is a computed value.

func IsAnnotationTrue

func IsAnnotationTrue(obj *unstructured.Unstructured, key string) bool

IsAnnotationTrue returns true if the specified annotation has the value "true", false otherwise.

func IsAutonamed

func IsAutonamed(obj *unstructured.Unstructured) bool

IsAutonamed checks if the object is auto-named by Pulumi.

func IsGenerateName

func IsGenerateName(obj *unstructured.Unstructured, propMap resource.PropertyMap) bool

IsGenerateName checks if the object is auto-named by Kubernetes.

func IsHelmHookAnnotation

func IsHelmHookAnnotation(key string) bool

IsHelmHookAnnotation returns true if the specified annotation has the `helm.sh/hook` prefix, false otherwise.

func IsInternalAnnotation

func IsInternalAnnotation(key string) bool

IsInternalAnnotation returns true if the specified annotation has the `pulumi.com/` prefix, false otherwise.

func IsNamed

func IsNamed(obj *unstructured.Unstructured, propMap resource.PropertyMap) bool

IsNamed checks if the object has an assigned name (may be a known or computed value).

func ReadyCondition

func ReadyCondition(
	ctx context.Context,
	source condition.Source,
	_ clientGetter,
	logger *logging.DedupLogger,
	inputs *unstructured.Unstructured,
	obj *unstructured.Unstructured,
) (condition.Satisfier, bool, error)

ReadyCondition reads annotations on the provided object and returns a condition.Satisfier appropriate to await on for creates and updates:

  • If the "pulumi.com/skipAwait" annotation is true, the ready condition will no-op.
  • If the "pulumi.com/waitFor" annotation is a string it will be interpreted as either a `JSONPath` expression or a custom condition, depending on whether it has a "jsonpath=" or "condition=" prefix, respectively.
  • If the "pulumi.com/waitFor" annotation is a JSON array of string expressions, the ready condition will wait for all expressions to succeed.
  • If PULUMI_K8S_AWAIT_ALL=true a generic/heuristic Ready condition is returned.
  • Otherwise we no-op.

JSONPath expressions must match the strict syntax used by `kubectl get -o`.

The "inputs" parameter is the source of truth for user-provided annotations, but it is not guaranteed to be named. The "obj" parameter should be used for conditions.

func ReplaceUnready

func ReplaceUnready(obj *unstructured.Unstructured) bool

ReplaceUnready returns true if the `pulumi.com/replaceUnready` annotation is "true", false otherwise.

func SetAnnotation

func SetAnnotation(obj *unstructured.Unstructured, key, value string)

SetAnnotation sets the specified key, value annotation on the provided Unstructured object. TODO(levi): This won't work for Pulumi-computed values. https://github.com/pulumi/pulumi-kubernetes/issues/826

func SetAnnotationTrue

func SetAnnotationTrue(obj *unstructured.Unstructured, key string)

SetAnnotationTrue sets the specified annotation key to "true" on the provided Unstructured object.

func SkipAwaitLogic

func SkipAwaitLogic(obj *unstructured.Unstructured) bool

SkipAwaitLogic returns true if the `pulumi.com/skipAwait` annotation is "true", false otherwise.

func TimeoutDuration

func TimeoutDuration(resourceTimeoutSeconds float64, obj *unstructured.Unstructured) *time.Duration

TimeoutDuration returns the resource timeout duration. There are a number of things it can do here in this order: 1. Return the timeout as specified in the customResource options 2. Return the timeout as specified in `pulumi.com/timeoutSeconds` annotation, 3. Return nil if the annotation is unset/invalid.

func TrySetLabel

func TrySetLabel(obj *unstructured.Unstructured, key, value string) (succeeded bool, err error)

TrySetLabel attempts to set the specified key/value pair as a label on the provided Unstructured object, reporting whether the write was successful, and an error if (e.g.) the underlying object is mistyped. In particular, TrySetLabel will fail if the underlying object has a Pulumi computed value.

func TrySetManagedByLabel

func TrySetManagedByLabel(obj *unstructured.Unstructured) (bool, error)

TrySetManagedByLabel attempts to set the `app.kubernetes.io/managed-by` label to the `pulumi` key on the provided Unstructured object, reporting whether the write was successful, and an error if (e.g.) the underlying object is mistyped. In particular, TrySetLabel will fail if the underlying object has a Pulumi computed value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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