operator

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MPL-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Event reasons for reporting. They are Event reasons only, never
	// condition reasons: reporting about reporting would perturb Ready.
	ReasonStatusReportFailed  = "StatusReportFailed"
	ReasonStatusReportSkipped = "StatusReportSkipped"
)

Delivery-target condition reporting (k8s-condition-reporting ADR D3, D4, D9, D10). Reporting is fire-and-forget beside the reconcile: it runs only after the status subresource write, never gates or requeues it, and never writes a condition. Its outcome is an Event at most.

Variables

View Source
var Version = "dev"

Version identifies the operator build in the fetch User-Agent (`hikyo-operator/<version>`). Set from cmd/hikyo/main.go, mirroring app.Version — the operator does not import internal/app for one string.

Functions

func NewManager

func NewManager(restCfg *rest.Config, cfg Config, opts ...ManagerOption) (manager.Manager, error)

NewManager builds the controller-runtime manager per § 0.7: leader election on, health/readyz on :8081, metrics on :8080, informer resync 10h explicit, and the cache restricted to the configured namespaces when set.

func Run

func Run(ctx context.Context, log *slog.Logger) error

Run boots the operator: loads config, builds the manager, registers the HikyoSecret controller, and blocks until the context is cancelled. It is the entrypoint cmd/hikyo wires the `operator` mode to.

Types

type Config

type Config struct {
	// Namespaces is the explicit watch/authority set. Empty means cluster-wide.
	// It is DERIVED, not authoritative: the install tooling generates the
	// RoleBindings AND this list from one input, and effective reach is the
	// intersection with what RBAC grants (ADR § Scoping).
	Namespaces []string

	// TriggerRollouts gates the workload-patch path (default true). When false
	// the operator neither lists nor patches workloads and the chart omits the
	// patch verbs entirely.
	TriggerRollouts bool

	// NativeSecretTypes permits non-Opaque targets and their conditional deletion
	// on authoritative withdrawal. Disabled by default; the chart gates delete
	// authority with the same switch.
	NativeSecretTypes bool

	// StatusReporting reports each HikyoSecret's conditions to its Hikyo
	// server (k8s-condition-reporting ADR D9, default true). The server must
	// also advertise the capability; its absence sends nothing.
	StatusReporting bool

	// OwnNamespace is the operator's own namespace, where the stamp-root Secret
	// lives. From HIKYO_OPERATOR_NAMESPACE, falling back to POD_NAMESPACE
	// (downward API). Missing is a hard error — the operator cannot derive or
	// store its stamp root without it.
	OwnNamespace string

	MetricsAddr string
	HealthAddr  string
}

Config is the operator's whole configuration surface: HIKYO_OPERATOR_* env only (§ 0.7). No keyring, no root key, no datastore. Missing required config is a hard error at boot — nothing is silently defaulted into existence.

func LoadConfig

func LoadConfig(getenv func(string) string) (Config, error)

LoadConfig parses HIKYO_OPERATOR_* env with fail-fast validation. getenv is injected so tests need no process environment.

type HikyoSecretReconciler

type HikyoSecretReconciler struct {
	client.Client
	// Reader is the UNCACHED API reader (mgr.GetAPIReader()). Every Secret and
	// ServiceAccount read goes through it, never the informer cache: the operator
	// holds only get/create/update/patch/delete on Secrets (no list/watch), so a cached
	// read would fail to start its informer, and — more importantly — the managed
	// Secret's controller-ownership/UID is the authority test and must be read
	// read-after-write, not from a cache that can lag a delete/recreate/re-own.
	Reader   client.Reader
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Config   Config
	Log      *slog.Logger

	// NewClientForURL builds the delivery client for an instance; nil defaults to
	// the real HTTPS client. Tests inject a stub.
	NewClientForURL func(rawURL string, caBundlePEM []byte) (deliveryClient, error)
	// TokenMinter mints federation tokens; nil is a hard error on the SA path.
	TokenMinter tokenMinter

	// SkipControllerNameValidation disables controller-runtime's process-global
	// controller-name uniqueness guard. Production leaves it false (one operator,
	// one controller, one process — the guard is free). It exists only so the kind
	// e2e can run more than one manager in a single test process without the
	// second SetupWithManager colliding on the shared "hikyosecret" controller
	// name; it changes nothing about a production single-manager deployment.
	SkipControllerNameValidation bool
	// contains filtered or unexported fields
}

HikyoSecretReconciler converges one managed Secret per HikyoSecret CR under the identity the CR names — the operator holds none of its own.

func (*HikyoSecretReconciler) Reconcile

func (r *HikyoSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile drives one CR toward its converged state per § 0.4/§ 0.5.

func (*HikyoSecretReconciler) SetupWithManager

func (r *HikyoSecretReconciler) SetupWithManager(mgr manager.Manager) error

SetupWithManager registers the reconciler and its watches. The managed Secret and the referenced workloads are Owns/Watches sources where cheap; the periodic resync is the floor that catches everything else (§ 0.4 refresh).

type ManagerOption

type ManagerOption func(*managerOptions)

ManagerOption tweaks NewManager. Production passes none; the seam exists so the kind e2e harness can run a real manager without leader election (a single in-process manager per test needs no lease, and acquiring one would only add startup latency and a lingering Lease object).

func WithLeaderElection

func WithLeaderElection(on bool) ManagerOption

WithLeaderElection overrides the default (on). It is an intentional API seam used by the build-tagged kind e2e harness, outside deadcode's default tags.

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 defines the Hikyo operator's CustomResourceDefinition Go types: HikyoInstance (cluster-scoped connection configuration) and HikyoSecret (namespaced delivery request).
Package v1alpha1 defines the Hikyo operator's CustomResourceDefinition Go types: HikyoInstance (cluster-scoped connection configuration) and HikyoSecret (namespaced delivery request).
Package client is the operator's HTTP client for the Hikyo delivery surface.
Package client is the operator's HTTP client for the Hikyo delivery surface.

Jump to

Keyboard shortcuts

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