Documentation
¶
Index ¶
- Constants
- func ContainsStorageRef(doc []byte) bool
- func DefaultResource[T client.Object](obj runtime.Object, kind string, log logr.Logger, fn func(T) error) error
- func EnforceMaxBytes(field string, raw []byte, max int, hint string) error
- func EnsureJSONObject(field string, b []byte) error
- func PickMaxInlineBytes(cfg *config.ControllerConfig) int
- func ResolveControllerConfig(log logr.Logger, mgr *config.OperatorConfigManager, ...) *config.ControllerConfig
- func ResolveReferencePolicy(cfg *config.ControllerConfig) string
- func ResolveRetryPolicy(cfg *config.ControllerConfig, policy *bubuv1alpha1.RetryPolicy) *bubuv1alpha1.RetryPolicy
- func ScrubStorageRefMetadata(doc []byte) ([]byte, error)
- func TrimLeadingSpace(b []byte) []byte
- func ValidateCreateResource[T client.Object](ctx context.Context, obj runtime.Object, kind string, log logr.Logger, ...) (admission.Warnings, error)
- func ValidateCrossNamespaceReference(ctx context.Context, reader client.Reader, cfg *config.ControllerConfig, ...) error
- func ValidateDeleteResource[T client.Object](obj runtime.Object, kind string, log logr.Logger, fn func(T) error) (admission.Warnings, error)
- func ValidateJSONAgainstSchema(doc []byte, schema []byte, schemaName string) error
- func ValidateJSONSchemaDefinition(schema []byte, schemaName string) error
- func ValidateReferenceMaps(doc []byte, field string) error
- func ValidateUpdateResource[T client.Object](ctx context.Context, oldObj, newObj runtime.Object, kind string, ...) (admission.Warnings, error)
- type EngramCustomDefaulter
- type EngramCustomValidator
- func (v *EngramCustomValidator) ValidateCreate(ctx context.Context, engram *bubushv1alpha1.Engram) (admission.Warnings, error)
- func (v *EngramCustomValidator) ValidateDelete(_ context.Context, engram *bubushv1alpha1.Engram) (admission.Warnings, error)
- func (v *EngramCustomValidator) ValidateUpdate(ctx context.Context, oldEngram, engram *bubushv1alpha1.Engram) (admission.Warnings, error)
- type EngramWebhook
- type ImpulseCustomDefaulter
- type ImpulseCustomValidator
- func (v *ImpulseCustomValidator) ValidateCreate(ctx context.Context, impulse *bubushv1alpha1.Impulse) (admission.Warnings, error)
- func (v *ImpulseCustomValidator) ValidateDelete(_ context.Context, obj *bubushv1alpha1.Impulse) (admission.Warnings, error)
- func (v *ImpulseCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj *bubushv1alpha1.Impulse) (admission.Warnings, error)
- type ImpulseWebhook
- type StoryCustomDefaulter
- type StoryCustomValidator
- func (v *StoryCustomValidator) ValidateCreate(ctx context.Context, story *bubushv1alpha1.Story) (admission.Warnings, error)
- func (v *StoryCustomValidator) ValidateDelete(_ context.Context, story *bubushv1alpha1.Story) (admission.Warnings, error)
- func (v *StoryCustomValidator) ValidateUpdate(ctx context.Context, oldStory, story *bubushv1alpha1.Story) (admission.Warnings, error)
- type StoryWebhook
Constants ¶
const DefaultRetryDelay = time.Second
DefaultRetryDelay is the default delay between retries when not specified.
Variables ¶
This section is empty.
Functions ¶
func ContainsStorageRef ¶ added in v0.1.4
ContainsStorageRef reports whether the JSON document contains a storage reference map.
Behavior:
- Returns false for empty or invalid JSON.
- Walks nested objects/arrays to detect any map with $bubuStorageRef.
func DefaultResource ¶ added in v0.1.4
func DefaultResource[T client.Object](obj runtime.Object, kind string, log logr.Logger, fn func(T) error) error
DefaultResource wraps webhook defaulting handlers with shared type assertion and logging logic.
func EnforceMaxBytes ¶ added in v0.1.4
EnforceMaxBytes returns an error when raw exceeds max.
Behavior:
- Compares len(raw) against max bytes.
- Appends hint to error message for context-specific guidance.
Arguments:
- field string: field name for error message (e.g., "spec.with").
- raw []byte: the payload to check.
- max int: maximum allowed bytes.
- hint string: additional guidance appended to error (can be empty).
Returns:
- nil if len(raw) <= max.
- Error describing the size violation.
func EnsureJSONObject ¶ added in v0.1.4
EnsureJSONObject returns an error when b is non-empty and not a valid JSON object.
Behavior:
- Validates JSON syntax when b is non-empty.
- Checks if b starts with '{' (JSON object).
- Returns error if b is non-empty and starts with array '[' or primitive.
- Callers should trim leading whitespace before invoking.
Arguments:
- field string: field name for error message (e.g., "spec.with").
- b []byte: the byte slice to check.
Returns:
- nil if b is empty or starts with '{'.
- Error if b is a non-object JSON value.
func PickMaxInlineBytes ¶ added in v0.1.4
func PickMaxInlineBytes(cfg *config.ControllerConfig) int
PickMaxInlineBytes returns the maximum inline payload size (in bytes) enforced by webhook validation.
Behavior:
- Uses cfg.Engram.EngramControllerConfig.DefaultMaxInlineSize if set.
- Falls back to config.DefaultControllerConfig() if cfg is nil.
- Falls back to 1024 bytes if the config value is zero.
Arguments:
- cfg *config.ControllerConfig: may be nil.
Returns:
- Maximum allowed inline bytes (at least 1024).
func ResolveControllerConfig ¶ added in v0.1.4
func ResolveControllerConfig(log logr.Logger, mgr *config.OperatorConfigManager, cfg *config.ControllerConfig) *config.ControllerConfig
ResolveControllerConfig returns the effective controller configuration.
Behavior:
- Checks ConfigManager first for live configuration.
- Falls back to embedded cfg if ConfigManager returns nil.
- Uses DefaultControllerConfig() as final fallback.
- Logs at V(1) level when falling back for observability.
Arguments:
- log logr.Logger: for logging fallback events.
- mgr *config.OperatorConfigManager: optional ConfigManager for live config.
- cfg *config.ControllerConfig: optional embedded config fallback.
Returns:
- Non-nil *config.ControllerConfig from the highest priority source.
func ResolveReferencePolicy ¶ added in v0.1.4
func ResolveReferencePolicy(cfg *config.ControllerConfig) string
ResolveReferencePolicy returns the effective cross-namespace reference policy.
func ResolveRetryPolicy ¶ added in v0.1.3
func ResolveRetryPolicy(cfg *config.ControllerConfig, policy *bubuv1alpha1.RetryPolicy) *bubuv1alpha1.RetryPolicy
ResolveRetryPolicy applies controller defaults to a retry policy when it is omitted.
Behavior:
- If policy is nil, creates a new empty RetryPolicy.
- Sets MaxRetries to cfg.MaxRetries (or 3 if cfg is nil or MaxRetries < 0).
- Sets Delay to DefaultRetryDelay (1s) if nil or empty.
- Sets Backoff strategy to Exponential if nil.
Arguments:
- cfg *config.ControllerConfig: controller configuration; may be nil.
- policy *bubuv1alpha1.RetryPolicy: policy to resolve; may be nil.
Returns:
- Non-nil *bubuv1alpha1.RetryPolicy with all fields populated.
func ScrubStorageRefMetadata ¶ added in v0.1.4
ScrubStorageRefMetadata removes storage ref metadata keys from any storage ref maps.
Behavior:
- Removes $bubuStorageContentType, $bubuStorageSchema, and $bubuStorageSchemaVersion when a map contains $bubuStorageRef.
- Returns the original document for empty input.
- Returns an error for invalid JSON.
func TrimLeadingSpace ¶ added in v0.1.4
TrimLeadingSpace removes leading ASCII whitespace characters from b.
Behavior:
- Strips space, newline, tab, and carriage return from the start of b.
- Returns the remaining slice without allocating new memory.
Arguments:
- b []byte: the byte slice to trim.
Returns:
- The input slice with leading whitespace removed.
func ValidateCreateResource ¶ added in v0.1.4
func ValidateCreateResource[T client.Object](ctx context.Context, obj runtime.Object, kind string, log logr.Logger, fn func(context.Context, T) error) (admission.Warnings, error)
ValidateCreateResource wraps webhook create validators with consistent type assertion and logging.
func ValidateCrossNamespaceReference ¶ added in v0.1.4
func ValidateCrossNamespaceReference( ctx context.Context, reader client.Reader, cfg *config.ControllerConfig, from client.Object, fromGroup string, fromKind string, toGroup string, toKind string, toNamespace string, toName string, refLabel string, ) error
ValidateCrossNamespaceReference enforces cross-namespace policy for a reference.
Returns nil when the reference is same-namespace or allowed by policy.
func ValidateDeleteResource ¶ added in v0.1.4
func ValidateDeleteResource[T client.Object](obj runtime.Object, kind string, log logr.Logger, fn func(T) error) (admission.Warnings, error)
ValidateDeleteResource wraps webhook delete validators with consistent type assertion and logging.
func ValidateJSONAgainstSchema ¶ added in v0.1.4
ValidateJSONAgainstSchema is a shared wrapper for schema validation across webhooks.
Behavior:
- Delegates to the internal validator, which normalizes schemas and allows storage refs.
Arguments:
- doc []byte: the JSON document to validate.
- schema []byte: the JSON Schema bytes.
- schemaName string: human-readable name for error messages.
Returns:
- nil if validation passes.
- Error describing normalization/validation failures.
func ValidateJSONSchemaDefinition ¶ added in v0.1.4
ValidateJSONSchemaDefinition validates that a JSON Schema is syntactically valid.
Behavior:
- Normalizes the schema to support inline required flags.
- Uses gojsonschema to parse the schema without validating a document.
Arguments:
- schema []byte: JSON-encoded JSON Schema.
- schemaName string: human-readable name for error messages.
Returns:
- nil if schema is valid.
- Error describing schema parsing failures.
func ValidateReferenceMaps ¶ added in v0.1.4
ValidateReferenceMaps ensures configmap/secret/storage ref maps are well-formed.
Behavior:
- Parses doc JSON into an interface tree.
- Walks maps/slices, validating any reference maps encountered.
- Returns the first error with a JSON path context.
Arguments:
- doc []byte: JSON document bytes.
- field string: field label for error messages.
Returns:
- nil if no invalid reference maps are found.
- Error with field/path details otherwise.
func ValidateUpdateResource ¶ added in v0.1.4
func ValidateUpdateResource[T client.Object](ctx context.Context, oldObj, newObj runtime.Object, kind string, log logr.Logger, fn func(context.Context, T, T) error) (admission.Warnings, error)
ValidateUpdateResource wraps webhook update validators with type assertion, deletion short-circuit, and logging. The DeletionTimestamp check is performed before logging to suppress noisy log entries for resources undergoing deletion. fn receives both the typed old and new objects; returning nil from fn skips further validation (e.g., spec unchanged).
Types ¶
type EngramCustomDefaulter ¶
type EngramCustomDefaulter struct {
}
EngramCustomDefaulter struct is responsible for setting default values on the custom resource of the Kind Engram when those are created or updated.
+kubebuilder:object:generate=false NOTE: This is an internal webhook helper and is not registered in the API scheme. It does not implement runtime.Object, so no DeepCopy generation is needed or applied.
func (*EngramCustomDefaulter) Default ¶
func (d *EngramCustomDefaulter) Default(_ context.Context, engram *bubushv1alpha1.Engram) error
Default implements admission.Defaulter for Engram resources.
Behavior:
- Currently a no-op; Engram defaults are intentionally minimal.
- Controller handles defaulting at reconcile time.
Arguments:
- ctx context.Context: unused but required by interface.
- engram *bubushv1alpha1.Engram: the Engram being defaulted.
Returns:
- nil (always succeeds; no defaults applied).
type EngramCustomValidator ¶
type EngramCustomValidator struct {
Client client.Reader
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
EngramCustomValidator struct is responsible for validating the Engram resource when it is created, updated, or deleted.
+kubebuilder:object:generate=false NOTE: This is an internal webhook helper and is not registered in the API scheme. It does not implement runtime.Object, so no DeepCopy generation is needed or applied.
func (*EngramCustomValidator) ValidateCreate ¶
func (v *EngramCustomValidator) ValidateCreate(ctx context.Context, engram *bubushv1alpha1.Engram) (admission.Warnings, error)
ValidateCreate implements admission.Validator for Engram creation.
Behavior:
- Validates templateRef.name is set and template exists.
- Validates with block is a JSON object and within size limits.
Arguments:
- ctx context.Context: for template lookup.
- engram *bubushv1alpha1.Engram: the Engram being created.
Returns:
- nil, nil if validation passes.
- nil, error if validation errors exist.
func (*EngramCustomValidator) ValidateDelete ¶
func (v *EngramCustomValidator) ValidateDelete(_ context.Context, engram *bubushv1alpha1.Engram) (admission.Warnings, error)
ValidateDelete implements admission.Validator for Engram deletion.
Behavior:
- Always allows deletion (no-op validation).
- Exists as scaffold placeholder; delete verb not enabled in annotation.
Arguments:
- ctx context.Context: unused.
- engram *bubushv1alpha1.Engram: the Engram being deleted.
Returns:
- nil, nil (deletion always allowed).
func (*EngramCustomValidator) ValidateUpdate ¶
func (v *EngramCustomValidator) ValidateUpdate(ctx context.Context, oldEngram, engram *bubushv1alpha1.Engram) (admission.Warnings, error)
ValidateUpdate implements admission.Validator for Engram updates.
Behavior:
- Skips validation for resources undergoing deletion (DeletionTimestamp set).
- Rejects spec changes while deletion is in progress (only finalizer edits allowed).
- Skips validation when spec is semantically unchanged; normalises RawExtension fields before comparison to prevent false mismatches after SSA round-trips.
- Validates templateRef.name is set and template exists.
- Validates with block is a JSON object and within size limits.
Arguments:
- ctx context.Context: for template lookup.
- oldEngram *bubushv1alpha1.Engram: previous Engram state.
- engram *bubushv1alpha1.Engram: proposed Engram state.
Returns:
- nil, nil if validation passes or is skipped.
- nil, error if validation errors exist.
type EngramWebhook ¶
type EngramWebhook struct {
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
func (*EngramWebhook) SetupWebhookWithManager ¶
func (wh *EngramWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error
SetupWebhookWithManager registers the webhook for Engram in the manager.
Behavior:
- Creates both defaulter and validator webhooks for Engram resources.
- Uses mgr.GetAPIReader() for template lookups to avoid cache staleness.
Arguments:
- mgr ctrl.Manager: the controller-runtime manager.
Returns:
- nil on success.
- Error if webhook registration fails.
type ImpulseCustomDefaulter ¶
type ImpulseCustomDefaulter struct {
}
ImpulseCustomDefaulter struct is responsible for setting default values on the custom resource of the Kind Impulse when those are created or updated.
NOTE: This is an internal webhook helper and is not registered in the API scheme. It does not implement runtime.Object, so no DeepCopy generation is needed or applied.
func (*ImpulseCustomDefaulter) Default ¶
func (d *ImpulseCustomDefaulter) Default(_ context.Context, obj *bubushv1alpha1.Impulse) error
Default implements webhook.CustomDefaulter for Impulse resources.
Behavior:
- Currently a no-op; Impulse defaults are intentionally minimal.
- Controller handles defaulting at reconcile time.
Arguments:
- ctx context.Context: unused but required by interface.
- obj *bubushv1alpha1.Impulse: the Impulse to default.
Returns:
- nil always (no defaulting logic).
type ImpulseCustomValidator ¶
type ImpulseCustomValidator struct {
Client client.Client
APIReader client.Reader
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
ImpulseCustomValidator struct is responsible for validating the Impulse resource when it is created, updated, or deleted.
NOTE: This is an internal webhook helper and is not registered in the API scheme. It does not implement runtime.Object, so no DeepCopy generation is needed or applied.
func (*ImpulseCustomValidator) ValidateCreate ¶
func (v *ImpulseCustomValidator) ValidateCreate(ctx context.Context, impulse *bubushv1alpha1.Impulse) (admission.Warnings, error)
ValidateCreate implements webhook.CustomValidator for Impulse creation.
Behavior:
- Validates spec fields, with/mapping blocks, and workload mode.
Arguments:
- ctx context.Context: for template lookup.
- impulse *bubushv1alpha1.Impulse: the Impulse being created.
Returns:
- nil, nil if validation passes.
- nil, error if validation errors exist.
func (*ImpulseCustomValidator) ValidateDelete ¶
func (v *ImpulseCustomValidator) ValidateDelete(_ context.Context, obj *bubushv1alpha1.Impulse) (admission.Warnings, error)
ValidateDelete implements webhook.CustomValidator for Impulse deletion.
Behavior:
- Always allows deletion (no-op validation).
- Exists as scaffold placeholder; delete verb not enabled in annotation.
Arguments:
- ctx context.Context: unused.
- obj *bubushv1alpha1.Impulse: the Impulse being deleted.
Returns:
- nil, nil (deletion always allowed).
func (*ImpulseCustomValidator) ValidateUpdate ¶
func (v *ImpulseCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj *bubushv1alpha1.Impulse) (admission.Warnings, error)
ValidateUpdate implements webhook.CustomValidator for Impulse updates.
Behavior:
- Validates spec fields, with/mapping blocks, and workload mode.
- Short-circuits for deletion or spec-unchanged updates.
Arguments:
- ctx context.Context: for template lookup.
- oldObj *bubushv1alpha1.Impulse: previous Impulse state.
- newObj *bubushv1alpha1.Impulse: proposed Impulse state.
Returns:
- nil, nil if validation passes.
- nil, error if validation errors exist.
type ImpulseWebhook ¶
type ImpulseWebhook struct {
client.Client
APIReader client.Reader
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
func (*ImpulseWebhook) SetupWebhookWithManager ¶
func (wh *ImpulseWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error
SetupWebhookWithManager registers the webhook for Impulse in the manager.
Behavior:
- Stores the manager's API reader and cached client for validation lookups.
- Creates both defaulter and validator webhooks for Impulse resources.
Arguments:
- mgr ctrl.Manager: the controller-runtime manager.
Returns:
- nil on success.
- Error if webhook registration fails.
type StoryCustomDefaulter ¶
type StoryCustomDefaulter struct {
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
StoryCustomDefaulter struct is responsible for setting default values on the custom resource of the Kind Story when those are created or updated.
NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, as it is used only for temporary operations and does not need to be deeply copied.
func (*StoryCustomDefaulter) Default ¶
func (d *StoryCustomDefaulter) Default(_ context.Context, story *bubushv1alpha1.Story) error
Default implements admission.Defaulter for Story resources.
Behavior:
- Resolves RetryPolicy for Story-level and step-level retries.
- Sets MaxRetries, Delay, and Backoff if not specified.
Arguments:
- ctx context.Context: unused but required by interface.
- story *bubushv1alpha1.Story: the Story being defaulted.
Returns:
- nil on success.
type StoryCustomValidator ¶
type StoryCustomValidator struct {
Client client.Client
APIReader client.Reader
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
StoryCustomValidator struct is responsible for validating the Story resource when it is created, updated, or deleted.
NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, as this struct is used only for temporary operations and does not need to be deeply copied.
func (*StoryCustomValidator) ValidateCreate ¶
func (v *StoryCustomValidator) ValidateCreate(ctx context.Context, story *bubushv1alpha1.Story) (admission.Warnings, error)
ValidateCreate implements admission.Validator for Story creation.
Behavior:
- Validates spec fields, size limits, steps shape, graph acyclicity, and transports.
- Uses 5-second timeout for template/Engram lookups.
Arguments:
- ctx context.Context: for API lookups.
- story *bubushv1alpha1.Story: the Story being created.
Returns:
- nil, nil if validation passes.
- nil, error if validation errors exist.
func (*StoryCustomValidator) ValidateDelete ¶
func (v *StoryCustomValidator) ValidateDelete(_ context.Context, story *bubushv1alpha1.Story) (admission.Warnings, error)
ValidateDelete implements admission.Validator for Story deletion.
Behavior:
- Always allows deletion (no-op validation).
- Exists as scaffold placeholder; delete verb not enabled in annotation.
Arguments:
- ctx context.Context: unused.
- story *bubushv1alpha1.Story: the Story being deleted.
Returns:
- nil, nil (deletion always allowed).
func (*StoryCustomValidator) ValidateUpdate ¶
func (v *StoryCustomValidator) ValidateUpdate(ctx context.Context, oldStory, story *bubushv1alpha1.Story) (admission.Warnings, error)
ValidateUpdate implements admission.Validator for Story updates.
Behavior:
- Skips validation if resource is being deleted (DeletionTimestamp set).
- Skips validation if spec is unchanged (metadata-only update).
- Uses 5-second timeout for template/Engram lookups.
Arguments:
- ctx context.Context: for API lookups.
- oldStory *bubushv1alpha1.Story: previous Story state.
- story *bubushv1alpha1.Story: proposed Story state.
Returns:
- nil, nil if validation passes or is skipped.
- nil, error if validation errors exist.
type StoryWebhook ¶
type StoryWebhook struct {
client.Client
APIReader client.Reader
Config *config.ControllerConfig
ConfigManager *config.OperatorConfigManager
}
StoryWebhook sets up the webhook for Story in the manager.
func (*StoryWebhook) SetupWebhookWithManager ¶
func (wh *StoryWebhook) SetupWebhookWithManager(mgr ctrl.Manager) error
SetupWebhookWithManager registers the webhook for Story in the manager.
Behavior:
- Stores the manager's API reader and cached client for validation lookups.
- Creates both defaulter and validator webhooks for Story resources.
- Injects Config and ConfigManager into both handlers.
Arguments:
- mgr ctrl.Manager: the controller-runtime manager.
Returns:
- nil on success.
- Error if webhook registration fails.