Documentation
¶
Overview ¶
Package role provides a builder and resource for managing Kubernetes Roles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a configuration helper for creating and customizing a Role Resource.
It provides a fluent API for registering mutations and data extractors. Build() validates the configuration and returns an initialized Resource ready for use in a reconciliation loop.
func NewBuilder ¶
NewBuilder initializes a new Builder with the provided Role object.
The Role object serves as the desired base state. During reconciliation the Resource will make the cluster's state match this base, modified by any registered mutations.
The provided Role must have both Name and Namespace set, which is validated during the Build() call.
func (*Builder) Build ¶
Build validates the configuration and returns the initialized Resource.
It returns an error if:
- No Role object was provided.
- The Role is missing a Name or Namespace.
func (*Builder) WithDataExtractor ¶
WithDataExtractor registers a function to read values from the Role after it has been successfully reconciled.
The extractor receives a value copy of the reconciled Role. This is useful for surfacing generated or updated entries to other components or resources.
A nil extractor is ignored.
func (*Builder) WithMutation ¶
WithMutation registers a mutation for the Role.
Mutations are applied sequentially during the Mutate() phase of reconciliation. A mutation with a nil Feature is applied unconditionally; one with a non-nil Feature is applied only when that feature is enabled.
type Mutation ¶
Mutation defines a mutation that is applied to a role Mutator only if its associated feature gate is enabled.
type Mutator ¶
type Mutator struct {
// contains filtered or unexported fields
}
Mutator is a high-level helper for modifying a Kubernetes Role.
It uses a "plan-and-apply" pattern: mutations are recorded first, then applied to the Role in a single controlled pass when Apply() is called.
The Mutator maintains feature boundaries: each feature's mutations are planned together and applied in the order the features were registered.
Mutator implements editors.ObjectMutator.
func NewMutator ¶
NewMutator creates a new Mutator for the given Role. The constructor creates the initial feature scope, so mutations can be registered immediately without an explicit call to NextFeature.
func (*Mutator) Apply ¶
Apply executes all recorded mutation intents on the underlying Role.
Execution order across all registered features:
- Metadata edits (in registration order within each feature)
- Rules edits (in registration order within each feature)
Features are applied in the order they were registered. Later features observe the Role as modified by all previous features.
func (*Mutator) EditObjectMetadata ¶
func (m *Mutator) EditObjectMetadata(edit func(*editors.ObjectMetaEditor) error)
EditObjectMetadata records a mutation for the Role's own metadata.
Metadata edits are applied before rules edits within the same feature. A nil edit function is ignored.
func (*Mutator) EditRules ¶
func (m *Mutator) EditRules(edit func(*editors.PolicyRulesEditor) error)
EditRules records a mutation for the Role's .rules field via a PolicyRulesEditor.
The editor provides SetRules to replace atomically, AddRule to append, and Raw() for free-form access. Rules edits are applied after metadata edits within the same feature, in registration order.
A nil edit function is ignored.
func (*Mutator) NextFeature ¶
func (m *Mutator) NextFeature()
NextFeature advances to a new feature planning scope. All subsequent mutation registrations will be grouped into this scope until NextFeature is called again.
The first scope is created automatically by NewMutator. This method is called by the framework between mutations to maintain per-feature ordering semantics.
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource is a high-level abstraction for managing a Kubernetes Role within a controller's reconciliation loop.
It implements the following component interfaces:
- component.Resource: for basic identity and mutation behaviour.
- concepts.DataExtractable: for exporting values after successful reconciliation.
Role resources are static: they do not model convergence health, grace periods, or suspension. Use a workload or task primitive for resources that require those concepts.
func (*Resource) ExtractData ¶
ExtractData executes all registered data extractor functions against a deep copy of the reconciled Role.
This is called by the framework after successful reconciliation, allowing the component to read generated or updated values from the Role.
func (*Resource) Identity ¶
Identity returns a unique identifier for the Role in the format "rbac.authorization.k8s.io/v1/Role/<namespace>/<name>".
func (*Resource) Mutate ¶
Mutate transforms the current state of a Kubernetes Role into the desired state.
The mutation process follows this order:
- The desired base state is applied to the current object.
- Feature mutations: all registered feature-gated mutations are applied in order.
This method is invoked by the framework during the Update phase of reconciliation.