Skip to content

Commit b79a27a

Browse files
committed
catalog_add: use explicit name for catalog source
1 parent 4780ff4 commit b79a27a

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

internal/cmd/catalog_add.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ func newCatalogAddCmd(cfg *action.Configuration) *cobra.Command {
1616
a := action.NewAddCatalog(cfg)
1717

1818
cmd := &cobra.Command{
19-
Use: "add <index_image>",
19+
Use: "add <name> <index_image>",
2020
Short: "Add an operator catalog",
21-
Args: cobra.ExactArgs(1),
21+
Args: cobra.ExactArgs(2),
2222
PreRun: func(cmd *cobra.Command, args []string) {
2323
regLogger := logrus.New()
2424
regLogger.SetOutput(ioutil.Discard)
@@ -30,7 +30,8 @@ func newCatalogAddCmd(cfg *action.Configuration) *cobra.Command {
3030
ctx, cancel := context.WithTimeout(cmd.Context(), a.AddTimeout)
3131
defer cancel()
3232

33-
a.IndexImage = args[0]
33+
a.CatalogSourceName = args[0]
34+
a.IndexImage = args[1]
3435

3536
cs, err := a.Run(ctx)
3637
if err != nil {

internal/pkg/action/catalog_add.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/spf13/pflag"
1212
"k8s.io/apimachinery/pkg/types"
1313
"k8s.io/apimachinery/pkg/util/wait"
14-
"sigs.k8s.io/cluster-api/util/container"
1514
"sigs.k8s.io/controller-runtime/pkg/client"
1615

1716
"github.com/joelanford/kubectl-operator/internal/pkg/catalog"
@@ -21,11 +20,12 @@ import (
2120
type AddCatalog struct {
2221
config *Configuration
2322

24-
IndexImage string
25-
DisplayName string
26-
Publisher string
27-
AddTimeout time.Duration
28-
CleanupTimeout time.Duration
23+
CatalogSourceName string
24+
IndexImage string
25+
DisplayName string
26+
Publisher string
27+
AddTimeout time.Duration
28+
CleanupTimeout time.Duration
2929

3030
RegistryOptions []containerdregistry.RegistryOption
3131

@@ -58,13 +58,9 @@ func (a *AddCatalog) Run(ctx context.Context) (*v1alpha1.CatalogSource, error) {
5858
}
5959
}()
6060

61-
imageRef, err := container.ImageFromString(a.IndexImage)
62-
if err != nil {
63-
return nil, err
64-
}
6561
csKey := types.NamespacedName{
6662
Namespace: a.config.Namespace,
67-
Name: imageRef.Name,
63+
Name: a.CatalogSourceName,
6864
}
6965

7066
labels, err := a.labelsFor(ctx, a.IndexImage)

0 commit comments

Comments
 (0)