clusterrolebinding-primitive

command
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

ClusterRoleBinding Primitive Example

This example demonstrates the usage of the clusterrolebinding primitive within the operator component framework. It shows how to manage a Kubernetes ClusterRoleBinding as a component of a larger application, utilising features like:

  • Base Construction: Initializing a ClusterRoleBinding with a roleRef and base subjects.
  • Feature Mutations: Adding subjects conditionally via feature-gated mutations using EditSubjects.
  • Metadata Mutations: Setting version labels on the ClusterRoleBinding via EditObjectMetadata.
  • Data Extraction: Inspecting ClusterRoleBinding state after each reconcile cycle.

Directory Structure

  • app/: Defines the controller that uses the component framework. The ExampleApp CRD is shared from examples/shared/app.
  • features/: Contains modular feature definitions:
    • mutations.go: version labelling and feature-gated monitoring subject addition.
  • resources/: Contains the central NewClusterRoleBindingResource factory that assembles all features using clusterrolebinding.Builder.
  • main.go: A standalone entry point that demonstrates building and mutating a ClusterRoleBinding through multiple spec variations.

Running the Example

go run examples/clusterrolebinding-primitive/main.go

This will:

  1. Create an in-memory ExampleApp owner object.
  2. For each of three spec variations, build a fresh resource and apply mutations to a simulated current ClusterRoleBinding.
  3. Print the reconciled ClusterRoleBinding state (labels, roleRef, subjects) after each mutation cycle.

Documentation

Overview

Package main is the entry point for the clusterrolebinding primitive example.

Directories

Path Synopsis
Package app provides a sample controller using the clusterrolebinding primitive.
Package app provides a sample controller using the clusterrolebinding primitive.
Package features provides sample mutations for the clusterrolebinding primitive example.
Package features provides sample mutations for the clusterrolebinding primitive example.
Package resources provides resource implementations for the clusterrolebinding primitive example.
Package resources provides resource implementations for the clusterrolebinding primitive example.

Jump to

Keyboard shortcuts

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