Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InitCommand = &cobra.Command{ Use: "init", Short: "Initialize your " + constants.CMD_NAME + "-config file with some sample values", Long: `kl init This command initialize a kl-config. Examples: # Initialize the kl-config file kl init `, Run: func(cmd *cobra.Command, _ []string) { pId := cmd.Flag("projectId").Value.String() aId := cmd.Flag("accountId").Value.String() initFile, err := server.GetKlFile(nil) if err != nil { dir, e := os.Getwd() if e != nil { common.PrintError(e) return } initFile = &server.KLFileType{ Version: "v1", Name: path.Base(dir), Mres: make([]server.ResType, 0), Configs: make([]server.ResType, 0), Secrets: make([]server.ResType, 0), Env: []server.EnvType{{Key: "SAMPLE_ENV", Value: "sample_value"}}, FileMount: server.MountType{ MountBasePath: "./.mounts", Mounts: make([]server.FileEntry, 0), }, } } else { fmt.Println("file already present") } accountId, _ := server.CurrentAccountId() if aId == "" && accountId == "" { accountId, e := use.SelectAccount([]string{}) if e != nil { common.PrintError(e) return } e = lib.SelectAccount(accountId) if e != nil { common.PrintError(e) return } } if aId != "" { e := lib.SelectAccount(aId) if e != nil { common.PrintError(e) return } } projectId, _ := server.CurrentProjectId() if pId == "" && projectId == "" { projectId, e := use.SelectProject([]string{}) if e != nil { common.PrintError(e) return } e = lib.SelectProject(projectId) if e != nil { common.PrintError(e) return } } if pId != "" { e := lib.SelectProject(pId) if e != nil { common.PrintError(e) return } } err = server.WriteKLFile(*initFile) if err != nil { common.PrintError(err) return } fmt.Println("Initialized file", server.GetConfigPath()) }, }
initCmd represents the init command
View Source
var LoadCommand = &cobra.Command{ Use: "load", Short: "load environment variables and mount config files according to defined in " + constants.CMD_NAME + "-config file", Long: `Load Environment This command help you to load environments of the server according to you defined in your kl-config file. Examples: # load environments and mount the configs kl load # load environments and execute a program with that loaded environments kl load <your_cmd> # example with npm start kl load npm start # get environments in json format kl load -o json # get environments in yaml format kl load -o yaml # start a new shell with loaded environments kl load shell # example of env with zsh shell kl load zsh `, Run: func(_ *cobra.Command, args []string) { loadEnv(args) }, }
View Source
var ShowCommand = &cobra.Command{ Use: "show", Short: "print your " + constants.CMD_NAME + "-config file and current context", Long: `Show kl-config`, Run: func(_ *cobra.Command, _ []string) { configFolder, err := common.GetConfigFolder() if err != nil { common.PrintError(err) return } contextFile, err := ioutil.ReadFile(path.Join(configFolder, "config")) if err != nil { common.PrintError(err) return } file, err := ioutil.ReadFile(server.GetConfigPath()) if err != nil { common.PrintError(err) return } common.PrintError(errors.New(table.HeaderText("context:"))) common.PrintError(errors.New(color.Text("---------------------------------------", 4))) fmt.Println(string(contextFile)) common.PrintError(errors.New(table.HeaderText("kl-config:"))) common.PrintError(errors.New(color.Text("---------------------------------------", 4))) fmt.Println(string(file)) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.