Skip to content

Commit 7ed36fd

Browse files
minor fixes
Signed-off-by: Rashmi Gottipati <[email protected]>
1 parent 94e5778 commit 7ed36fd

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

internal/cmd/internal/olmv1/catalog_update.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package olmv1
22

33
import (
44
"github.com/spf13/cobra"
5-
"github.com/spf13/pflag"
65

76
"github.com/operator-framework/kubectl-operator/internal/cmd/internal/log"
87
v1action "github.com/operator-framework/kubectl-operator/internal/pkg/v1/action"
@@ -14,28 +13,31 @@ func NewCatalogUpdateCmd(cfg *action.Configuration) *cobra.Command {
1413
i := v1action.NewCatalogUpdate(cfg)
1514
i.Logf = log.Printf
1615

16+
var priority int32
17+
var pollInterval int
18+
var labels map[string]string
19+
1720
cmd := &cobra.Command{
1821
Use: "catalog <catalog>",
1922
Short: "Update a catalog",
2023
Args: cobra.ExactArgs(1),
2124
Run: func(cmd *cobra.Command, args []string) {
2225
i.CatalogName = args[0]
26+
i.Priority = &priority
27+
i.PollIntervalMinutes = &pollInterval
28+
i.Labels = labels
2329
_, err := i.Run(cmd.Context())
2430
if err != nil {
2531
log.Fatalf("failed to update catalog: %v", err)
2632
}
2733
log.Printf("catalog %q updated", i.CatalogName)
2834
},
2935
}
30-
bindCatalogUpdateFlags(cmd.Flags(), i)
36+
cmd.Flags().Int32Var(&priority, "priority", 0, "priority determines the likelihood of a catalog being selected in conflict scenarios")
37+
cmd.Flags().IntVar(&pollInterval, "source-poll-interval-minutes", 5, "catalog source polling interval [in minutes]. Set to 0 or -1 to remove the polling interval.")
38+
cmd.Flags().StringToStringVar(&labels, "labels", map[string]string{}, "labels that will be added to the catalog")
39+
cmd.Flags().StringVar(&i.AvailabilityMode, "availability-mode", "", "available means that the catalog should be active and serving data")
40+
cmd.Flags().StringVar(&i.ImageRef, "image", "", "Image reference for the catalog source. Leave unset to retain the current image.")
3141

3242
return cmd
3343
}
34-
35-
func bindCatalogUpdateFlags(fs *pflag.FlagSet, i *v1action.CatalogUpdate) {
36-
fs.Int32Var(i.Priority, "priority", 1, "priority determines the likelihood of a catalog being selected in conflict scenarios")
37-
fs.IntVar(i.PollIntervalMinutes, "source-poll-interval-minutes", 5, "catalog source polling interval [in minutes]. Set to 0 or -1 to remove the polling interval.")
38-
fs.StringToStringVar(&i.Labels, "labels", map[string]string{}, "labels that will be added to the catalog")
39-
fs.StringVar(&i.AvailabilityMode, "availability-mode", "", "available means that the catalog should be active and serving data")
40-
fs.StringVar(&i.ImageRef, "image", "", "Image reference for the catalog source. Leave unset to retain the current image.")
41-
}

internal/pkg/v1/action/catalog_update.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ type CatalogUpdate struct {
2727

2828
func NewCatalogUpdate(config *action.Configuration) *CatalogUpdate {
2929
return &CatalogUpdate{
30-
config: config,
31-
Logf: func(string, ...interface{}) {},
32-
Priority: new(int32),
33-
PollIntervalMinutes: new(int),
34-
Labels: make(map[string]string),
30+
config: config,
31+
Logf: func(string, ...interface{}) {},
3532
}
3633
}
3734

0 commit comments

Comments
 (0)