utils

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const (
	REJECTED_THROTTLING           = "Rejected.Throttling"
	SERVICE_UNAVAILABLE_TEMPORARY = "ServiceUnavailableTemporary"
	INTERNAL_FAILURE              = "InternalFailure"
)
View Source
const (
	BinaryType = "binary"
)
View Source
const TriggerReconcileAnnotation = "ack-secret-manager.alibabacloud.com/trigger-reconcile"

TriggerReconcileAnnotation forces store client recreation when set on a SecretStore/ClusterSecretStore; shared by the store controllers and the Secret/ServiceAccount trigger controllers so the literal never drifts.

Variables

View Source
var (
	BACKOFF_DEFAULT_RETRY_INTERVAL = time.Second
	BACKOFF_DEFAULT_CAPACITY       = time.Duration(10) * time.Second
)

Functions

func Contains

func Contains(list []string, s string) bool

func GenerateDefaultOidcProviderArn added in v0.6.2

func GenerateDefaultOidcProviderArn(clusterId string, uid int64) string

func GetConfigFromSecret added in v0.5.0

func GetConfigFromSecret(ctx context.Context, r client.Client, secretRef *v1alpha1.SecretRef) ([]byte, error)

func GetJsonSecrets added in v0.5.5

func GetJsonSecrets(jmesObj []v1alpha1.JMESPathObject, secretValue, key string) (jsonMap map[string]string, err error)

GetJsonSecrets evaluates jmesPath expressions against the fetched secret value (JSON or YAML). Per-expression failures are logged and skipped; the only returned error is a structurally invalid secret value.

func GetWaitTimeExponential added in v0.5.5

func GetWaitTimeExponential(retryTimes int) time.Duration

GetWaitTimeExponential returns 2^retryTimes * BACKOFF_DEFAULT_RETRY_INTERVAL with +/-20% jitter (spreads concurrent retries), capped at BACKOFF_DEFAULT_CAPACITY.

func IgnoreNotFoundError added in v0.5.0

func IgnoreNotFoundError(err error) error

Ignore not found errors

func IsNamespaceAllowedForClusterExternalSecret added in v0.6.2

func IsNamespaceAllowedForClusterExternalSecret(ces *v1alpha1.ClusterExternalSecret, namespace corev1.Namespace) bool

IsNamespaceAllowedForClusterExternalSecret reports whether the namespace is selected by the CES conditions (fail-closed): only an explicit match allows; only a fully empty selection config matches every namespace; any invalid selector/regex denies all namespaces.

func IsNamespaceAllowedForClusterSecretStore added in v0.6.2

func IsNamespaceAllowedForClusterSecretStore(clusterSecretStore *v1alpha1.ClusterSecretStore, namespaceName string, getClient func(context.Context, client.ObjectKey, client.Object, ...client.GetOption) error) bool

IsNamespaceAllowedForClusterSecretStore reports whether the namespace may access the ClusterSecretStore (fail-closed on invalid selectors/regexes)

func IsNamespaceWatched added in v0.6.7

func IsNamespaceWatched(watchNs map[string]bool, namespace string) bool

IsNamespaceWatched reports whether the namespace falls inside the watch scope built from --watch-namespaces / --exclude-namespaces (a map with true entries for watched and false entries for excluded namespaces). Include mode (any true entry present): only explicitly listed namespaces are watched. Exclude-only mode: a namespace is excluded only when mapped to false; an empty map or a missing key passes.

func IsValidJSON added in v0.6.6

func IsValidJSON(data []byte) bool

IsValidJSON reports whether data is a strict JSON document: the first byte must be '{' or '[' (leading whitespace is treated as YAML by design).

func IsValidOidcProviderArn added in v0.6.2

func IsValidOidcProviderArn(arn string) bool

func JsonStr added in v0.5.0

func JsonStr(o interface{}) string

func JudgeNeedRetry added in v0.5.5

func JudgeNeedRetry(err error) bool

JudgeNeedRetry reports whether err is transient and worth retrying: throttling/unavailability/internal-failure codes, 5xx/429 statuses (legacy ClientError by code, tea.SDKError by status fallback), and transient network errors (timeouts, resets, broken pipes). Permanent errors (403/404, DNS failures, invalid parameters) are NOT retryable; wrapped errors are matched via errors.As.

func PatchTriggerAnnotation added in v0.6.7

func PatchTriggerAnnotation(ctx context.Context, c client.Client, store client.Object) error

PatchTriggerAnnotation patches the trigger annotation onto the given store so its controller recreates the provider clients; the value is the current unix-nanosecond timestamp, so consecutive calls always produce a change. Callers must skip stores already carrying a non-empty trigger annotation (a pending rebuild is already guaranteed) to avoid amplifying rebuilds.

func ReadyConditionObservedGeneration added in v0.6.7

func ReadyConditionObservedGeneration(conditions []v1alpha1.SecretStoreStatusCondition) (observed int64, found bool)

ReadyConditionObservedGeneration locates the condition whose Type is SecretStoreReady and returns its ObservedGeneration. found is false when no such condition exists; callers treat that as "never managed by a Store controller" rather than assuming any particular list position.

func Remove

func Remove(list []string, s string) []string

Remove returns a new slice with all occurrences of s removed; the input slice is never modified in place.

func RetryOnTransient added in v0.6.6

func RetryOnTransient(ctx context.Context, maxAttempts int, fn func() error) error

RetryOnTransient invokes fn up to maxAttempts times, backing off exponentially (GetWaitTimeExponential) after each transient error judged by JudgeNeedRetry; non-retryable errors return immediately. The wait is interruptible via ctx: on cancellation the ctx error is wrapped (%w) with the last transient error included as text.

func RewriteRegexp added in v0.5.5

func RewriteRegexp(operation v1alpha1.ReplaceRule, in map[string]string) (map[string]string, error)

RewriteRegexp applies one regexp rewrite rule. An uncompilable Source is a configuration error returned to the caller (fail closed), not silently dropped.

func YamlStr added in v0.5.8

func YamlStr(o interface{}) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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