Documentation
¶
Overview ¶
Package rolebinding provides a builder and resource for managing Kubernetes RoleBindings.
Index ¶
- type Builder
- type Mutation
- type Mutator
- type Resource
- func (r *Resource) ExtractData() error
- func (r *Resource) GuardStatus() (concepts.GuardStatusWithReason, error)
- func (r *Resource) Identity() string
- func (r *Resource) Mutate(current client.Object) error
- func (r *Resource) Object() (client.Object, error)
- func (r *Resource) PreviewObject() (*rbacv1.RoleBinding, error)
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 RoleBinding 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 ¶
func NewBuilder(rb *rbacv1.RoleBinding) *Builder
NewBuilder initializes a new Builder with the provided RoleBinding object.
The RoleBinding 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.
roleRef must be set on the provided RoleBinding object. It is immutable after creation and is not modifiable via the mutation API.
The provided RoleBinding 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 RoleBinding object was provided.
- The RoleBinding is missing a Name or Namespace.
- The RoleRef is missing APIGroup, Kind, or Name.
func (*Builder) WithDataExtractor ¶
func (b *Builder) WithDataExtractor(extractor func(rbacv1.RoleBinding) error) *Builder
WithDataExtractor registers a function to read values from the RoleBinding after it has been successfully reconciled.
The extractor receives a value copy of the reconciled RoleBinding. This is useful for surfacing generated or updated entries to other components or resources.
A nil extractor is ignored.
func (*Builder) WithGuard ¶ added in v0.4.0
func (b *Builder) WithGuard(guard func(rbacv1.RoleBinding) (concepts.GuardStatusWithReason, error)) *Builder
WithGuard registers a guard precondition that is evaluated before the RoleBinding is applied during reconciliation. If the guard returns Blocked, the RoleBinding and all resources registered after it are skipped until the guard clears. Passing nil clears any previously registered guard.
func (*Builder) WithMutation ¶
WithMutation registers a mutation for the RoleBinding.
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 rolebinding 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 RoleBinding.
It uses a "plan-and-apply" pattern: mutations are recorded first, then applied to the RoleBinding 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 ¶
func NewMutator(rb *rbacv1.RoleBinding) *Mutator
NewMutator creates a new Mutator for the given RoleBinding. 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 RoleBinding.
Execution order across all registered features:
- Metadata edits (in registration order within each feature)
- Subject edits (in registration order within each feature)
Features are applied in the order they were registered. Later features observe the RoleBinding as modified by all previous features.
func (*Mutator) EditObjectMetadata ¶
func (m *Mutator) EditObjectMetadata(edit func(*editors.ObjectMetaEditor) error)
EditObjectMetadata records a mutation for the RoleBinding's own metadata.
Metadata edits are applied before subject edits within the same feature. A nil edit function is ignored.
func (*Mutator) EditSubjects ¶
func (m *Mutator) EditSubjects(edit func(*editors.BindingSubjectsEditor) error)
EditSubjects records a mutation for the RoleBinding's subjects list via a BindingSubjectsEditor.
The editor provides structured operations (EnsureSubject, RemoveSubject) as well as Raw() for free-form access. Subject 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 RoleBinding within a controller's reconciliation loop.
It implements the following component interfaces:
- component.Resource: for basic identity and mutation behaviour.
- concepts.Guardable: for conditional reconciliation based on a guard precondition.
- concepts.DataExtractable: for exporting values after successful reconciliation.
RoleBinding resources are static: they do not model convergence health, grace periods, or suspension.
func (*Resource) ExtractData ¶
ExtractData executes all registered data extractor functions against a deep copy of the reconciled RoleBinding.
This is called by the framework after successful reconciliation, allowing the component to read generated or updated values from the RoleBinding.
func (*Resource) GuardStatus ¶ added in v0.4.0
func (r *Resource) GuardStatus() (concepts.GuardStatusWithReason, error)
GuardStatus evaluates the resource's guard precondition. If no guard was registered, the resource is unconditionally unblocked.
func (*Resource) Identity ¶
Identity returns a unique identifier for the RoleBinding in the format "rbac.authorization.k8s.io/v1/RoleBinding/<namespace>/<name>".
func (*Resource) Mutate ¶
Mutate transforms the provided Kubernetes RoleBinding into the desired state.
Feature mutations are applied in registration order. This method is invoked by the framework during the Update phase of reconciliation.
func (*Resource) Object ¶
Object returns a deep copy of the underlying Kubernetes RoleBinding object.
The returned object implements client.Object, making it compatible with controller-runtime's Client for Create, Update, and Patch operations.
func (*Resource) PreviewObject ¶ added in v0.6.0
func (r *Resource) PreviewObject() (*rbacv1.RoleBinding, error)
PreviewObject returns the RoleBinding as it would appear after feature mutations have been applied, without modifying the resource's internal state.
Suspension mutations are not applied; the preview reflects content state only.