Fix golangci-lint errors (#10196)
* Fix golangci-lint errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix dupl errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix comments Signed-off-by: z1cheng <imchench@gmail.com> * Fix errcheck lint errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix assert in e2e test Signed-off-by: z1cheng <imchench@gmail.com> * Not interrupt the waitForPodsReady Signed-off-by: z1cheng <imchench@gmail.com> * Replace string with constant Signed-off-by: z1cheng <imchench@gmail.com> * Fix comments Signed-off-by: z1cheng <imchench@gmail.com> * Revert write file permision Signed-off-by: z1cheng <imchench@gmail.com> --------- Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
46d87d3462
commit
b3060bfbd0
253 changed files with 2434 additions and 2113 deletions
|
|
@ -66,6 +66,7 @@ func (f *Framework) ExecCommand(pod *corev1.Pod, command string) (string, error)
|
|||
execErr bytes.Buffer
|
||||
)
|
||||
|
||||
//nolint:gosec // Ignore G204 error
|
||||
cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf("%v exec --namespace %s %s --container controller -- %s", KubectlPath, pod.Namespace, pod.Name, command))
|
||||
cmd.Stdout = &execOut
|
||||
cmd.Stderr = &execErr
|
||||
|
|
@ -73,7 +74,6 @@ func (f *Framework) ExecCommand(pod *corev1.Pod, command string) (string, error)
|
|||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not execute '%s %s': %v", cmd.Path, cmd.Args, err)
|
||||
|
||||
}
|
||||
|
||||
if execErr.Len() > 0 {
|
||||
|
|
@ -91,6 +91,7 @@ func (f *Framework) NamespaceContent() (string, error) {
|
|||
execErr bytes.Buffer
|
||||
)
|
||||
|
||||
//nolint:gosec // Ignore G204 error
|
||||
cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf("%v get pods,services,endpoints,deployments --namespace %s", KubectlPath, f.Namespace))
|
||||
cmd.Stdout = &execOut
|
||||
cmd.Stderr = &execErr
|
||||
|
|
@ -98,7 +99,6 @@ func (f *Framework) NamespaceContent() (string, error) {
|
|||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not execute '%s %s': %v", cmd.Path, cmd.Args, err)
|
||||
|
||||
}
|
||||
|
||||
eout := strings.TrimSpace(execErr.String())
|
||||
|
|
@ -110,7 +110,7 @@ func (f *Framework) NamespaceContent() (string, error) {
|
|||
}
|
||||
|
||||
// newIngressController deploys a new NGINX Ingress controller in a namespace
|
||||
func (f *Framework) newIngressController(namespace string, namespaceOverlay string) error {
|
||||
func (f *Framework) newIngressController(namespace, namespaceOverlay string) error {
|
||||
// Creates an nginx deployment
|
||||
isChroot, ok := os.LookupEnv("IS_CHROOT")
|
||||
if !ok {
|
||||
|
|
@ -130,12 +130,11 @@ func (f *Framework) newIngressController(namespace string, namespaceOverlay stri
|
|||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
proxyRegexp = regexp.MustCompile("Starting to serve on .*:([0-9]+)")
|
||||
)
|
||||
var proxyRegexp = regexp.MustCompile(`Starting to serve on .*:(\d+)`)
|
||||
|
||||
// KubectlProxy creates a proxy to kubernetes apiserver
|
||||
func (f *Framework) KubectlProxy(port int) (int, *exec.Cmd, error) {
|
||||
//nolint:gosec // Ignore G204 error
|
||||
cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf("%s proxy --accept-hosts=.* --address=0.0.0.0 --port=%d", KubectlPath, port))
|
||||
stdout, stderr, err := startCmdAndStreamOutput(cmd)
|
||||
if err != nil {
|
||||
|
|
@ -163,6 +162,7 @@ func (f *Framework) KubectlProxy(port int) (int, *exec.Cmd, error) {
|
|||
}
|
||||
|
||||
func (f *Framework) UninstallChart() error {
|
||||
//nolint:gosec //Ignore G204 error
|
||||
cmd := exec.Command("helm", "uninstall", "--namespace", f.Namespace, "nginx-ingress")
|
||||
_, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue