bundle version increased type safety / serialization support#1938
bundle version increased type safety / serialization support#1938grokspawn wants to merge 3 commits intooperator-framework:masterfrom
Conversation
Signed-off-by: grokspawn <jordan@nimblewidget.com>
|
Skipping CI for Draft Pull Request. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1938 +/- ##
==========================================
+ Coverage 57.50% 57.74% +0.24%
==========================================
Files 139 139
Lines 13339 13382 +43
==========================================
+ Hits 7671 7728 +57
+ Misses 4486 4468 -18
- Partials 1182 1186 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: grokspawn <jordan@nimblewidget.com>
9df00dd to
6121538
Compare
alpha/declcfg/declcfg.go
Outdated
|
|
||
| // Validate against CRD constraint from operators.coreos.com/v1alpha1 ClusterServiceVersion | ||
| // Maximum length of 20 characters | ||
| if len(relStr) > 20 { |
There was a problem hiding this comment.
Is there a value we can get that isn't a magic number?
There was a problem hiding this comment.
There isn't one defined presently, but I'm happy to define a constant here for it. The reference is in the type here, but we're deliberately not using that type in this repo (to de-couple v0 & v1 uses), so we just need to be consistent.
|
/approve |
Signed-off-by: grokspawn <jordan@nimblewidget.com>
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| SchemaChannel = "olm.channel" | ||
| SchemaBundle = "olm.bundle" | ||
| SchemaDeprecation = "olm.deprecations" | ||
| VersionReleaseMaxLength = 20 |
There was a problem hiding this comment.
Does this need to be exported? Do we expect callers to need to know it, or is it an internal detail of a validation that happens somewhere?
| b := semver.Version{Pre: other} | ||
| return a.Compare(b) | ||
| } | ||
|
|
There was a problem hiding this comment.
I think you'll want a String() method on the Release type. I know @pedjak had added one in his operator-controller PR when we were thinking it would include the release plumbing.
| r, err = semver.Parse(fmt.Sprintf("0.0.0-%s", props.Packages[0].Release)) | ||
| r, err = NewRelease(props.Packages[0].Release) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("error parsing bundle %q release version %q: %v", b.Name, props.Packages[0].Release, err) |
There was a problem hiding this comment.
| return nil, fmt.Errorf("error parsing bundle %q release version %q: %v", b.Name, props.Packages[0].Release, err) | |
| return nil, fmt.Errorf("error parsing bundle %q release %q: %v", b.Name, props.Packages[0].Release, err) |
| Version semver.Version `json:"version"` | ||
| Release Release `json:"release,omitempty"` |
There was a problem hiding this comment.
Do we have specific needs around JSON marshaling/unmarshaling yet?
A few questions come to mind:
- Should we not omit an empty release, so that an empty release is still explicitly marshalled?
- Should the CompositeVersion be marshalled/unmarshalled as to/from an JSON string instead of a JSON object?
There was a problem hiding this comment.
For organizational purposes, WDYT about separate files:
- compositeversion.go
- compositeversion_test.go
It seems a little odd for this to be the only contents of a file calleddeclcfg_test.go
| return r, nil | ||
| } | ||
|
|
||
| type CompositeVersion struct { |
There was a problem hiding this comment.
Naming is the hardest thing in CompSci right? So here goes:
Should this be VersionRelease? My pitch is:
- RPM uses NVR to abbreviate their name/version/release tuple. I could very easily see us defining an actual
NameVersionReleasetype that includes the package name. - Kubernetes has
GroupVersion,GroupKind, andGroupVersionKind, which are structs that represent the respective combos of group, version, and kind.
Description of the change:
This is a deliberate re-scoping of the CompositeVersion type to co-locate all the bits of dependency on use of the underlying blang semver PRVersion slice, by making this an explicit type.
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.
api-diff is intended to fail here, and will need to be overridden (since we are un-exporting the fields to make this an opaque type).
Motivation for the change:
Reviewer Checklist
/docs