Skip to content

Add OpenAPIModelName() generation for v1alpha1 and lib/version types#477

Open
tmshort wants to merge 1 commit intooperator-framework:masterfrom
tmshort:add-openapi-model-names
Open

Add OpenAPIModelName() generation for v1alpha1 and lib/version types#477
tmshort wants to merge 1 commit intooperator-framework:masterfrom
tmshort:add-openapi-model-names

Conversation

@tmshort
Copy link
Contributor

@tmshort tmshort commented Feb 13, 2026

Use openapi-gen from k8s.io/kube-openapi to generate OpenAPIModelName() accessor functions and OpenAPI schema definitions.

  • Add openapi-gen to bingo
  • Add +k8s:openapi-gen and +k8s:openapi-model-package markers to pkg/operators/v1alpha1 and pkg/lib/version.
  • Add a generate-openapi Makefile target.
  • Remove broken empty +patchMergeKey tag from SubscriptionStatus.CatalogHealth that blocked generation.

The api_violations.report is a file created by openapi-gen, and it's required if we don't want to error out without fixing the violations. Because it's checked in, we can use it as part of the verify CI/review process to ensure nothing new is added.

Alternative to #476, which had in its description:

Description of the change:

This PR adds OpenAPIModelName() methods to all types in the operator-framework/api package that are referenced in OpenAPI schema definitions.
When Kubernetes serves OpenAPI schemas, the "/" character in type references gets URL-encoded to "~1". If the schema definition keys use the raw Go import path format (e.g., github.com/operator-framework/api/...) but references are URL-encoded (e.g., github.com~1operator-framework~1api~1...), lookups fail with errors like:

  error getting OpenAPISchema: SchemaError(...CSVDescription.apiservicedefinitions):
    unknown model in reference: "github.com~1operator framework~1api~1pkg~1operators~1v1alpha1.APIServiceDefinitions"

Adding OpenAPIModelName() makes openapi-gen use the canonical com.github... format for both definition keys and references, ensuring they match.

Motivation for the change:

This is a prerequisite fix for https://issues.redhat.com/browse/OCPBUGS-76460

PR operator-framework/operator-lifecycle-manager#3765 added OpenAPIModelName() for types defined in the OLM package-server, but operators like Hive still fail because CSVDescription references types from this package (operator-framework/api) that don't have the method.

Assisted-By: Claude

@openshift-ci openshift-ci bot requested review from anik120 and grokspawn February 13, 2026 19:37
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

❌ Patch coverage is 0% with 116 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.00%. Comparing base (1b5c3ea) to head (ec1a893).

Files with missing lines Patch % Lines
pkg/operators/v1alpha1/zz_generated.model_name.go 0.00% 114 Missing ⚠️
pkg/lib/version/zz_generated.model_name.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #477       +/-   ##
===========================================
- Coverage   37.86%   22.00%   -15.87%     
===========================================
  Files          57       60        +3     
  Lines        4563     7853     +3290     
===========================================
  Hits         1728     1728               
- Misses       2678     5968     +3290     
  Partials      157      157               

☔ 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.

@@ -0,0 +1,5 @@
// +k8s:openapi-gen=true
// +k8s:openapi-model-package=com.coreos.operators.lib.version
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should confirm what this name should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jianzhangbjz you had:
com.github.operator-framework.api.pkg.operators.lib.version

// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators
// +k8s:openapi-gen=true
// +k8s:openapi-model-package=com.coreos.operators.v1alpha1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should confirm what this name should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jianzhangbjz you had:
com.github.operator-framework.api.pkg.operators.v1alpha1

@perdasilva
Copy link
Contributor

/lgtm

In principle it seems fine. It would be good to get more on the motivation for this change in the PR description. Maybe some better formatting in the description (maybe bullet points) would be good too =D

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2026
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2026
@tmshort
Copy link
Contributor Author

tmshort commented Feb 17, 2026

In principle it seems fine. It would be good to get more on the motivation for this change in the PR description. Maybe some better formatting in the description (maybe bullet points) would be good too =D

It's an alternative to #476

Use openapi-gen from k8s.io/kube-openapi to generate OpenAPIModelName()
accessor functions and OpenAPI schema definitions.

* Add openapi-gen to bingo.
* add +k8s:openapi-gen and +k8s:openapi-model-package markers to pkg/operators/v1alpha1 and pkg/lib/version.
* Add a generate-openapi Makefile target.
* Remove broken empty +patchMergeKey tag from SubscriptionStatus.CatalogHealth that blocked generation.

Signed-off-by: Todd Short <todd.short@me.com>
Assisted-By: Claude
@tmshort tmshort force-pushed the add-openapi-model-names branch from 5456d2a to ec1a893 Compare February 17, 2026 19:01
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 17, 2026
@openshift-ci
Copy link

openshift-ci bot commented Feb 17, 2026

New changes are detected. LGTM label has been removed.

@openshift-ci
Copy link

openshift-ci bot commented Feb 17, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from perdasilva. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments