Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigCmd = &cobra.Command{
Use: "config",
Short: "Manage configuration of the CLI utility",
Long: "Manage configuration of the CLI utility",
}
View Source
var ConfigInitCmd = &cobra.Command{ Use: "init", Short: "import config", Long: "import config", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { filename := args[0] log.GetLogger().Infof("Start [%s %s]", cmd.CommandPath(), filename) c := &config.Config{} file, err := ioutil.ReadFile(filename) if err != nil { log.GetLogger().Debugf("Failed to open file %s, [ERROR: %s]", filename, err) exit.SetExitWithError(err, fmt.Sprintf("Failed to open file %s", filename)) return } err = json.Unmarshal([]byte(file), c) if err != nil { log.GetLogger().Debugf("Failed to parse file %s, [ERROR: %s]", filename, err) exit.SetExitWithError(err, fmt.Sprintf("Failed to parse file as json file %s", filename)) return } c.Log(fmt.Sprintf("Init with file %s: ", filename)) if len(c.Profile) == 0 { c.Profile = "prod" } err = c.MiniCheck() if err != nil { log.GetLogger().Debugf("Config file has missing fields %s, [ERROR: %s]", filename, err) exit.SetExitWithError(err, fmt.Sprintf("Config file has missing fields %s", filename)) return } log.GetLogger().Infof("Minicheck ok") configFile := context.GetContext().ConfigFilename() err = c.Save(configFile) if err != nil { log.GetLogger().Debugf("Error in saving config file, [ERROR: %s]", err) exit.SetExitWithError(err, fmt.Sprintf("Error saving confing file")) return } log.GetLogger().Infof("Save config to file %s", configFile) log.GetLogger().Infof("End [%s %s]", cmd.CommandPath(), filename) }, }
View Source
var ConfigSetCmd = &cobra.Command{
Use: "set",
Short: "Set pctl config",
Long: "Set various parameters of pctl config",
}
View Source
var ConfigSetProjectCmd = &cobra.Command{ Use: "project <project name>", Short: "set the project to be used", Long: "set the project under which all applicable pctl command will be executed", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { if len(args) <= 0 { err := fmt.Errorf("invalid command") exit.SetExitWithError(err, fmt.Sprintf("Failed to get the command args")) return } project := args[0] log.GetLogger().Debugf("Start [%s %s]", cmd.CommandPath(), project) _, err := testProjectAccess(project) if err != nil { exit.SetExitWithError(err, fmt.Sprintf("Failed to set project %s", project)) return } conf := config.GetConfig() conf.Project = project configFile := context.GetContext().ConfigFilename() err = conf.Save(configFile) if err != nil { log.GetLogger().Debugf("Error in saving config file, [ERROR: %s]", err) exit.SetExitWithError(err, fmt.Sprintf("Error saving confing file")) return } log.GetLogger().Infof("Save config to file %s", configFile) log.GetLogger().Debugf("End [%s]", cmd.CommandPath()) }, }
View Source
var ConfigShowCmd = &cobra.Command{ Use: "show", Short: "display current config", Long: "display current config", Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, args []string) { log.GetLogger().Infof("Start [%s]", cmd.CommandPath()) showSource, err := cmd.Flags().GetBool("source") if err != nil { showSource = false } if showSource { output.PrintOutputer(cmd, config.GetConfigTracker()) } else { output.PrintOutputer(cmd, config.GetConfig()) } log.GetLogger().Infof("End [%s]", cmd.CommandPath()) }, }
View Source
var KubeconfigCmd = &cobra.Command{ Use: "kubeconfig", Short: "Generate kubeconfig", Long: "Allows the user to generate a kubeconfig", Aliases: []string{"kc"}, }
KubeconfigCmd is command definition for kubeconfig root command
View Source
var KubeconfigDownloadCmd = &cobra.Command{ Use: "download", Short: "Download the generated kubeconfig", Long: "Download the generated kubeconfig", Args: cobra.ExactArgs(0), Run: func(cmd *cobra.Command, args []string) { log.GetLogger().Infof("Start [%s]", cmd.CommandPath()) auth := config.GetConfig().GetAppAuthProfile() defaultNamespace, _ := cmd.Flags().GetString("namespace") cluster, _ := cmd.Flags().GetString("cluster") params := url.Values{} if defaultNamespace != "" { params.Add("namespace", defaultNamespace) } if cluster != "" { params.Add("opts.selector", fmt.Sprintf("paralus.dev/clusterName=%s", cluster)) } params.Add("opts.ID", config.GetConfig().APIKey) params.Add("opts.organization", config.GetConfig().Organization) uri := fmt.Sprintf("/v2/sentry/kubeconfig/user?%s", params.Encode()) resp, err := auth.AuthAndRequestFullResponse(uri, "GET", nil) if err != nil { exit.SetExitWithError(err, "failed to get kubeconfig") return } jsonData := &struct { Data string `json:"data"` }{} err = resp.JSON(jsonData) if err != nil { exit.SetExitWithError(err, "failed to get kubeconfig") return } decoded, err := base64.StdEncoding.DecodeString(jsonData.Data) if err != nil { exit.SetExitWithError(err, "failed to get kubeconfig") return } yaml := string(decoded) toFile, _ := cmd.Flags().GetString("to-file") if len(toFile) != 0 { err := ioutil.WriteFile(toFile, []byte(yaml), 0644) if err != nil { exit.SetExitWithError(err, "failed to store the downloaded kubeconfig file ") return } fmt.Println(fmt.Sprintf("kubeconfig downloaded to file - %s", toFile)) } else { fmt.Println(yaml) } log.GetLogger().Infof("End [%s]", cmd.CommandPath()) }, }
KubeconfigDownloadCmd is command definition for kubeconfig download cmd
Functions ¶
Types ¶
This section is empty.
Source Files
¶
- apply.go
- completion.go
- config.go
- create.go
- create_cluster.go
- create_cluster_imported.go
- create_group.go
- create_idp.go
- create_oidc.go
- create_project.go
- create_role.go
- create_user.go
- delete.go
- delete_cluster.go
- delete_group.go
- delete_idp.go
- delete_oidc.go
- delete_project.go
- delete_role.go
- delete_user.go
- download.go
- download_kubeconfig.go
- get.go
- get_cluster.go
- get_cluster_bootstrap.go
- get_group.go
- get_idp.go
- get_location.go
- get_oidc.go
- get_project.go
- get_role.go
- get_rolepermissions.go
- get_user.go
- kubeconfig.go
- root.go
- update.go
- update_cluster.go
- update_groupassociation.go
- version.go
Click to show internal directories.
Click to hide internal directories.