Add support for --container flag (#9703)

Add support for --container flag, which sets an explicit container name
for exec operations. Defaults to `controller`.

Signed-off-by: Jacob Henner <code@ventricle.us>
This commit is contained in:
Jacob Henner 2023-05-01 07:32:18 -04:00 committed by GitHub
parent 97a1a6d616
commit ae989d7722
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 31 deletions

View file

@ -31,6 +31,7 @@ import (
const (
DefaultIngressDeploymentName = "ingress-nginx-controller"
DefaultIngressServiceName = "ingress-nginx-controller"
DefaultIngressContainerName = "controller"
)
// IssuePrefix is the github url that we can append an issue number to to link to it
@ -127,6 +128,13 @@ func AddSelectorFlag(cmd *cobra.Command) *string {
return &v
}
// AddContainerFlag adds a --container flag to a cobra command
func AddContainerFlag(cmd *cobra.Command) *string {
v := ""
cmd.Flags().StringVar(&v, "container", DefaultIngressContainerName, "The name of the ingress-nginx controller container")
return &v
}
// GetNamespace takes a set of kubectl flag values and returns the namespace we should be operating in
func GetNamespace(flags *genericclioptions.ConfigFlags) string {
namespace, _, err := flags.ToRawKubeConfigLoader().Namespace()