"opm alpha diff xxx -i include.yaml" doesn't change default channel when the current default channels is not in include.yaml
When use "opm alpha diff xxx -i include.yaml", if the current default channels is not mirrored, the default channel still the old one. It should be given by the user (when multiple channels are selected) or the single selected channels becomes the new default channel.
[root@preserve-olm-agent-test .docker]# opm alpha list bundles quay.io/xzhao/catalog-test:45317-test
PACKAGE CHANNEL BUNDLE REPLACES SKIPS SKIP RANGE IMAGE
ditto-operator alpha-1 ditto-operator.v0.1.0 quay.io/xzhao/ditto-operator:0.1.0-2196
ditto-operator alpha-2 ditto-operator.v0.1.0 quay.io/xzhao/ditto-operator:0.1.0-2196
ditto-operator alpha-2 ditto-operator.v0.1.1 ditto-operator.v0.1.0 quay.io/xzhao/ditto-operator:0.1.1-2196
ditto-operator alpha-3 ditto-operator.v0.1.1 quay.io/xzhao/ditto-operator:0.1.1-2196
ditto-operator alpha-3 ditto-operator.v0.2.0 ditto-operator.v0.1.1 quay.io/xzhao/ditto-operator:0.2.0-2196
ditto-operator default channel is alpha-1
[root@preserve-olm-agent-test JIRA-2196]# cat include.yaml.test
packages:
- name: ditto-operator
channels:
- name: alpha-3
[root@preserve-olm-agent-test JIRA-2196]# opm alpha diff quay.io/xzhao/catalog-test:45317-test -i include.yaml.test -o yaml > test/index.yaml
[root@preserve-olm-agent-test JIRA-2196]# opm validate test/
FATA[0000] invalid index:
└── invalid package "ditto-operator":
└── invalid channel "alpha-1":
└── channel must contain at least one bundle
[root@preserve-olm-agent-test JIRA-2196]# cat test/index.yaml
---
defaultChannel: alpha-1
name: ditto-operator
schema: olm.package
---
entries:
- name: ditto-operator.v0.1.1
- name: ditto-operator.v0.2.0
replaces: ditto-operator.v0.1.1
name: alpha-3
package: ditto-operator
schema: olm.channel
---
image: quay.io/xzhao/ditto-operator:0.1.1-2196
name: ditto-operator.v0.1.1
package: ditto-operator
This actually seems more like a feature request than a bug: the default channel is still externally alpha-1 even though this channel's object is not in the diff. @joelanford is an empty channel never allowed? Is there a reason for that?
This is a contentious area given the default channel setting is on package manager and not on OLM/OPM. They are the authority on which channel is the default channel. When the default channel is empty for some reason, then selecting another channel to be the new default also falls under package manager's responsibility especially if there are multiple available channels. opm diff should not randomly choose a channel to be the new default channel. I wonder if it is more appropriate to error out in this case than choosing a new channel at random.