Skip to content

✨ Add automated schema generation and validation for registry+v1 bundle configuration - #2454

Merged
anik120 merged 1 commit into
operator-framework:mainfrom
anik120:deploymentconfig-json-schema
Jan 28, 2026
Merged

✨ Add automated schema generation and validation for registry+v1 bundle configuration#2454
anik120 merged 1 commit into
operator-framework:mainfrom
anik120:deploymentconfig-json-schema

Conversation

@anik120

@anik120anik120 commented Jan 20, 2026

Copy link
Copy Markdown
Member

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: Parses SubscriptionConfig using AST to extract field names/types

    • Fetches Kubernetes OpenAPI v3 specs from GitHub releases
    • Maps fields to official Kubernetes schemas
    • Generates schema with watchNamespace (for operator scope) and deploymentConfig (for deployment customization)
    • 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

  • Validation Infrastructure: Validation integrated into bundle config unmarshaling via config.UnmarshalConfig()

  • 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: Documentation

CopilotAI review requested due to automatic review settings January 20, 2026 19:51
@netlify

netlifyBot commented Jan 20, 2026

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

NameLink
🔨 Latest commitd5b6bc6
🔍 Latest deploy loghttps://app.netlify.com/projects/olmv1/deploys/697a3bd3e510050008cef5c7
😎 Deploy Previewhttps://deploy-preview-2454--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@anik120
anik120 requested review from tmshort and removed request for CopilotJanuary 20, 2026 19:52
@anik120
anik120 requested review from joelanford and perdasilva and removed request for camilamacedo86 and thetechnickJanuary 20, 2026 19:52
@anik120
anik120force-pushed the deploymentconfig-json-schema branch from 1367534 to 2cd3619CompareJanuary 20, 2026 20:05
CopilotAI review requested due to automatic review settings January 20, 2026 20:05

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements Phase 1 of the DeploymentConfig feature to achieve feature parity with OLMv0's SubscriptionConfig for registry+v1 bundles. It adds automated JSON schema generation and validation infrastructure for the deploymentConfig field in ClusterExtension.

Changes:

  • Added reflection-based schema generator tool that introspects v1alpha1.SubscriptionConfig from the operator-framework/api package
  • Implemented embedded JSON schema validation infrastructure with comprehensive test coverage
  • Integrated deploymentConfig schema into bundle config validation with make target for regeneration

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
hack/tools/schema-generator/main.goImplements reflection-based generator that introspects Go types and parses AST to extract documentation, handling nested k8s types and inline fields
hack/tools/schema-generator/main_test.goComprehensive test suite validating schema structure, selector field exclusion, and comparing generated vs committed schemas
internal/operator-controller/rukpak/bundle/schema/validator.goValidation infrastructure with embedded schema compilation and multi-format input support (JSON bytes, strings, structs)
internal/operator-controller/rukpak/bundle/schema/validator_test.goTest coverage for valid and invalid deployment configurations including edge cases
internal/operator-controller/rukpak/bundle/schema/deploymentconfig.jsonGenerated JSON Schema Draft 7 document (1862 lines) defining all SubscriptionConfig fields except selector
internal/operator-controller/rukpak/bundle/schema/README.mdDocumentation explaining schema purpose, included/excluded fields, and regeneration workflow
internal/operator-controller/rukpak/bundle/registryv1.goIntegration of deploymentConfig schema into bundle config validation
internal/operator-controller/config/config.goAdded GetDeploymentConfig accessor method with nil handling
hack/tools/update-deploymentconfig-schema.shShell script for regenerating schema from vendor dependencies
MakefileAdded update-deploymentconfig-schema make target

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadinternal/operator-controller/rukpak/bundle/registryv1.go Outdated
Comment threadinternal/operator-controller/rukpak/bundle/schema/validator_test.go Outdated
@anik120
anik120force-pushed the deploymentconfig-json-schema branch from 2cd3619 to 56d10e2CompareJanuary 20, 2026 20:26
CopilotAI review requested due to automatic review settings January 20, 2026 20:30
@anik120
anik120force-pushed the deploymentconfig-json-schema branch from 56d10e2 to fce993aCompareJanuary 20, 2026 20:30
@anik120
anik120force-pushed the deploymentconfig-json-schema branch 2 times, most recently from cd32996 to 5bfc310CompareJanuary 20, 2026 20:37

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

// Write to file
if err := os.WriteFile(outputFile, data, 0600); err != nil {

CopilotAIJan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file permission 0600 makes the generated schema file read/write for owner only. Since this is a JSON schema file that needs to be committed to the repository and read by the build process, it should use more permissive permissions like 0644 (readable by all, writable by owner).

Suggested change
iferr:=os.WriteFile(outputFile, data, 0600); err!=nil {
iferr:=os.WriteFile(outputFile, data, 0644); err!=nil {

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0644 is what I started out with, but the linter fails with

hack/tools/schema-generator/main.go:106:12 gosec G306: Expect WriteFile permissions to be 0600 or less

But if I change this to 0600, Copilot says it should be 0644.

The machines are fighting with each other, and I'm caught in between.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 644 and add a //nolint:gosec comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's only one user in the pod. There's no need to give group and other users access. 0600 has been used in many other places.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's start off with 0600 and see if more is required in that case then

Comment threadinternal/operator-controller/config/config.go
Comment threadinternal/operator-controller/rukpak/bundle/schema/validator_test.go Outdated
Comment threadinternal/operator-controller/rukpak/bundle/registryv1.go Outdated
@anik120
anik120force-pushed the deploymentconfig-json-schema branch from 5bfc310 to 64e7f6bCompareJanuary 20, 2026 20:47
CopilotAI review requested due to automatic review settings January 20, 2026 21:01
@anik120
anik120force-pushed the deploymentconfig-json-schema branch from 64e7f6b to 6b8cb00CompareJanuary 20, 2026 21:01

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadhack/tools/update-registryv1-bundle-schema.sh Outdated
Comment threadhack/tools/schema-generator/main.go Outdated
Comment threadinternal/operator-controller/rukpak/bundle/schema/README.md Outdated
@codecov

codecovBot commented Jan 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.16733% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.52%. Comparing base (8167ff8) to head (d5b6bc6).
⚠️ Report is 11 commits behind head on main.

Files with missing linesPatch %Lines
hack/tools/schema-generator/main.go58.97%72 Missing and 8 partials ⚠️
...al/operator-controller/rukpak/bundle/registryv1.go50.00%15 Missing and 4 partials ⚠️
internal/operator-controller/config/config.go66.66%3 Missing and 3 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2454 +/- ##
==========================================
+ Coverage 69.49% 69.52% +0.03% 
==========================================
Files 101 102 +1 Lines 7754 8231 +477 ==========================================
+ Hits 5389 5723 +334 - Misses 1930 2056 +126 - Partials 435 452 +17 
FlagCoverage Δ
e2e46.64% <33.92%> (+0.53%)⬆️
experimental-e2e13.43% <0.00%> (-0.03%)⬇️
unit57.55% <51.79%> (+0.36%)⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@perdasilva

perdasilva commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

@anik120 have you considered approaching this by having the schema-generator generate the base registry+v1 bundle configuration schema including watchNamespace? Then the process of generating the final schema for a bundle could be:
deserialize the base schema, update it based on the bundle install mode configuration, then return that (or validate the configuration against that). This way we don't need to tie things down so closely to the deployment config.

Also, you could delete the deploymentConfig from the schema if the featuregate isn't enabled...

Comment threadMakefile Outdated
env JQ=$(GOJQ) hack/tools/update-tls-profiles.sh

.PHONY: update-deploymentconfig-schema
update-deploymentconfig-schema: #EXHELP Update DeploymentConfig JSON schema by introspecting v1alpha1.SubscriptionConfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call it something like update-bundle-config-schema or somehow relate the naming of things back to bundle configuration? It might make it easier to understand if you're coming in fresh?

same with hack/tools/schema-generator

@tmshort

Copy link
Copy Markdown
Contributor

/approve

@openshift-ciopenshift-ciBot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2026
@@ -0,0 +1,25 @@
package schema

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move all of this into registryv1.go, move the README.md to rukpak/bundle and remove the schema package. Just to keep it tight. Then I think we're good 🎉

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

…le 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**: Parses SubscriptionConfig using AST to extract field names/types
- Fetches Kubernetes OpenAPI v3 specs from GitHub releases
- Maps fields to official Kubernetes schemas
- Generates schema with `watchNamespace` (for operator scope) and `deploymentConfig` (for deployment customization)
- 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
- **Validation Infrastructure**: Validation integrated into bundle config unmarshaling via `config.UnmarshalConfig()`
- **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: Documentation
CopilotAI review requested due to automatic review settings January 28, 2026 16:39
@anik120
anik120force-pushed the deploymentconfig-json-schema branch from 26cc593 to d5b6bc6CompareJanuary 28, 2026 16:39

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadhack/tools/schema-generator/main.go
@perdasilvaperdasilva removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2026
@perdasilva

Copy link
Copy Markdown
Contributor

/approve

@openshift-ciopenshift-ciBot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2026
@perdasilva

Copy link
Copy Markdown
Contributor

I missed that Todd had already approved and removed what I thought was an approve =/ adding the lgtm them

/lgtm

@openshift-ciopenshift-ciBot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2026

@rashmigottipatirashmigottipati left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@openshift-ci

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: perdasilva, rashmigottipati, tmshort

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@anik120
anik120 merged commit 12923b9 into operator-framework:mainJan 28, 2026
33 of 35 checks passed
anik120 added a commit to anik120/operator-controller that referenced this pull request Jan 29, 2026
This PR implements **Phase 2** of the [Deployment Configuration RFC](https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0):
extending the OLMv1 bundle renderer to apply `DeploymentConfig` customizations to operator deployments.
Building on the foundation from operator-framework#2454, this PR enables the renderer to
accept and apply deployment configuration when rendering registry+v1 bundles.
The implementation follows OLMv0's behavior patterns to ensure compatibility and correctness.
The next PR will wire up the config in the `ClusterExtension` controller by parsing `spec.install.config`
to convert to `DeploymentConfig` and thread `DeploymentConfig` through the controller's render call chain
anik120 added a commit to anik120/operator-controller that referenced this pull request Jan 29, 2026
This PR implements **Phase 2** of the [Deployment Configuration RFC](https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0):
extending the OLMv1 bundle renderer to apply `DeploymentConfig` customizations to operator deployments.
Building on the foundation from operator-framework#2454, this PR enables the renderer to
accept and apply deployment configuration when rendering registry+v1 bundles.
The implementation follows OLMv0's behavior patterns to ensure compatibility and correctness.
The next PR will wire up the config in the `ClusterExtension` controller by parsing `spec.install.config`
to convert to `DeploymentConfig` and thread `DeploymentConfig` through the controller's render call chain
anik120 added a commit to anik120/operator-controller that referenced this pull request Feb 2, 2026
This PR implements **Phase 2** of the [Deployment Configuration RFC](https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0):
extending the OLMv1 bundle renderer to apply `DeploymentConfig` customizations to operator deployments.
Building on the foundation from operator-framework#2454, this PR enables the renderer to
accept and apply deployment configuration when rendering registry+v1 bundles.
The implementation follows OLMv0's behavior patterns to ensure compatibility and correctness.
The next PR will wire up the config in the `ClusterExtension` controller by parsing `spec.install.config`
to convert to `DeploymentConfig` and thread `DeploymentConfig` through the controller's render call chain
anik120 added a commit to anik120/operator-controller that referenced this pull request Feb 2, 2026
This PR implements **Phase 2** of the [Deployment Configuration RFC](https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0):
extending the OLMv1 bundle renderer to apply `DeploymentConfig` customizations to operator deployments.
Building on the foundation from operator-framework#2454, this PR enables the renderer to
accept and apply deployment configuration when rendering registry+v1 bundles.
The implementation follows OLMv0's behavior patterns to ensure compatibility and correctness.
The next PR will wire up the config in the `ClusterExtension` controller by parsing `spec.install.config`
to convert to `DeploymentConfig` and thread `DeploymentConfig` through the controller's render call chain
anik120 added a commit to anik120/operator-controller that referenced this pull request Feb 2, 2026
This PR implements **Phase 2** of the [Deployment Configuration RFC](https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0):
extending the OLMv1 bundle renderer to apply `DeploymentConfig` customizations to operator deployments.
Building on the foundation from operator-framework#2454, this PR enables the renderer to
accept and apply deployment configuration when rendering registry+v1 bundles.
The implementation follows OLMv0's behavior patterns to ensure compatibility and correctness.
The next PR will wire up the config in the `ClusterExtension` controller by parsing `spec.install.config`
to convert to `DeploymentConfig` and thread `DeploymentConfig` through the controller's render call chain
anik120 added a commit to anik120/operator-controller that referenced this pull request Feb 2, 2026
This PR implements **Phase 2** of the [Deployment Configuration RFC](https://docs.google.com/document/d/18O4qBvu5I4WIJgo5KU1opyUKcrfgk64xsI3tyXxmVEU/edit?tab=t.0):
extending the OLMv1 bundle renderer to apply `DeploymentConfig` customizations to operator deployments.
Building on the foundation from operator-framework#2454, this PR enables the renderer to
accept and apply deployment configuration when rendering registry+v1 bundles.
The implementation follows OLMv0's behavior patterns to ensure compatibility and correctness.
The next PR will wire up the config in the `ClusterExtension` controller by parsing `spec.install.config`
to convert to `DeploymentConfig` and thread `DeploymentConfig` through the controller's render call chain
@anik120anik120 mentioned this pull request Mar 2, 2026
4 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by an approver from all required OWNERS files.crd-diff-overridelgtmIndicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@anik120@perdasilva@tmshort@joelanford@rashmigottipati@camilamacedo86