Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundle create: set default channel if only one channel is set #3124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/fragments/bundle-default-channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
entries:
- description: >
Set a default channel to the channel supplied to 'bundle create --channels=<c>'
if exactly one channel is set.

kind: addition
7 changes: 7 additions & 0 deletions cmd/operator-sdk/bundle/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

catalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog"
"github.com/operator-framework/operator-sdk/internal/util/projutil"
Expand Down Expand Up @@ -171,6 +172,12 @@ func (c *bundleCreateCmd) setDefaults() (err error) {
c.directory = dir
}

// Ensure a default channel is present if there only one channel. Don't infer
// default otherwise; the user must set this value.
if c.defaultChannel == "" && strings.Count(c.channels, ",") == 0 {
c.defaultChannel = c.channels
}

return nil
}

Expand Down