environments-controller

module
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0

README ΒΆ

BlanketOps Environments Controller

Kubernetes controller for BlanketOps Environments.

  • This project wires Kubernetes CRDs to the blanketops/environments engine.
  • The controller is intentionally thin β€” all business logic lives in the engine module.

Architecture

The system is split into two parts:

🧠 Engine (blanketops/environments)
  • Domain logic
  • Resolution layer
  • Mediators
  • Infra adapters
  • Secrets management
  • Contracts

πŸŽ› Controller (this project)

  • Kubernetes reconcilers
  • Watches CRDs
  • Calls engine mediators
  • Updates status

The controller orchestrates reconciliation; business rules live in the engine module.

Supported Resources

The controller reconciles:

  • Build
  • Deployment
  • Environment
  • Package
  • ServiceUnit
  • GitRepository
  • GitHubEvent
  • Route (registered, but errors on every CR β€” no domain handler is registered for its GVK yet)
  • Domain (registered, but Reconcile is a no-op stub)

CRD schemas for these Kinds live in the external environments-api module. All behavior is delegated to the engine layer.

Prerequisites

Go v1.26+
Docker
Kubernetes v1.25+
kubectl

Development

Build tooling is mage.

Run locally:

mage run

Build and push image:

IMG=<registry>/environments-controller:<tag> mage dockerbuild dockerpush

Run the unit test suite:

mage test

This repo generates config/rbac/role.yaml and syncs it to the separate install repo, which owns cluster deployment manifests (config/manager, config/default, Helm chart).

Release

Releases are tag-driven:

git tag v0.0.X
git push origin --tags

The pipeline will:

  • Generate CHANGELOG.md
  • Commit it to main
  • Create GitHub Release
  • Publish release notes

Design Principles

  • Thin controller
  • Engine-driven architecture
  • Explicit domain contracts
  • Resolution-based orchestration

Infrastructure adapters isolated from Kubernetes layer

License

Apache 2.0

Directories ΒΆ

Path Synopsis
main.go is the controller's process entry point.
main.go is the controller's process entry point.
internal
bootstrap
register.go wires the controller manager's runtime at startup.
register.go wires the controller manager's runtime at startup.
cache
setup.go aggregates every domain's cache behind a single Caches struct, so callers construct and pass around one value instead of six.
setup.go aggregates every domain's cache behind a single Caches struct, so callers construct and pass around one value instead of six.
cache/build
build.go constructs this controller's Build domain cache: a thin wrapper around blanketops-environments-core's cache/build package.
build.go constructs this controller's Build domain cache: a thin wrapper around blanketops-environments-core's cache/build package.
cache/deployment
deployment.go constructs this controller's Deployment domain cache: a thin wrapper around blanketops-environments-core's cache/deployment package.
deployment.go constructs this controller's Deployment domain cache: a thin wrapper around blanketops-environments-core's cache/deployment package.
cache/domain
domain.go constructs this controller's Domain domain cache: a thin wrapper around blanketops-environments-core's cache/domain package.
domain.go constructs this controller's Domain domain cache: a thin wrapper around blanketops-environments-core's cache/domain package.
cache/environment
environment.go constructs this controller's Environment domain cache: a thin wrapper around blanketops-environments-core's cache/environment package.
environment.go constructs this controller's Environment domain cache: a thin wrapper around blanketops-environments-core's cache/environment package.
cache/githubevent
githubevent.go constructs this controller's GitHubEvent domain cache: a thin wrapper around blanketops-environments-core's cache/githubevent package.
githubevent.go constructs this controller's GitHubEvent domain cache: a thin wrapper around blanketops-environments-core's cache/githubevent package.
cache/gitrepository
gitrepository.go constructs this controller's GitRepository domain cache: a thin wrapper around blanketops-environments-core's cache/gitrepository package.
gitrepository.go constructs this controller's GitRepository domain cache: a thin wrapper around blanketops-environments-core's cache/gitrepository package.
cache/packages
package.go constructs this controller's Package domain cache: a thin wrapper around blanketops-environments-core's cache/packages package.
package.go constructs this controller's Package domain cache: a thin wrapper around blanketops-environments-core's cache/packages package.
cache/route
route.go constructs this controller's Route domain cache: a thin wrapper around blanketops-environments-core's cache/route package.
route.go constructs this controller's Route domain cache: a thin wrapper around blanketops-environments-core's cache/route package.
cache/serviceunit
serviceunit.go constructs this controller's ServiceUnit domain cache: a thin wrapper around blanketops-environments-core's cache/serviceunit package.
serviceunit.go constructs this controller's ServiceUnit domain cache: a thin wrapper around blanketops-environments-core's cache/serviceunit package.
controller/environments
build.go reconciles the Build CR: routes create/update/delete through the core CQRS engine and, on setup, wires the Build domain's mediator, backend providers (Buildah, Kaniko, Buildpacks), and service into the domain registry.
build.go reconciles the Build CR: routes create/update/delete through the core CQRS engine and, on setup, wires the Build domain's mediator, backend providers (Buildah, Kaniko, Buildpacks), and service into the domain registry.
controller/events
githubevent.go reconciles the GitHubEvent CR: routes create/update/ delete through the core CQRS engine and, on setup, wires the GitHubEvent domain's mediator, GitHub provider, and service into the domain registry.
githubevent.go reconciles the GitHubEvent CR: routes create/update/ delete through the core CQRS engine and, on setup, wires the GitHubEvent domain's mediator, GitHub provider, and service into the domain registry.
controller/networks
This file owns DomainReconciler β€” the controller-runtime reconciler for the Domain CR.
This file owns DomainReconciler β€” the controller-runtime reconciler for the Domain CR.
controller/observers/build
Package build (build-observer) is the side-channel reconciler for Build CRs.
Package build (build-observer) is the side-channel reconciler for Build CRs.
controller/observers/buildrun
Package buildrun observes Shipwright BuildRun objects and reflects their terminal Succeeded condition back onto the owning Build CR's status.
Package buildrun observes Shipwright BuildRun objects and reflects their terminal Succeeded condition back onto the owning Build CR's status.
controller/observers/deployment
Package deployment implements the Deployment observer.
Package deployment implements the Deployment observer.
controller/observers/environment
Package environment (environment-observer) is the status rollup reconciler for Environment CRs.
Package environment (environment-observer) is the status rollup reconciler for Environment CRs.
controller/observers/githubevent
Package githubevent observes GitHubEvent CRs and the Argo Events Sensor provisioned for each, deriving and writing the event's accepted/triggered/ success status and conditions.
Package githubevent observes GitHubEvent CRs and the Argo Events Sensor provisioned for each, deriving and writing the event's accepted/triggered/ success status and conditions.
controller/observers/gitrepository
Package gitrepository observes the Crossplane Repository object the GitRepository domain's provider creates and reflects its Ready condition back onto the owning GitRepository CR's status.
Package gitrepository observes the Crossplane Repository object the GitRepository domain's provider creates and reflects its Ready condition back onto the owning GitRepository CR's status.
controller/observers/packages
Package packages observes kapp-controller App objects and reflects what they report back onto the owning Package CR's status.
Package packages observes kapp-controller App objects and reflects what they report back onto the owning Package CR's status.
controller/sources
gitrepository.go reconciles the GitRepository CR β€” the entry point of the delivery pipeline (GitRepository β†’ GitHubEvent β†’ Build β†’ SupplyChain β†’ Package β†’ Deployment).
gitrepository.go reconciles the GitRepository CR β€” the entry point of the delivery pipeline (GitRepository β†’ GitHubEvent β†’ Build β†’ SupplyChain β†’ Package β†’ Deployment).
domains/build
Package build implements the Build resource domain.
Package build implements the Build resource domain.
domains/deployment
Package deployment implements the Deployment resource domain.
Package deployment implements the Deployment resource domain.
domains/domain
Package domain implements the Domain resource domain.
Package domain implements the Domain resource domain.
domains/environment
Package environment implements the Environment resource domain.
Package environment implements the Environment resource domain.
domains/githubevent
Package githubevent implements the GitHubEvent resource domain.
Package githubevent implements the GitHubEvent resource domain.
domains/gitrepository
Package gitrepository implements the GitRepository resource domain.
Package gitrepository implements the GitRepository resource domain.
domains/packages
Package packages implements the Package resource domain.
Package packages implements the Package resource domain.
domains/route
Package route implements the Route resource domain.
Package route implements the Route resource domain.
domains/serviceunit
Package serviceunit implements the ServiceUnit resource domain.
Package serviceunit implements the ServiceUnit resource domain.
logging
Package logging owns the controller's root logger construction: a single zap.Logger (Init, guarded by sync.Once so repeated calls are safe and always return the same instance) wrapped as a logr.Logger (AsLogr) for controller-runtime's consumption.
Package logging owns the controller's root logger construction: a single zap.Logger (Init, guarded by sync.Once so repeated calls are safe and always return the same instance) wrapped as a logr.Logger (AsLogr) for controller-runtime's consumption.
mediators
Package environment provides two standalone helpers other mediators use to interact with the Environment CR that roots their delivery chain: EnsureEnvironment (find-or-create the Environment named by an object's environments.blanketops.dev/{name,type} labels) and PatchEnvironmentAggregate (resolve the Environment's contract, apply a caller-supplied mutation, and re-encode it back onto the CR).
Package environment provides two standalone helpers other mediators use to interact with the Environment CR that roots their delivery chain: EnsureEnvironment (find-or-create the Environment named by an object's environments.blanketops.dev/{name,type} labels) and PatchEnvironmentAggregate (resolve the Environment's contract, apply a caller-supplied mutation, and re-encode it back onto the CR).
mediators/build
Package build implements the Build prerequisite mediator.
Package build implements the Build prerequisite mediator.
mediators/serviceunit
Package serviceunit implements the ServiceUnit prerequisite mediator.
Package serviceunit implements the ServiceUnit prerequisite mediator.
runtime
Package runtime bundles the shared CQRS infrastructure every domain and mediator in this controller depends on: the field cache, event recorder, Domain registry, and command-dispatch Engine (all from github.com/blanketops/environments/core).
Package runtime bundles the shared CQRS infrastructure every domain and mediator in this controller depends on: the field cache, event recorder, Domain registry, and command-dispatch Engine (all from github.com/blanketops/environments/core).
testsupport
Package testsupport provides shared fixtures for the domain, mediator, and cache layer unit tests: a scheme matching production's RegisterSchemes (internal/bootstrap/register.go), a fake controller-runtime client builder with status-subresource support, a no-op event recorder, and helpers for encoding a Go map into the runtime.RawExtension contract format every BlanketOps CR spec/status uses.
Package testsupport provides shared fixtures for the domain, mediator, and cache layer unit tests: a scheme matching production's RegisterSchemes (internal/bootstrap/register.go), a fake controller-runtime client builder with status-subresource support, a no-op event recorder, and helpers for encoding a Go map into the runtime.RawExtension contract format every BlanketOps CR spec/status uses.
pkg
controller/environments
Package environments re-exports the environments-group reconciler types as public aliases.
Package environments re-exports the environments-group reconciler types as public aliases.
controller/events
Package events re-exports the events-group reconciler types as public aliases.
Package events re-exports the events-group reconciler types as public aliases.
controller/networks
Package networks re-exports the networks-group reconciler types as public aliases.
Package networks re-exports the networks-group reconciler types as public aliases.
controller/observers/build
Package build re-exports the build-observer reconciler type as a public alias.
Package build re-exports the build-observer reconciler type as a public alias.
controller/observers/buildrun
Package buildrun re-exports the buildrun-observer reconciler type as a public alias.
Package buildrun re-exports the buildrun-observer reconciler type as a public alias.
controller/observers/deployment
Package deployment re-exports the deployment-observer reconciler type as a public alias.
Package deployment re-exports the deployment-observer reconciler type as a public alias.
controller/observers/environment
Package environment re-exports the environment-observer reconciler type as a public alias.
Package environment re-exports the environment-observer reconciler type as a public alias.
controller/observers/githubevent
Package githubevent re-exports the githubevent-observer reconciler type as a public alias.
Package githubevent re-exports the githubevent-observer reconciler type as a public alias.
controller/observers/gitrepository
Package gitrepository re-exports the gitrepository-observer reconciler type as a public alias.
Package gitrepository re-exports the gitrepository-observer reconciler type as a public alias.
controller/sources
Package sources re-exports the sources-group reconciler types as public aliases.
Package sources re-exports the sources-group reconciler types as public aliases.
runtime
Package runtime re-exports the Runtime type as a public alias.
Package runtime re-exports the Runtime type as a public alias.

Jump to

Keyboard shortcuts

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