|
| 1 | +# AGENTS.md - horizon-operator |
| 2 | + |
| 3 | +## Project overview |
| 4 | + |
| 5 | +horizon-operator is a Kubernetes operator that manages |
| 6 | +[OpenStack Horizon](https://docs.openstack.org/horizon/latest/) (the web |
| 7 | +dashboard: project management, instance console, identity management, and |
| 8 | +custom theming) on OpenShift/Kubernetes. It is part of the |
| 9 | +[openstack-k8s-operators](https://github.com/openstack-k8s-operators) project. |
| 10 | + |
| 11 | +Key Horizon domain concepts: **dashboard**, **panels**, **custom themes**, |
| 12 | +**WSGI/httpd**, **session management**. |
| 13 | + |
| 14 | +Go module: `github.com/openstack-k8s-operators/horizon-operator` |
| 15 | +API group: `horizon.openstack.org` |
| 16 | +API version: `v1beta1` |
| 17 | + |
| 18 | +## Tech stack |
| 19 | + |
| 20 | +| Layer | Technology | |
| 21 | +|-------|------------| |
| 22 | +| Language | Go (modules, multi-module workspace via `go.work`) | |
| 23 | +| Scaffolding | [Kubebuilder v4](https://book.kubebuilder.io/) + [Operator SDK](https://sdk.operatorframework.io/) | |
| 24 | +| CRD generation | controller-gen (DeepCopy, CRDs, RBAC, webhooks) | |
| 25 | +| Config management | Kustomize | |
| 26 | +| Packaging | OLM bundle | |
| 27 | +| Testing | Ginkgo/Gomega + envtest (functional), KUTTL (integration) | |
| 28 | +| Linting | golangci-lint (`.golangci.yaml`) | |
| 29 | +| CI | Zuul (`zuul.d/`), Prow (`.ci-operator.yaml`), GitHub Actions | |
| 30 | + |
| 31 | +## Custom Resources |
| 32 | + |
| 33 | +| Kind | Purpose | |
| 34 | +|------|---------| |
| 35 | +| `Horizon` | Single CR managing the Horizon dashboard deployment (httpd/WSGI). No sub-CRs. | |
| 36 | + |
| 37 | +The `Horizon` CR has defaulting and validating admission webhooks. |
| 38 | + |
| 39 | +## Directory structure |
| 40 | + |
| 41 | +| Directory | Contents | |
| 42 | +|-----------|----------| |
| 43 | +| `api/v1beta1/` | CRD types (`horizon_types.go`), conditions, webhook markers | |
| 44 | +| `cmd/` | `main.go` entry point | |
| 45 | +| `internal/controller/` | Reconciler: `horizon_controller.go` | |
| 46 | +| `internal/horizon/` | Horizon resource builders (deployment, volumes, config) | |
| 47 | +| `internal/webhook/` | Webhook implementation | |
| 48 | +| `templates/` | Config files and scripts mounted into pods via `OPERATOR_TEMPLATES` env var | |
| 49 | +| `config/crd,rbac,manager,webhook/` | Generated Kubernetes manifests (CRDs, RBAC, deployment, webhooks) | |
| 50 | +| `config/samples/` | Example CRs (Kustomize overlays). `base/`, `custom-theme/`, `httpd-overrides/` for customization. | |
| 51 | +| `test/functional/` | envtest-based Ginkgo/Gomega tests | |
| 52 | +| `test/kuttl/` | KUTTL integration tests | |
| 53 | +| `hack/` | Helper scripts (CRD schema checker, local webhook runner) | |
| 54 | + |
| 55 | +## Build commands |
| 56 | + |
| 57 | +After modifying Go code, always run: `make generate manifests fmt vet`. |
| 58 | + |
| 59 | +## Code style guidelines |
| 60 | + |
| 61 | +- Follow standard openstack-k8s-operators conventions and lib-common patterns. |
| 62 | +- Use `lib-common` modules for conditions, endpoints, TLS, storage, and other |
| 63 | + cross-cutting concerns rather than re-implementing them. |
| 64 | +- CRD types go in `api/v1beta1/`. Controller logic goes in |
| 65 | + `internal/controller/`. Resource-building helpers go in `internal/horizon/`. |
| 66 | +- Config templates are plain files in `templates/` -- they are mounted at |
| 67 | + runtime via the `OPERATOR_TEMPLATES` environment variable. |
| 68 | +- Webhook logic is split between the kubebuilder markers in `api/v1beta1/` and |
| 69 | + the implementation in `internal/webhook/`. |
| 70 | + |
| 71 | +## Testing |
| 72 | + |
| 73 | +- Functional tests use the envtest framework with Ginkgo/Gomega and live in |
| 74 | + `test/functional/`. |
| 75 | +- KUTTL integration tests live in `test/kuttl/`. |
| 76 | +- Run all functional tests: `make test`. |
| 77 | +- When adding a new field or feature, add corresponding test cases in |
| 78 | + `test/functional/` and update fixture data accordingly. |
| 79 | + |
| 80 | +## Key dependencies |
| 81 | + |
| 82 | +- [lib-common](https://github.com/openstack-k8s-operators/lib-common): shared modules for conditions, endpoints, TLS, secrets, etc. |
| 83 | +- [infra-operator](https://github.com/openstack-k8s-operators/infra-operator): Memcached and topology APIs. |
| 84 | +- [keystone-operator](https://github.com/openstack-k8s-operators/keystone-operator): identity service registration. |
0 commit comments