diff --git a/pkg/cache/json.go b/pkg/cache/json.go index 47a54952b..f1e90d9a7 100644 --- a/pkg/cache/json.go +++ b/pkg/cache/json.go @@ -14,6 +14,7 @@ import ( "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/pkg/api" "github.com/operator-framework/operator-registry/pkg/registry" + "k8s.io/apimachinery/pkg/util/sets" ) var _ Cache = &JSON{} @@ -58,8 +59,13 @@ func (q *JSON) ListBundles(ctx context.Context) ([]*api.Bundle, error) { func (q *JSON) SendBundles(_ context.Context, s registry.BundleSender) error { for _, pkg := range q.packageIndex { - for _, ch := range pkg.Channels { - for _, b := range ch.Bundles { + channels := sets.KeySet(pkg.Channels) + for _, chName := range sets.List(channels) { + ch := pkg.Channels[chName] + + bundles := sets.KeySet(ch.Bundles) + for _, bName := range sets.List(bundles) { + b := ch.Bundles[bName] apiBundle, err := q.loadAPIBundle(apiBundleKey{pkg.Name, ch.Name, b.Name}) if err != nil { return fmt.Errorf("convert bundle %q: %v", b.Name, err) diff --git a/pkg/cache/pkgs.go b/pkg/cache/pkgs.go index d387ddbd0..af24c397c 100644 --- a/pkg/cache/pkgs.go +++ b/pkg/cache/pkgs.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "sort" + "strings" "github.com/operator-framework/operator-registry/alpha/declcfg" "github.com/operator-framework/operator-registry/alpha/model" @@ -34,6 +35,7 @@ func (pkgs packageIndex) GetPackage(_ context.Context, name string) (*registry.P CurrentCSVName: ch.Head, }) } + sort.Slice(channels, func(i, j int) bool { return strings.Compare(channels[i].Name, channels[j].Name) < 0 }) return ®istry.PackageManifest{ PackageName: pkg.Name, Channels: channels,