github.com/operator-framework/operator-lifecycle-manager@v0.30.0/cmd/catalog/start.go (about) 1 package main 2 3 import ( 4 "context" 5 "fmt" 6 "os" 7 "time" 8 9 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/signals" 10 olmversion "github.com/operator-framework/operator-lifecycle-manager/pkg/version" 11 "github.com/sirupsen/logrus" 12 "github.com/spf13/cobra" 13 ) 14 15 type options struct { 16 kubeconfig string 17 catalogNamespace string 18 configMapServerImage string 19 opmImage string 20 utilImage string 21 writeStatusName string 22 debug bool 23 version bool 24 profiling bool 25 tlsKeyPath string 26 tlsCertPath string 27 clientCAPath string 28 setWorkloadUserID bool 29 30 installPlanTimeout time.Duration 31 bundleUnpackTimeout time.Duration 32 wakeupInterval time.Duration 33 } 34 35 func newRootCmd() *cobra.Command { 36 o := options{} 37 38 cmd := &cobra.Command{ 39 Use: "Start", 40 Short: "Starts the Catalog Operator", 41 SilenceUsage: true, 42 RunE: func(cmd *cobra.Command, args []string) error { 43 if o.version { 44 fmt.Print(olmversion.String()) 45 return nil 46 } 47 48 logger := logrus.New() 49 if o.debug { 50 logger.SetLevel(logrus.DebugLevel) 51 } 52 logger.Infof("log level %s", logger.Level) 53 54 ctx, cancel := context.WithCancel(signals.Context()) 55 defer cancel() 56 57 if err := o.run(ctx, logger); err != nil { 58 return err 59 } 60 return nil 61 }, 62 } 63 64 cmd.Flags().StringVar(&o.kubeconfig, "kubeconfig", os.Getenv("KUBECONFIG"), "absolute path to the kubeconfig file") 65 cmd.Flags().StringVar(&o.catalogNamespace, "namespace", defaultCatalogNamespace, "namespace where catalog will run and install catalog resources") 66 cmd.Flags().StringVar(&o.configMapServerImage, "configmapServerImage", defaultConfigMapServerImage, "the image to use for serving the operator registry api for a configmap") 67 cmd.Flags().StringVar(&o.opmImage, "opmImage", defaultOPMImage, "the image to use for unpacking bundle content with opm") 68 cmd.Flags().StringVar(&o.utilImage, "util-image", defaultUtilImage, "an image containing custom olm utilities") 69 cmd.Flags().StringVar(&o.writeStatusName, "writeStatusName", defaultOperatorName, "ClusterOperator name in which to write status, set to \"\" to disable.") 70 cmd.Flags().BoolVar(&o.setWorkloadUserID, "set-workload-user-id", false, "set user ID for all workloads (registry pods/bundle unpack jobs to default 1001") 71 72 cmd.Flags().BoolVar(&o.debug, "debug", false, "use debug log level") 73 cmd.Flags().BoolVar(&o.version, "version", false, "displays the olm version") 74 cmd.Flags().BoolVar(&o.profiling, "profiling", false, "deprecated") 75 cmd.Flags().MarkDeprecated("profiling", "profiling is now enabled by default") 76 77 cmd.Flags().StringVar(&o.tlsKeyPath, "tls-key", "", "path to use for private key (requires tls-cert)") 78 cmd.Flags().StringVar(&o.tlsCertPath, "tls-cert", "", "path to use for certificate key (requires tls-key)") 79 cmd.Flags().StringVar(&o.clientCAPath, "client-ca", "", "path to watch for client ca bundle") 80 81 cmd.Flags().DurationVar(&o.wakeupInterval, "interval", defaultWakeupInterval, "wakeup interval") 82 cmd.Flags().DurationVar(&o.bundleUnpackTimeout, "bundle-unpack-timeout", 10*time.Minute, "The time limit for bundle unpacking, after which InstallPlan execution is considered to have failed. 0 is considered as having no timeout.") 83 cmd.Flags().DurationVar(&o.installPlanTimeout, "install-plan-retry-timeout", 1*time.Minute, "time since first attempt at which plan execution errors are considered fatal") 84 85 return cmd 86 }