Skip to content

Commit 2ed2d79

Browse files
committed
OCPBUGS-73844: Let import mode be decided by the cluster when not specified
Today, we default to "Legacy" importmode when no option is specified. With the introduction of https://issues.redhat.com/browse/MULTIARCH-4552, the importmode is determined by the Cluster version's `desired.architecture` - which if set to "Multi", the import mode is PreserveOriginal else Legacy. Hence we don't need to default to Legacy all the time.
1 parent 4df0e94 commit 2ed2d79

6 files changed

Lines changed: 13 additions & 10 deletions

File tree

pkg/cli/importimage/importimage.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func NewImportImageOptions(streams genericiooptions.IOStreams) *ImportImageOptio
100100
PrintFlags: genericclioptions.NewPrintFlags("imported"),
101101
IOStreams: streams,
102102
ReferencePolicy: tag.SourceReferencePolicy,
103-
ImportMode: string(imagev1.ImportModeLegacy),
104103
}
105104
}
106105

@@ -129,7 +128,7 @@ func NewCmdImportImage(f kcmdutil.Factory, streams genericiooptions.IOStreams) *
129128
cmd.Flags().BoolVar(&o.Confirm, "confirm", o.Confirm, "If true, allow the image stream import location to be set or changed")
130129
cmd.Flags().BoolVar(&o.All, "all", o.All, "If true, import all tags from the provided source on creation or if --from is specified")
131130
cmd.Flags().StringVar(&o.ReferencePolicy, "reference-policy", o.ReferencePolicy, "Allow to request pullthrough for external image when set to 'local'. Defaults to 'source'.")
132-
cmd.Flags().StringVar(&o.ImportMode, "import-mode", o.ImportMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.")
131+
cmd.Flags().StringVar(&o.ImportMode, "import-mode", o.ImportMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. When set to 'Legacy', imports a single sub-manifest. When unspecified, the cluster determines the import mode.")
133132
cmd.Flags().BoolVar(&o.DryRun, "dry-run", o.DryRun, "Fetch information about images without creating or updating an image stream.")
134133
cmd.Flags().BoolVar(&o.Scheduled, "scheduled", o.Scheduled, "Set each imported container image to be periodically imported from a remote repository. Defaults to false.")
135134
cmd.Flags().BoolVar(&o.Insecure, "insecure", o.Insecure, "If true, allow importing from registries that have invalid HTTPS certificates or are hosted via HTTP. This flag will take precedence over the insecure annotation.")
@@ -218,7 +217,8 @@ func (o *ImportImageOptions) Validate() error {
218217
case string(imagev1.ImportModeLegacy):
219218
case string(imagev1.ImportModePreserveOriginal):
220219
case "":
221-
o.ImportMode = string(imagev1.ImportModeLegacy)
220+
// Leave empty and let it be decided based on the ClusterVersion's "desired.architecture" value. If the value is "Multi",
221+
// the import mode is set to "PreserveOriginal", if not it is set to "Legacy"
222222
default:
223223
return fmt.Errorf("valid ImportMode values are %s or %s", imagev1.ImportModeLegacy, imagev1.ImportModePreserveOriginal)
224224
}

pkg/cli/newapp/newapp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func NewCmdNewApplication(f kcmdutil.Factory, streams genericiooptions.IOStreams
302302
cmd.Flags().StringVar(&o.Config.SourceSecret, "source-secret", o.Config.SourceSecret, "The name of an existing secret that should be used for cloning a private git repository.")
303303
cmd.Flags().BoolVar(&o.Config.SkipGeneration, "no-install", o.Config.SkipGeneration, "Do not attempt to run images that describe themselves as being installable")
304304
cmd.Flags().BoolVar(&o.Config.BinaryBuild, "binary", o.Config.BinaryBuild, "Instead of expecting a source URL, set the build to expect binary contents. Will disable triggers.")
305-
cmd.Flags().StringVar(&o.Config.ImportMode, "import-mode", o.Config.ImportMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.")
305+
cmd.Flags().StringVar(&o.Config.ImportMode, "import-mode", o.Config.ImportMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. When set to 'Legacy', imports a single sub-manifest. When unspecified, the cluster determines the import mode.")
306306

307307
o.Action.BindForOutput(cmd.Flags(), "output", "template")
308308
cmd.Flags().String("output-version", "", "The preferred API versions of the output objects")

pkg/cli/newbuild/newbuild.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func NewCmdNewBuild(f kcmdutil.Factory, streams genericiooptions.IOStreams) *cob
158158
cmd.Flags().BoolVar(&o.Config.NoOutput, "no-output", o.Config.NoOutput, "If true, the build output will not be pushed anywhere.")
159159
cmd.Flags().StringVar(&o.Config.SourceImage, "source-image", o.Config.SourceImage, "Specify an image to use as source for the build. You must also specify --source-image-path.")
160160
cmd.Flags().StringVar(&o.Config.SourceImagePath, "source-image-path", o.Config.SourceImagePath, "Specify the file or directory to copy from the source image and its destination in the build directory. Format: [source]:[destination-dir].")
161-
cmd.Flags().StringVar(&o.Config.ImportMode, "import-mode", o.Config.ImportMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.")
161+
cmd.Flags().StringVar(&o.Config.ImportMode, "import-mode", o.Config.ImportMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. When set to 'Legacy', imports a single sub-manifest. When unspecified, the cluster determines the import mode.")
162162

163163
o.Action.BindForOutput(cmd.Flags(), "output", "template", "sort-by")
164164
cmd.Flags().String("output-version", "", "The preferred API versions of the output objects")

pkg/cli/tag/tag.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func NewCmdTag(f kcmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Co
116116
cmd.Flags().BoolVar(&o.scheduleTag, "scheduled", o.scheduleTag, "Set a container image to be periodically imported from a remote repository. Defaults to false.")
117117
cmd.Flags().BoolVar(&o.insecureTag, "insecure", o.insecureTag, "Set to true if importing the specified container image requires HTTP or has a self-signed certificate. Defaults to false.")
118118
cmd.Flags().StringVar(&o.referencePolicy, "reference-policy", SourceReferencePolicy, "Allow to request pullthrough for external image when set to 'local'. Defaults to 'source'.")
119-
cmd.Flags().StringVar(&o.importMode, "import-mode", o.importMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.")
119+
cmd.Flags().StringVar(&o.importMode, "import-mode", o.importMode, "Imports the full manifest list of a tag when set to 'PreserveOriginal'. When set to 'Legacy', imports a single sub-manifest. When unspecified, the cluster determines the import mode.")
120120

121121
return cmd
122122
}
@@ -367,7 +367,8 @@ func (o *TagOptions) Validate() error {
367367
case string(imagev1.ImportModeLegacy):
368368
case string(imagev1.ImportModePreserveOriginal):
369369
case "":
370-
o.importMode = string(imagev1.ImportModeLegacy)
370+
// Leave empty and let it be decided based on the ClusterVersion's "desired.architecture" value. If the value is "Multi",
371+
// the import mode is set to "PreserveOriginal", if not it is set to "Legacy"
371372
default:
372373
return fmt.Errorf("valid ImportMode values are %s or %s", imagev1.ImportModeLegacy, imagev1.ImportModePreserveOriginal)
373374
}

pkg/cli/tag/tag_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,9 @@ func TestRunTag_AddImportMode(t *testing.T) {
433433
destNameAndTag: []string{"rails:tip"},
434434
},
435435
expectedActions: []testActionWithImportMode{
436-
{verb: "update", resource: "imagestreamtags", importMode: string(imagev1.ImportModeLegacy)},
437-
{verb: "create", resource: "imagestreamtags", importMode: string(imagev1.ImportModeLegacy)},
436+
// Empty import mode - let the cluster decide based on its configuration
437+
{verb: "update", resource: "imagestreamtags", importMode: ""},
438+
{verb: "create", resource: "imagestreamtags", importMode: ""},
438439
},
439440
},
440441
"valid tag with import mode PreserveOriginal": {

pkg/helpers/newapp/cmd/newapp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,8 @@ func (c *AppConfig) Run() (*AppResult, error) {
888888
case string(imagev1.ImportModeLegacy):
889889
case string(imagev1.ImportModePreserveOriginal):
890890
case "":
891-
c.ImportMode = string(imagev1.ImportModeLegacy)
891+
// Leave empty and let it be decided based on the ClusterVersion's "desired.architecture" value. If the value is "Multi",
892+
// the import mode is set to "PreserveOriginal", if not it is set to "Legacy"
892893
default:
893894
return nil, fmt.Errorf("valid ImportMode values are %s or %s", imagev1.ImportModeLegacy, imagev1.ImportModePreserveOriginal)
894895
}

0 commit comments

Comments
 (0)