Skip to content

Commit 99fc008

Browse files
author
bowenislandsong
committedApr 1, 2020
[feature] Understanding packages from directory
This commit adds a feature to interpret bundle name and channels based on a given bundle directory and update bundle's annotation YAML. This feature is triggered when opm alpha generate/build is not supplying packageName, channels, and defaultChannels information. This Bundle directory needs to be inside a Package directory that contains all bundles. The previous reverted commit 13373cb accidentally changed opm command. This commit removes the duplicated package flag. This commit corrects bundle dir from pakcgae directory. This commit adds an error message for getting empty channels for a bundle. This commit skipes error for trying to parse anyfile as Json or Yaml format. The output directory of the annotation file is not the bundle directory rather its parent directory. This fix resolves it.
1 parent 1186793 commit 99fc008

Some content is hidden

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

49 files changed

+20168
-26
lines changed
 

‎cmd/opm/alpha/bundle/build.go

+18-14
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,37 @@ func newBundleBuildCmd() *cobra.Command {
4444
RunE: buildFunc,
4545
}
4646

47-
bundleBuildCmd.Flags().StringVarP(&dirBuildArgs, "directory", "d", "", "The directory where bundle manifests and metadata for a specific version are located")
47+
bundleBuildCmd.Flags().StringVarP(&dirBuildArgs, "directory", "d", "",
48+
"The directory where bundle manifests and metadata for a specific version are located")
4849
if err := bundleBuildCmd.MarkFlagRequired("directory"); err != nil {
4950
log.Fatalf("Failed to mark `directory` flag for `build` subcommand as required")
5051
}
5152

52-
bundleBuildCmd.Flags().StringVarP(&tagBuildArgs, "tag", "t", "", "The image tag applied to the bundle image")
53+
bundleBuildCmd.Flags().StringVarP(&tagBuildArgs, "tag", "t", "",
54+
"The image tag applied to the bundle image")
5355
if err := bundleBuildCmd.MarkFlagRequired("tag"); err != nil {
5456
log.Fatalf("Failed to mark `tag` flag for `build` subcommand as required")
5557
}
5658

57-
bundleBuildCmd.Flags().StringVarP(&packageNameArgs, "package", "p", "", "The name of the package that bundle image belongs to")
58-
if err := bundleBuildCmd.MarkFlagRequired("package"); err != nil {
59-
log.Fatalf("Failed to mark `package` flag for `build` subcommand as required")
60-
}
59+
bundleBuildCmd.Flags().StringVarP(&packageNameArgs, "package", "p", "",
60+
"The name of the package that bundle image belongs to "+
61+
"(Required if `directory` is not pointing to a bundle in the nested bundle format)")
6162

62-
bundleBuildCmd.Flags().StringVarP(&channelsArgs, "channels", "c", "", "The list of channels that bundle image belongs to")
63-
if err := bundleBuildCmd.MarkFlagRequired("channels"); err != nil {
64-
log.Fatalf("Failed to mark `channels` flag for `build` subcommand as required")
65-
}
63+
bundleBuildCmd.Flags().StringVarP(&channelsArgs, "channels", "c", "",
64+
"The list of channels that bundle image belongs to"+
65+
"(Required if `directory` is not pointing to a bundle in the nested bundle format)")
6666

67-
bundleBuildCmd.Flags().StringVarP(&imageBuilderArgs, "image-builder", "b", "docker", "Tool to build container images. One of: [docker, podman, buildah]")
67+
bundleBuildCmd.Flags().StringVarP(&imageBuilderArgs, "image-builder", "b", "docker",
68+
"Tool to build container images. One of: [docker, podman, buildah]")
6869

69-
bundleBuildCmd.Flags().StringVarP(&channelDefaultArgs, "default", "e", "", "The default channel for the bundle image")
70+
bundleBuildCmd.Flags().StringVarP(&channelDefaultArgs, "default", "e", "",
71+
"The default channel for the bundle image")
7072

71-
bundleBuildCmd.Flags().BoolVarP(&overwriteArgs, "overwrite", "o", false, "To overwrite annotations.yaml locally if existed. By default, overwrite is set to `false`.")
73+
bundleBuildCmd.Flags().BoolVarP(&overwriteArgs, "overwrite", "o", false,
74+
"To overwrite annotations.yaml locally if existed. By default, overwrite is set to `false`.")
7275

73-
bundleBuildCmd.Flags().StringVarP(&outputDirArgs, "output-dir", "u", "", "Optional output directory for operator manifests")
76+
bundleBuildCmd.Flags().StringVarP(&outputDirArgs, "output-dir", "u", "",
77+
"Optional output directory for operator manifests")
7478

7579
return bundleBuildCmd
7680
}

‎cmd/opm/alpha/bundle/generate.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,25 @@ func newBundleGenerateCmd() *cobra.Command {
2424
RunE: generateFunc,
2525
}
2626

27-
bundleGenerateCmd.Flags().StringVarP(&dirBuildArgs, "directory", "d", "", "The directory where bundle manifests for a specific version are located.")
27+
bundleGenerateCmd.Flags().StringVarP(&dirBuildArgs, "directory", "d", "",
28+
"The directory where bundle manifests for a specific version are located.")
2829
if err := bundleGenerateCmd.MarkFlagRequired("directory"); err != nil {
2930
log.Fatalf("Failed to mark `directory` flag for `generate` subcommand as required")
3031
}
3132

32-
bundleGenerateCmd.Flags().StringVarP(&packageNameArgs, "package", "p", "", "The name of the package that bundle image belongs to")
33-
if err := bundleGenerateCmd.MarkFlagRequired("package"); err != nil {
34-
log.Fatalf("Failed to mark `package` flag for `generate` subcommand as required")
35-
}
33+
bundleGenerateCmd.Flags().StringVarP(&packageNameArgs, "package", "p", "",
34+
"The name of the package that bundle image belongs to "+
35+
"(Required if `directory` is not pointing to a bundle in the nested bundle format)")
3636

37-
bundleGenerateCmd.Flags().StringVarP(&channelsArgs, "channels", "c", "", "The list of channels that bundle image belongs to")
38-
if err := bundleGenerateCmd.MarkFlagRequired("channels"); err != nil {
39-
log.Fatalf("Failed to mark `channels` flag for `generate` subcommand as required")
40-
}
37+
bundleGenerateCmd.Flags().StringVarP(&channelsArgs, "channels", "c", "",
38+
"The list of channels that bundle image belongs to"+
39+
"(Required if `directory` is not pointing to a bundle in the nested bundle format)")
4140

42-
bundleGenerateCmd.Flags().StringVarP(&channelDefaultArgs, "default", "e", "", "The default channel for the bundle image")
41+
bundleGenerateCmd.Flags().StringVarP(&channelDefaultArgs, "default", "e", "",
42+
"The default channel for the bundle image")
4343

44-
bundleGenerateCmd.Flags().StringVarP(&outputDirArgs, "output-dir", "u", "", "Optional output directory for operator manifests")
44+
bundleGenerateCmd.Flags().StringVarP(&outputDirArgs, "output-dir", "u", "",
45+
"Optional output directory for operator manifests")
4546

4647
return bundleGenerateCmd
4748
}

0 commit comments

Comments
 (0)