Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "configmap", Short: "Get data from ConfigMap", Aliases: []string{"cm"}, Args: cobra.NoArgs, Run: func(c *cobra.Command, args []string) { clientset, defaultNamespace, _ := k8s.KubernetesClient() namespace := defaultNamespace if CmdFlagNamespace != "" { namespace = CmdFlagNamespace } configmapClient := clientset.CoreV1().ConfigMaps(namespace) configmap, err := configmapClient.Get(context.TODO(), CmdFlagName, metav1.GetOptions{}) if err != nil { log.Fatal(err) } if CmdFlagKey != "" { if FlagJson { outJson, err := json.Marshal(string(configmap.Data[CmdFlagKey])) if err != nil { panic(err) } fmt.Println(string(outJson)) } else { fmt.Println(string(configmap.Data[CmdFlagKey])) } } else { if FlagJson { out := make(map[string]string) for key, val := range configmap.Data { out[key] = string(val) } outJson, err := json.Marshal(out) if err != nil { panic(err) } fmt.Println(string(outJson)) } else { for key, val := range configmap.Data { fmt.Printf("KEY: %s\nVALUE: %s\n---\n", key, val) } } } }, }
View Source
var CmdFlagKey string
View Source
var CmdFlagName string
View Source
var CmdFlagNamespace string
View Source
var FlagJson bool
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.