Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "morty", Short: "Morty CLI is used to interact with the Morty serverless platform.", PersistentPreRun: func(cmd *cobra.Command, args []string) { // By default, if there is no value for the environment variable // MORTY_LOG, all logs are disabled. // // The program will produce only // outputs that comes from fmt.Print instructions. // But in some cases, it would be great to have the opportunity // to see what is going on in the execution of the program. // // If a value is provided, a logger will be configured. If the value // can't be parsed, the default log level will be applied, INFO. var level log.Level envFlag := os.Getenv(logEnvVarKey) cliFlag, _ := cmd.Flags().GetCount("verbose") switch cliFlag { case 1: level = log.InfoLevel case 2: level = log.DebugLevel case 3: level = log.TraceLevel default: level, _ = log.ParseLevel(envFlag) } if level == 0 { log.SetOutput(io.Discard) } else { log.SetLevel(level) } cfg, err := cliconfig.Load() if err != nil { log.Fatal(err) } currentCtx, err := cfg.GetCurrentContext() if err != nil { log.Fatal(err) } log.Infof("Active context : %s", cfg.Current) ctx := context.WithValue(cmd.Context(), cliconfig.CtxKey{}, cfg) ctx = context.WithValue(ctx, cliconfig.CurrentCtxKey{}, currentCtx) ctx = context.WithValue(ctx, cliconfig.ControllerClientContextKey{}, makeMortyClient(currentCtx.Controller)) ctx = context.WithValue(ctx, cliconfig.RegistryClientContextKey{}, makeRegistryClient(currentCtx.Registry)) cmd.SetContext(ctx) }, }
rootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.