forked from operator-framework/operator-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.go
62 lines (50 loc) · 2.08 KB
/
generate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package bundle
import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/operator-framework/operator-registry/pkg/lib/bundle"
)
// newBundleGenerateCmd returns a command that will generate operator bundle
// annotations.yaml metadata
func newBundleGenerateCmd() *cobra.Command {
bundleGenerateCmd := &cobra.Command{
Use: "generate",
Short: "Generate operator bundle metadata and Dockerfile",
Long: `The "opm alpha bundle generate" command will generate operator
bundle metadata if needed and a Dockerfile to build Operator bundle image.
$ opm alpha bundle generate --directory /test/0.1.0/ --package test-operator \
--channels stable,beta --default stable
Note:
* All manifests yaml must be in the same directory.`,
RunE: generateFunc,
Args: cobra.NoArgs,
}
bundleGenerateCmd.Flags().StringVarP(&buildDir, "directory", "d", "",
"The directory where bundle manifests for a specific version are located.")
if err := bundleGenerateCmd.MarkFlagRequired("directory"); err != nil {
log.Fatalf("Failed to mark `directory` flag for `generate` subcommand as required")
}
bundleGenerateCmd.Flags().StringVarP(&pkg, "package", "p", "",
"The name of the package that bundle image belongs to "+
"(Required if `directory` is not pointing to a bundle in the nested bundle format)")
bundleGenerateCmd.Flags().StringVarP(&channels, "channels", "c", "",
"The list of channels that bundle image belongs to"+
"(Required if `directory` is not pointing to a bundle in the nested bundle format)")
bundleGenerateCmd.Flags().StringVarP(&defaultChannel, "default", "e", "",
"The default channel for the bundle image")
bundleGenerateCmd.Flags().StringVarP(&outputDir, "output-dir", "u", "",
"Optional output directory for operator manifests")
bundleGenerateCmd.Flags().StringVar(&baseImage, "base-image", "scratch", "Use a custom image pullspec as the base bundle image")
return bundleGenerateCmd
}
func generateFunc(cmd *cobra.Command, _ []string) error {
return bundle.GenerateFunc(
buildDir,
outputDir,
pkg,
channels,
defaultChannel,
true,
baseImage,
)
}