github.skymusic.top/operator-framework/operator-sdk@v0.8.2/cmd/operator-sdk/main.go (about) 1 // Copyright 2019 The Operator-SDK Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "github.com/operator-framework/operator-sdk/internal/util/projutil" 19 "os" 20 21 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) 22 // to ensure that `run` and `up local` can make use of them. 23 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/add" 24 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/build" 25 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion" 26 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate" 27 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/migrate" 28 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/new" 29 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/olmcatalog" 30 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/printdeps" 31 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/run" 32 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/scorecard" 33 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/test" 34 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/up" 35 "github.com/operator-framework/operator-sdk/cmd/operator-sdk/version" 36 flags "github.com/operator-framework/operator-sdk/internal/pkg/flags" 37 38 log "github.com/sirupsen/logrus" 39 "github.com/spf13/cobra" 40 "github.com/spf13/viper" 41 _ "k8s.io/client-go/plugin/pkg/client/auth" 42 ) 43 44 func main() { 45 root := &cobra.Command{ 46 Use: "operator-sdk", 47 Short: "An SDK for building operators with ease", 48 PersistentPreRun: func(cmd *cobra.Command, args []string) { 49 if viper.GetBool(flags.VerboseOpt) { 50 err := projutil.SetGoVerbose() 51 if err != nil { 52 log.Errorf("Could not set GOFLAGS: (%v)", err) 53 return 54 } 55 log.SetLevel(log.DebugLevel) 56 log.Debug("Debug logging is set") 57 } 58 }, 59 } 60 61 root.AddCommand(new.NewCmd()) 62 root.AddCommand(add.NewCmd()) 63 root.AddCommand(build.NewCmd()) 64 root.AddCommand(generate.NewCmd()) 65 root.AddCommand(up.NewCmd()) 66 root.AddCommand(completion.NewCmd()) 67 root.AddCommand(test.NewCmd()) 68 root.AddCommand(scorecard.NewCmd()) 69 root.AddCommand(printdeps.NewCmd()) 70 root.AddCommand(migrate.NewCmd()) 71 root.AddCommand(run.NewCmd()) 72 root.AddCommand(olmcatalog.NewCmd()) 73 root.AddCommand(version.NewCmd()) 74 75 root.PersistentFlags().Bool(flags.VerboseOpt, false, "Enable verbose logging") 76 if err := viper.BindPFlags(root.PersistentFlags()); err != nil { 77 log.Fatalf("Failed to bind root flags: %v", err) 78 } 79 80 if err := root.Execute(); err != nil { 81 os.Exit(1) 82 } 83 }