Skip to content

Commit 0e7f3d4

Browse files
kaovilaiclaude
andcommitted
feat: add --catalog-only flag to run bundle command
Add a new --catalog-only flag to the 'operator-sdk run bundle' command that creates only the catalog source without creating a subscription. This allows users to deploy the catalog source for manual subscription management or for use with other tools. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
1 parent 0da7ea3 commit 0e7f3d4

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

internal/olm/operator/bundle/install.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
type Install struct {
3434
BundleImage string
35+
CatalogOnly bool
3536

3637
*registry.IndexImageCatalogCreator
3738
*registry.OperatorInstaller
@@ -55,6 +56,7 @@ func (i *Install) BindFlags(fs *pflag.FlagSet) {
5556
"the registry pod to decompress the compressed catalog contents. cat and gzip binaries are expected to exist "+
5657
"in the PATH")
5758
fs.Var(&i.InstallMode, "install-mode", "install mode")
59+
fs.BoolVar(&i.CatalogOnly, "catalog-only", false, "create only the catalog source without creating a subscription")
5860

5961
// --mode is hidden so only users who know what they're doing can alter add mode.
6062
fs.StringVar((*string)(&i.BundleAddMode), "mode", "", "mode to use for adding bundle to index")
@@ -67,9 +69,27 @@ func (i Install) Run(ctx context.Context) (*v1alpha1.ClusterServiceVersion, erro
6769
if err := i.setup(ctx); err != nil {
6870
return nil, err
6971
}
72+
73+
// If catalog-only mode is enabled, create only the catalog source
74+
if i.CatalogOnly {
75+
return i.RunCatalogOnly(ctx)
76+
}
77+
7078
return i.InstallOperator(ctx)
7179
}
7280

81+
func (i *Install) RunCatalogOnly(ctx context.Context) (*v1alpha1.ClusterServiceVersion, error) {
82+
cs, err := i.CatalogCreator.CreateCatalog(ctx, i.CatalogSourceName)
83+
if err != nil {
84+
return nil, fmt.Errorf("create catalog: %v", err)
85+
}
86+
log.Infof("Created CatalogSource: %s", cs.GetName())
87+
log.Infof("Catalog-only mode: skipping subscription creation")
88+
89+
// Return nil CSV since we're not installing the operator
90+
return nil, nil
91+
}
92+
7393
func (i *Install) setup(ctx context.Context) error {
7494
// Validate add mode in case it was set by a user.
7595
if i.BundleAddMode != "" {

0 commit comments

Comments
 (0)