util

package
v1.18.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SourceRetryBackoff sets retry timeout for `SourceCommitAndDirWithRetry`.
	SourceRetryBackoff = BackoffWithDurationLimit(5 * time.Minute)
	// HydratedRetryBackoff sets retry timeout for `readHydratedDirWithRetry`.
	HydratedRetryBackoff = BackoffWithDurationLimit(time.Minute)
)
View Source
var AutopilotManagedKinds = []schema.GroupVersionKind{

	admissionregistrationv1.SchemeGroupVersion.WithKind("MutatingWebhookConfiguration"),
	admissionregistrationv1.SchemeGroupVersion.WithKind("MutatingWebhookConfigurationList"),
}

AutopilotManagedKinds tracks the GVKs that are managed by GKE autopilot. ACM should not mutate resources with the same GVKs.

View Source
var AutopilotManagedNamespaces = map[string]bool{

	metav1.NamespaceSystem: true,
}

AutopilotManagedNamespaces tracks the namespaces that are managed by GKE autopilot. ACM should not mutate or create any resources in these namespaces.

Functions

func AutopilotResourceMutation

func AutopilotResourceMutation(annotation string) (map[string]corev1.ResourceRequirements, map[string]corev1.ResourceRequirements, error)

AutopilotResourceMutation extracts the input and output resource requirements for all containers. - input describes the containers' resources before Autopilot adjustment. - output describes the resources after Autopilot adjustment.

func BackoffWithDurationLimit added in v1.16.2

func BackoffWithDurationLimit(duration time.Duration) wait.Backoff

BackoffWithDurationLimit returns backoff with a duration limit in 10 steps. Here is an example of the duration between steps:

1.055843837s, 2.085359785s, 4.229560375s, 8.324724174s, 16.295984061s,
34.325711987s, 1m5.465642392s, 2m18.625713221s, 4m24.712222056s, 9m18.97652295s.

func EnvBool

func EnvBool(key string, def bool) bool

EnvBool retrieves the boolean value of the environment variable named by the key. If the variable is not present, it returns default value.

func EnvFloat

func EnvFloat(key string, def float64) float64

EnvFloat retrieves the float value of the environment variable named by the key. If the variable is not present, it returns default value.

func EnvInt

func EnvInt(key string, def int) int

EnvInt retrieves the int value of the environment variable named by the key. If the variable is not present, it returns default value.

func EnvList added in v1.16.0

func EnvList(key string, def []string) []string

EnvList retrieves the comma delimited list value of the environment variable named by the key. If the variable is not present, it returns default value.

func EnvString

func EnvString(key, def string) string

EnvString retrieves the string value of the environment variable named by the key. If the variable is not present, it returns default value.

func FakeAutopilotWebhookObject added in v1.17.0

func FakeAutopilotWebhookObject() client.Object

FakeAutopilotWebhookObject returns a fake empty MutatingWebhookConfiguration that satisfies IsGKEAutopilotCluster, for testing.

func IsAutopilotManagedNamespace

func IsAutopilotManagedNamespace(o client.Object) bool

IsAutopilotManagedNamespace returns if the input object is a namespace managed by the Autopilot cluster.

func IsErrorRetriable added in v1.16.2

func IsErrorRetriable(err error) bool

IsErrorRetriable returns if the error is retriable.

func IsGKEAutopilotCluster

func IsGKEAutopilotCluster(c client.Client) (bool, error)

IsGKEAutopilotCluster returns if the cluster is an autopilot cluster. It determines an Autopilot cluster by the presence of autopilot webhooks.

func NewRetriableError added in v1.16.2

func NewRetriableError(err error) error

NewRetriableError returns a RetriableError

func RetryWithBackoff added in v1.16.2

func RetryWithBackoff(backoff wait.Backoff, f func() error) error

RetryWithBackoff retries the function with the default backoff with a given retry limit.

func UpdateSymlink(helmRoot, linkAbsPath, packageDir, oldPackageDir string) error

UpdateSymlink updates the symbolic link to the package directory.

func WaitTime

func WaitTime(seconds float64) time.Duration

WaitTime returns the wait time between syncs in time.Duration type.

Types

type ContainerResources

type ContainerResources struct {
	// Compute Resources required by this container.
	corev1.ResourceRequirements
	// Name of the container specified as a DNS_LABEL.
	Name string `json:"name"`
}

ContainerResources describes the container's resource requirements.

type PodResources

type PodResources struct {
	// List of initialization containers belonging to the pod.
	InitContainers []ContainerResources `json:"initContainers,omitempty"`
	// List of containers belonging to the pod.
	Containers []ContainerResources `json:"containers,omitempty"`
}

PodResources describes the resources of all containers in a Pod.

type ResourceMutation

type ResourceMutation struct {
	// Input describes the container resources before the mutation.
	Input *PodResources `json:"input,omitempty"`
	// Output describes the container resources after the mutation.
	Output *PodResources `json:"output,omitempty"`
	// Modified indicates whether the resources are modified.
	Modified bool `json:"modified"`
}

ResourceMutation describes the mutation made by Autopilot.

type RetriableError added in v1.16.2

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

RetriableError represents a transient error that is retriable.

func (*RetriableError) Error added in v1.16.2

func (r *RetriableError) Error() string

Error implements the Error function of the interface.

Directories

Path Synopsis
Package watch includes a RestartableManager for dynamically watching resources.
Package watch includes a RestartableManager for dynamically watching resources.

Jump to

Keyboard shortcuts

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