Skip to content

OPRUN-4548: bundle version increased type safety / serialization support#1938

Open
grokspawn wants to merge 4 commits intooperator-framework:masterfrom
grokspawn:release-types-play
Open

OPRUN-4548: bundle version increased type safety / serialization support#1938
grokspawn wants to merge 4 commits intooperator-framework:masterfrom
grokspawn:release-types-play

Conversation

@grokspawn
Copy link
Copy Markdown
Contributor

@grokspawn grokspawn commented Mar 23, 2026

Description of the change:
This is a types consolidation between op-reg CompositeVersion and op-con VersionRelease.

api-diff is expected to fail here, and will need to be overridden (since we are un-exporting the fields to make this an opaque type).

There will be an additional PR to more widely adopt the types internally.

Motivation for the change:
Improved safety by declaring a distinct Release type instead of implicitly using blang semver.Version (so this becomes an implementation detail and could be replaced with any type which behaved identically). The original implementation was evaluating the tradeoffs between re-use of the semver.Parse method versus re-implementing just the semver.org pre-release version info for validation.

In order to encourage use of the types as first-class fields in APIs, the types support serialization as JSON objects.
One-way stringification is provided for the VersionRelease type in a manner suitable for use as a metadata.Name in kubernetes.
Round-trip stringification is provided for the Release type.

In order to provide identical type access from outside and inside the system, the types are implemented in the model package (considered an internal package) and re-exported via the declcfg package (which is the intended interface point for external clients).

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 23, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 23, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 68.42105% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.76%. Comparing base (21f9b55) to head (0b737df).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
alpha/declcfg/declcfg.go 50.00% 11 Missing and 5 partials ⚠️
alpha/model/versionrelease.go 75.43% 10 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1938      +/-   ##
==========================================
+ Coverage   57.68%   57.76%   +0.07%     
==========================================
  Files         139      140       +1     
  Lines       13363    13426      +63     
==========================================
+ Hits         7708     7755      +47     
- Misses       4468     4481      +13     
- Partials     1187     1190       +3     

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

@grokspawn grokspawn marked this pull request as ready for review March 23, 2026 20:56
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 23, 2026
@openshift-ci openshift-ci bot requested review from anik120 and pedjak March 23, 2026 20:56
@grokspawn grokspawn force-pushed the release-types-play branch from 9df00dd to 6121538 Compare March 24, 2026 21:14
@grokspawn grokspawn changed the title ensure that new types minimize internal access and maximize safeness bundle version increased type safety / serialization support Mar 25, 2026
@tmshort
Copy link
Copy Markdown
Contributor

tmshort commented Mar 26, 2026

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2026
@tmshort
Copy link
Copy Markdown
Contributor

tmshort commented Mar 26, 2026

/approve
Still approve after change

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 26, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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

@grokspawn grokspawn force-pushed the release-types-play branch 2 times, most recently from 9b9301c to 2d1b03e Compare March 27, 2026 20:49
@grokspawn grokspawn removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 27, 2026
@grokspawn
Copy link
Copy Markdown
Contributor Author

I removed the approval label because there was some fundamental change in this PR and I'd appreciate a re-review, please!

@grokspawn grokspawn requested review from joelanford and tmshort March 27, 2026 21:06
Signed-off-by: grokspawn <jordan@nimblewidget.com>
Signed-off-by: grokspawn <jordan@nimblewidget.com>
Signed-off-by: grokspawn <jordan@nimblewidget.com>
@grokspawn grokspawn force-pushed the release-types-play branch from 2d1b03e to e4cc4a8 Compare March 30, 2026 14:23
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 30, 2026
@grokspawn
Copy link
Copy Markdown
Contributor Author

rebased the pr to keep it current

@grokspawn grokspawn force-pushed the release-types-play branch 4 times, most recently from a64a59a to b94ee9e Compare March 31, 2026 19:59
@grokspawn grokspawn requested review from Copilot and joelanford April 3, 2026 15:59
Copy link
Copy Markdown

Copilot AI left a comment

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 consolidates bundle version/release handling by introducing a dedicated VersionRelease / Release type in alpha/model and switching template and declcfg logic from the previous composite-version approach to the new API, with added JSON serialization support.

Changes:

  • Add model.VersionRelease and model.Release with comparison, parsing, and Kubernetes-safe stringification helpers.
  • Replace CompositeVersion() usage with VersionRelease() in declcfg bundle ordering and substitutes template validation.
  • Update conversion/tests to use the new release parsing and updated error messages.

Reviewed changes

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

Show a summary per file
File Description
alpha/template/substitutes/substitutes.go Switch substitution validation to compare bundles via VersionRelease(); tweak substitution error formatting.
alpha/template/substitutes/substitutes_test.go Update expected error text for missing version property scenario.
alpha/model/versionrelease.go Introduce Release + VersionRelease types with parsing/comparison and JSON tags.
alpha/model/versionrelease_test.go Add unit tests for JSON (un)marshal, round-trip, and NewRelease validation.
alpha/declcfg/declcfg.go Re-export version types from model; replace CompositeVersion with VersionRelease() logic and legacy build-metadata conversion.
alpha/declcfg/declcfg_to_model.go Switch release parsing to model.NewRelease and adapt internal assignment.
alpha/declcfg/declcfg_to_model_test.go Update expected error message for invalid release parsing.

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

@grokspawn grokspawn force-pushed the release-types-play branch from b94ee9e to 166b065 Compare April 3, 2026 20:06
Copilot AI review requested due to automatic review settings April 3, 2026 20:25
@grokspawn grokspawn force-pushed the release-types-play branch from 166b065 to 32b7d9b Compare April 3, 2026 20:25
@grokspawn grokspawn force-pushed the release-types-play branch from 32b7d9b to e900d30 Compare April 3, 2026 20:29
Copy link
Copy Markdown

Copilot AI left a comment

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 7 out of 7 changed files in this pull request and generated 6 comments.


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

VersionRelease = model.VersionRelease
)

var NewRelease = model.NewRelease
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

NewRelease is exported as a mutable var function value, which allows external packages to reassign it (e.g. declcfg.NewRelease = ...) and change declcfg behavior globally. This is a surprising and unsafe API surface; prefer exporting a real wrapper function (e.g. func NewRelease(string) (Release, error)) so callers can’t mutate package behavior.

Suggested change
var NewRelease = model.NewRelease
func NewRelease(version string) (Release, error) {
return model.NewRelease(version)
}

Copilot uses AI. Check for mistakes.
Signed-off-by: grokspawn <jordan@nimblewidget.com>
@grokspawn grokspawn force-pushed the release-types-play branch from e900d30 to 0b737df Compare April 3, 2026 20:55
@grokspawn grokspawn changed the title bundle version increased type safety / serialization support OPRUN-4548: bundle version increased type safety / serialization support Apr 6, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 6, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@grokspawn: This pull request references OPRUN-4548 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Description of the change:
This is a types consolidation between op-reg CompositeVersion and op-con VersionRelease.

api-diff is expected to fail here, and will need to be overridden (since we are un-exporting the fields to make this an opaque type).

There will be an additional PR to more widely adopt the types internally.

Motivation for the change:
Improved safety by declaring a distinct Release type instead of implicitly using blang semver.Version (so this becomes an implementation detail and could be replaced with any type which behaved identically). The original implementation was evaluating the tradeoffs between re-use of the semver.Parse method versus re-implementing just the semver.org pre-release version info for validation.

In order to encourage use of the types as first-class fields in APIs, the types support serialization as JSON objects.
One-way stringification is provided for the VersionRelease type in a manner suitable for use as a metadata.Name in kubernetes.
Round-trip stringification is provided for the Release type.

In order to provide identical type access from outside and inside the system, the types are implemented in the model package (considered an internal package) and re-exported via the declcfg package (which is the intended interface point for external clients).

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. go-apidiff-override jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants