Skip to content

⚠️ updates from api audit - #1404

Merged
everettraven merged 3 commits into
operator-framework:mainfrom
grokspawn:api-audit-updates
Nov 8, 2024
Merged

⚠️ updates from api audit#1404
everettraven merged 3 commits into
operator-framework:mainfrom
grokspawn:api-audit-updates

Conversation

@grokspawn

@grokspawngrokspawn commented Oct 22, 2024

Copy link
Copy Markdown
Contributor

This is API changes in preparation for our v1.0 release, mostly from the openshift API team's audit but also from feedback from the maintainers and community.

It is expected that this PR contains breaking changes as we prepare (tightening types, enhancing docs, etc.) for the release.

Description

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@grokspawn
grokspawn requested a review from a team as a code ownerOctober 22, 2024 19:12
@openshift-ciopenshift-ciBot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 22, 2024
@netlify

netlifyBot commented Oct 22, 2024

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

NameLink
🔨 Latest commit1620b73
🔍 Latest deploy loghttps://app.netlify.com/sites/olmv1/deploys/672e88cdbf71a5000878c4c3
😎 Deploy Previewhttps://deploy-preview-1404--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 site configuration.

@codecov

codecovBot commented Oct 22, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 71.79487% with 11 lines in your changes missing coverage. Please review.

Project coverage is 74.88%. Comparing base (ce86a65) to head (1620b73).
Report is 2 commits behind head on main.

Files with missing linesPatch %Lines
internal/applier/helm.go35.29%9 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #1404 +/- ##
==========================================
- Coverage 75.18% 74.88% -0.31% 
==========================================
Files 42 42 Lines 3236 3237 +1 ==========================================
- Hits 2433 2424 -9 - Misses 632 640 +8 - Partials 171 173 +2 
FlagCoverage Δ
e2e51.93% <64.10%> (-0.36%)⬇️
unit57.24% <30.76%> (-0.42%)⬇️

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.

Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadconfig/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml Outdated
//
//+kubebuilder:validation:MaxLength:=64
//+kubebuilder:validation:Pattern=`^(\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|[x|X|\*])(\.(0|[1-9]\d*|x|X|\*]))?(\.(0|[1-9]\d*|x|X|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+|,\s*|\s*\|\|\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|x|X|\*])(\.(0|[1-9]\d*|x|X|\*))?(\.(0|[1-9]\d*|x|X|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$`
//+kubebuilder:validation.XValidation:rule="self.matches(r'^(\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|[x|X|\*])(\.(0|[1-9]\d*|x|X|\*]))?(\.(0|[1-9]\d*|x|X|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+|,\s*|\s*\|\|\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|x|X|\*])(\.(0|[1-9]\d*|x|X|\*))?(\.(0|[1-9]\d*|x|X|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$')"", message="invalid version expression in the catalog source"

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.

Is the error message correct here?

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.

We don't need to say "in the catalog source" because the error emitted by the validator includes the parent path leading up to this field.

Suggested change
//+kubebuilder:validation.XValidation:rule="self.matches(r'^(\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|[x|X|\*])(\.(0|[1-9]\d*|x|X|\*]))?(\.(0|[1-9]\d*|x|X|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+|,\s*|\s*\|\|\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|x|X|\*])(\.(0|[1-9]\d*|x|X|\*))?(\.(0|[1-9]\d*|x|X|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$')"", message="invalid version expression in the catalog source"
//+kubebuilder:validation.XValidation:rule="self.matches(r'^(\s*(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|[x|X|\*])(\.(0|[1-9]\d*|x|X|\*]))?(\.(0|[1-9]\d*|x|X|\*))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)((?:\s+|,\s*|\s*\|\|\s*)(=||!=|>|<|>=|=>|<=|=<|~|~>|\^)\s*(v?(0|[1-9]\d*|x|X|\*])(\.(0|[1-9]\d*|x|X|\*))?(\.(0|[1-9]\d*|x|X|\*]))?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?)\s*)*$')"", message="invalid version expression"

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.

The error message here definitely seems a bit vague to me. Could we update the message to also include some helpful information for crafting a valid version expression?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadinternal/applier/helm.go Outdated
func shouldSkipPreflight(preflight Preflight, ctx context.Context, ext *ocv1alpha1.ClusterExtension, state string) bool {
l := log.FromContext(ctx)
if ext.Spec.Install.Preflight != nil && ext.Spec.Install.Preflight.CRDUpgradeSafety != nil {
if _, ok := preflight.(*crdupgradesafety.Preflight); ok {

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.

Maybe move this line out to the calling function, probably a more appropriate place for it, and might solve the linter concern around nested blocks.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I resolved this by externalizing the conditions somewhat, but still putting all the 'CRDUpgradeSafety' checks in one place.
My assertion is still that this kind of thing should be exposed via an interface.

Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go
@grokspawn
grokspawnforce-pushed the api-audit-updates branch 6 times, most recently from f04b254 to 237bcf6CompareNovember 7, 2024 19:54
@openshift-merge-robotopenshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2024
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go Outdated
Comment threadapi/v1alpha1/clusterextension_types.go
Comment threadinternal/applier/helm.go Outdated
Signed-off-by: Jordan Keister <jordan@nimblewidget.com>
LalatenduMohanty
LalatenduMohanty previously approved these changes Nov 8, 2024

@LalatenduMohantyLalatenduMohanty 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.

/lgtm

Signed-off-by: Jordan Keister <jordan@nimblewidget.com>
@openshift-ci

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@openshift-ciopenshift-ciBot removed the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2024
@everettraven
everettraven added this pull request to the merge queue Nov 8, 2024
Merged via the queue into operator-framework:main with commit 6c2be08Nov 8, 2024
@grokspawn
grokspawn deleted the api-audit-updates branch November 8, 2024 22:13
@grokspawn

Copy link
Copy Markdown
ContributorAuthor

Solves #1426

Sign up for freeto 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.

6 participants

@grokspawn@joelanford@perdasilva@LalatenduMohanty@everettraven@openshift-merge-robot