feat(plugin): set DefaultIngressContainerName to empty

This commit is contained in:
wrype 2023-08-01 01:38:16 +08:00
parent afd1311f85
commit b2808c9ff7
2 changed files with 7 additions and 3 deletions

View file

@ -32,7 +32,11 @@ import (
// PodExecString takes a pod and a command, uses kubectl exec to run the command in the pod
// and returns stdout as a string
func PodExecString(flags *genericclioptions.ConfigFlags, pod *apiv1.Pod, container string, args []string) (string, error) {
args = append([]string{"exec", "-n", pod.Namespace, "-c", container, pod.Name}, args...)
params := []string{"exec", "-n", pod.Namespace, pod.Name}
if len(container) > 0 {
params = append(params, "-c", container)
}
args = append(params, args...)
return ExecToString(flags, args)
}

View file

@ -31,7 +31,7 @@ import (
const (
DefaultIngressDeploymentName = "ingress-nginx-controller"
DefaultIngressServiceName = "ingress-nginx-controller"
DefaultIngressContainerName = "controller"
DefaultIngressContainerName = ""
)
// IssuePrefix is the github url that we can append an issue number to to link to it
@ -131,7 +131,7 @@ func AddSelectorFlag(cmd *cobra.Command) *string {
// 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")
cmd.Flags().StringVarP(&v, "container", "c", DefaultIngressContainerName, "The name of the ingress-nginx controller container")
return &v
}