Skip to content

Commit 19c4ee4

Browse files
committed
updates
Signed-off-by: grokspawn <[email protected]>
1 parent ed49115 commit 19c4ee4

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
@@ -345,33 +345,32 @@ func (b *Bundle) VersionString() string {
345345

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

357-
// order by release, if present
358-
// - label first, if present;
359-
// - then version, if present;
360-
//
361-
// then version
357+
// order by version, then
358+
// release, if present
359+
// - label first, if present
360+
// - then version, if present
362361
func (b *Bundle) Compare(other *Bundle) int {
363362
if b.Name == other.Name {
364363
return 0
365364
}
365+
if b.Version.NE(other.Version) {
366+
return b.Version.Compare(other.Version)
367+
}
366368
if b.Release.Label != other.Release.Label {
367369
return strings.Compare(b.Release.Label, other.Release.Label)
368370
}
369371
if b.Release.Version.NE(other.Release.Version) {
370372
return b.Release.Version.Compare(other.Release.Version)
371373
}
372-
if b.Version.NE(other.Version) {
373-
return b.Version.Compare(other.Version)
374-
}
375374
return 0
376375
}
377376

alpha/model/model_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,41 @@ func TestValidators(t *testing.T) {
288288
},
289289
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]}]`),
290290
},
291+
{
292+
name: "Package/Error/DuplicateBundleVersionsReleases",
293+
v: &Package{
294+
Name: "anakin",
295+
Channels: map[string]*Channel{
296+
"light": {
297+
Package: pkg,
298+
Name: "light",
299+
Bundles: map[string]*Bundle{
300+
"anakin.v0.0.1": {Name: "anakin.v0.0.1", Version: semver.MustParse("0.0.1")},
301+
"anakin.v0.0.2": {Name: "anakin.v0.0.2", Version: semver.MustParse("0.0.1")},
302+
"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},
303+
"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},
304+
},
305+
},
306+
},
307+
},
308+
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]}]`),
309+
},
310+
{
311+
name: "Package/Error/BundleReleaseNormalizedName",
312+
v: &Package{
313+
Name: "anakin",
314+
Channels: map[string]*Channel{
315+
"light": {
316+
Package: pkg,
317+
Name: "light",
318+
Bundles: map[string]*Bundle{
319+
"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},
320+
},
321+
},
322+
},
323+
},
324+
assertion: hasError(`name "anakin.v0.0.1.alpha.0.0.1" does not match normalized name "anakin-v0.0.1-alpha-0.0.1"`),
325+
},
291326
{
292327
name: "Package/Error/NoDefaultChannel",
293328
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)