Commit 52133b9
committed
✨ Add automated schema generation and validation for registry+v1 bundle configuration
Summary:
Implements Phase 1 of the variable configuration feature to achieve feature parity with
OLMv0's SubscriptionConfig for registry+v1 bundles.
RFC: https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0#heading=h.x3tfh25grvnv
Details:
This PR adds infrastructure for JSON schema-based validation of registry+v1 bundle configuration
in ClusterExtension, including both `watchNamespace` and `deploymentConfig` fields:
- **Schema Generation Tool**: Created reflection-based generator (`hack/tools/schema-generator/`)
that automatically introspects `v1alpha1.SubscriptionConfig` from `github.com/operator-framework/api`
to produce a complete registry+v1 bundle configuration JSON Schema Draft 7 document
- Generates schema with `watchNamespace` (for operator scope) and `deploymentConfig` (for deployment customization)
- Handles nested k8s corev1 types recursively
- Supports inline/embedded struct fields
- Extracts field documentation from Go source via AST parsing
- Excludes `selector` field (unused in OLMv0)
- **Runtime Schema Customization**: The base schema is loaded and modified at runtime based on
operator install modes:
- `watchNamespace` validation rules are customized per operator's supported install modes
- AllNamespaces only: watchNamespace removed (operator always watches all namespaces)
- OwnNamespace only: watchNamespace required, must equal install namespace
- SingleNamespace only: watchNamespace required, must differ from install namespace
- AllNamespaces + OwnNamespace: watchNamespace optional
- **Validation Infrastructure**: Added `internal/operator-controller/rukpak/bundle/schema/` package with:
- `GetBundleConfigSchemaMap()` function that provides the base bundle config schema
- Runtime schema modification in `buildBundleConfigSchema()` based on install modes
- Validation integrated into bundle config unmarshaling via `config.UnmarshalConfig()`
- Comprehensive test coverage
- **Regeneration Workflow**: Added `make update-registryv1-bundle-schema` target to regenerate schema when
upstream SubscriptionConfig changes.
When the upstream `v1alpha1.SubscriptionConfig` adds new fields (e.g., new k8s corev1 types), running the
regeneration target will automatically include them in the schema without manual updates.
Addresses OPRUN-4112 (Phase 1)
Future PRs will implement:
- Phase 2: Renderer integration to apply deploymentConfig to Deployments
- Phase 3: Provider integration to extract bundle configuration from bundles
- Phase 4: Documentation1 parent 8167ff8 commit 52133b9
File tree
11 files changed
+2898
-21
lines changed- hack/tools
- schema-generator
- internal/operator-controller
- config
- rukpak/bundle
- schema
11 files changed
+2898
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
225 | 229 | | |
226 | 230 | | |
227 | 231 | | |
| |||
0 commit comments