Skip to content

Commit bd67bb4

Browse files
committed
updates
Signed-off-by: grokspawn <jordan@nimblewidget.com>
1 parent cdde802 commit bd67bb4

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed

alpha/model/model.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,33 +341,32 @@ func (b *Bundle) VersionString() string {
341341

342342
func (b *Bundle) normalizeName() string {
343343
// if the bundle has release versioning, then the name must include this in standard form:
344-
// <package-name>-<version>-<release label>-<release version>
344+
// <package-name>-v<version>-<release label>-<release version>
345345
// if no release versioning exists, then just return the bundle name
346346
if b.Release.Label != "" || (b.Release.Version.Major != 0 || b.Release.Version.Minor != 0 || b.Release.Version.Patch != 0) {
347-
return strings.Join([]string{b.Package.Name, b.Version.String(), b.Release.String()}, "-")
347+
return strings.Join([]string{b.Package.Name, "v" + b.Version.String(), b.Release.String()}, "-")
348348
} else {
349349
return b.Name
350350
}
351351
}
352352

353-
// order by release, if present
354-
// - label first, if present;
355-
// - then version, if present;
356-
//
357-
// then version
353+
// order by version, then
354+
// release, if present
355+
// - label first, if present
356+
// - then version, if present
358357
func (b *Bundle) Compare(other *Bundle) int {
359358
if b.Name == other.Name {
360359
return 0
361360
}
361+
if b.Version.NE(other.Version) {
362+
return b.Version.Compare(other.Version)
363+
}
362364
if b.Release.Label != other.Release.Label {
363365
return strings.Compare(b.Release.Label, other.Release.Label)
364366
}
365367
if b.Release.Version.NE(other.Release.Version) {
366368
return b.Release.Version.Compare(other.Release.Version)
367369
}
368-
if b.Version.NE(other.Version) {
369-
return b.Version.Compare(other.Version)
370-
}
371370
return 0
372371
}
373372

alpha/model/model_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,41 @@ func TestValidators(t *testing.T) {
280280
},
281281
assertion: hasError(`duplicate versions found in bundles: [{0.0.1: [anakin.v0.0.1, anakin.v0.0.2]} {1.0.1: [anakin.v1.0.1, anakin.v1.0.2]}]`),
282282
},
283+
{
284+
name: "Package/Error/DuplicateBundleVersionsReleases",
285+
v: &Package{
286+
Name: "anakin",
287+
Channels: map[string]*Channel{
288+
"light": {
289+
Package: pkg,
290+
Name: "light",
291+
Bundles: map[string]*Bundle{
292+
"anakin.v0.0.1": {Name: "anakin.v0.0.1", Version: semver.MustParse("0.0.1")},
293+
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Version: semver.MustParse("0.0.1")},
294+
"anakin-v0.0.1-alpha-0.0.1": {Name: "anakin.v0.0.1", Version: semver.MustParse("0.0.1"), Release: property.Release{Label: "alpha", Version: semver.MustParse("0.0.1")}, Package: pkg},
295+
"anakin-v0.0.2-alpha-0.0.1": {Name: "anakin.v0.0.2", Version: semver.MustParse("0.0.1"), Release: property.Release{Label: "alpha", Version: semver.MustParse("0.0.1")}, Package: pkg},
296+
},
297+
},
298+
},
299+
},
300+
assertion: hasError(`duplicate versions found in bundles: [{0.0.1: [anakin.v0.0.1, anakin.v0.0.2]} {0.0.1-alpha-0.0.1: [anakin.v0.0.1, anakin.v0.0.2]}]`),
301+
},
302+
{
303+
name: "Package/Error/BundleReleaseNormalizedName",
304+
v: &Package{
305+
Name: "anakin",
306+
Channels: map[string]*Channel{
307+
"light": {
308+
Package: pkg,
309+
Name: "light",
310+
Bundles: map[string]*Bundle{
311+
"anakin.v0.0.1.alpha.0.0.1": {Name: "anakin.v0.0.1.alpha.0.0.1", Version: semver.MustParse("0.0.1"), Release: property.Release{Label: "alpha", Version: semver.MustParse("0.0.1")}, Package: pkg},
312+
},
313+
},
314+
},
315+
},
316+
assertion: hasError(`name "anakin.v0.0.1.alpha.0.0.1" does not match normalized name "anakin-v0.0.1-alpha-0.0.1"`),
317+
},
283318
{
284319
name: "Package/Error/NoDefaultChannel",
285320
v: &Package{

alpha/property/property.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"reflect"
99
"strings"
1010

11+
"github.com/blang/semver/v4"
1112
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1213

13-
"github.com/blang/semver/v4"
1414
"github.com/operator-framework/api/pkg/operators/v1alpha1"
1515
)
1616

alpha/template/substitutes/substitutes.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@ type Template struct {
1515
RenderBundle func(context.Context, string) (*declcfg.DeclarativeConfig, error)
1616
}
1717

18-
type SubstitutesTemplate struct {
19-
Schema string `json:"schema"`
20-
Entries []*declcfg.Meta `json:"entries"`
21-
Substitutes []string `json:"substitutes"`
18+
type Substitute struct {
19+
Name string `json:"name"`
20+
Base string `json:"base"`
21+
}
22+
23+
type SubstitutesForTemplate struct {
24+
Schema string `json:"schema"`
25+
Entries []*declcfg.Meta `json:"entries"`
26+
Substitutions []Substitute `json:"substitutions"`
2227
}
2328

2429
const schema string = "olm.template.substitutes"
2530

26-
func parseSpec(reader io.Reader) (*SubstitutesTemplate, error) {
27-
st := &SubstitutesTemplate{}
31+
func parseSpec(reader io.Reader) (*SubstitutesForTemplate, error) {
32+
st := &SubstitutesForTemplate{}
2833
stDoc := json.RawMessage{}
2934
stDecoder := yaml.NewYAMLOrJSONDecoder(reader, 4096)
3035
err := stDecoder.Decode(&stDoc)

pkg/cache/cache.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,6 @@ func (c *cache) processPackage(ctx context.Context, reader io.Reader) (packageIn
367367
if err != nil {
368368
return nil, err
369369
}
370-
371-
// TODO: for each input channel, adjust the entries to respect re-ordering by release attributes as required
372-
// do so as FBC so that the routine may be made common, and re-used for OLMv1
373-
374370
pkgModel, err := declcfg.ConvertToModel(*pkgFbc)
375371
if err != nil {
376372
return nil, err

0 commit comments

Comments
 (0)