Skip to content

Commit 16b91b8

Browse files
committedSep 23, 2020
(fix) index add --overwrite-latest
This adds the ability to overwrite the latest bundle during index add in order to avoid having to remove all the bundles from the index and re-add them before being able to add the updated bundle.
1 parent 0e50c92 commit 16b91b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13285
-116
lines changed
 

‎cmd/opm/index/add.go

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func addIndexAddCmd(parent *cobra.Command) {
6262
indexCmd.Flags().Bool("permissive", false, "allow registry load errors")
6363
indexCmd.Flags().StringP("mode", "", "replaces", "graph update mode that defines how channel graphs are updated. One of: [replaces, semver, semver-skippatch]")
6464

65+
indexCmd.Flags().Bool("overwrite-latest", false, "overwrite the latest bundles (channel heads) with those of the same csv name given by --bundles")
66+
if err := indexCmd.Flags().MarkHidden("overwrite-latest"); err != nil {
67+
logrus.Panic(err.Error())
68+
}
6569
if err := indexCmd.Flags().MarkHidden("debug"); err != nil {
6670
logrus.Panic(err.Error())
6771
}
@@ -118,6 +122,11 @@ func runIndexAddCmdFunc(cmd *cobra.Command, args []string) error {
118122
return err
119123
}
120124

125+
overwrite, err := cmd.Flags().GetBool("overwrite-latest")
126+
if err != nil {
127+
return err
128+
}
129+
121130
modeEnum, err := registry.GetModeFromString(mode)
122131
if err != nil {
123132
return err
@@ -147,6 +156,7 @@ func runIndexAddCmdFunc(cmd *cobra.Command, args []string) error {
147156
Permissive: permissive,
148157
Mode: modeEnum,
149158
SkipTLS: skipTLS,
159+
Overwrite: overwrite,
150160
}
151161

152162
err = indexAdder.AddToIndex(request)

‎cmd/opm/registry/add.go

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func addFunc(cmd *cobra.Command, args []string) error {
7373
Bundles: bundleImages,
7474
Mode: modeEnum,
7575
ContainerTool: containertools.NewContainerTool(containerTool, containertools.NoneTool),
76+
Overwrite: false,
7677
}
7778

7879
logger := logrus.WithFields(logrus.Fields{"bundles": bundleImages})

0 commit comments

Comments
 (0)
Please sign in to comment.