Skip to content

Commit c3a9176

Browse files
committed
compat_otp: lint, vet, owners, etc.
1 parent 80ac5c1 commit c3a9176

File tree

21 files changed

+51
-69
lines changed

21 files changed

+51
-69
lines changed

test/extended/util/compat_otp/architecture/architecture.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func SkipNonAmd64SingleArch(oc *exutil.CLI) (Architecture Architecture) {
6262
func GetAvailableArchitecturesSet(oc *exutil.CLI) []Architecture {
6363
output, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("nodes", "-o=jsonpath={.items[*].status.nodeInfo.architecture}").Output()
6464
if err != nil {
65-
e2e.Failf("unable to get the cluster architecture: ", err)
65+
e2e.Failf("unable to get the cluster architecture: %v", err)
6666
}
6767
if output == "" {
6868
e2e.Failf("the retrieved architecture is empty")
@@ -135,7 +135,7 @@ func (a Architecture) String() string {
135135
func ClusterArchitecture(oc *exutil.CLI) (architecture Architecture) {
136136
output, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("nodes", "-o=jsonpath={.items[*].status.nodeInfo.architecture}").Output()
137137
if err != nil {
138-
e2e.Failf("unable to get the cluster architecture: ", err)
138+
e2e.Failf("unable to get the cluster architecture: %v", err)
139139
}
140140
if output == "" {
141141
e2e.Failf("the retrieved architecture is empty")

test/extended/util/compat_otp/cloud/cloud.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package cloud
22

3-
43
import (
54
"context"
65
"fmt"

test/extended/util/compat_otp/clusterinfra/machine_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func GetLatestMachineFromMachineSet(oc *exutil.CLI, machineSet string) string {
172172
o.Expect(err).NotTo(o.HaveOccurred())
173173
parsedMachineCreationTime, err := time.Parse(time.RFC3339, machineCreationTime)
174174
if err != nil {
175-
e2e.Logf("Error parsing time:", err)
175+
e2e.Logf("Error parsing time: %v", err)
176176
return ""
177177
}
178178
if parsedMachineCreationTime.After(newest) {

test/extended/util/compat_otp/container/quay_client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ func (c *QuayCLI) TryDeleteTag(imageIndex string) (bool, error) {
100100
return false, err
101101
}
102102
response, err := client.Do(reqest)
103-
defer response.Body.Close()
104103
if err != nil {
105104
return false, err
106105
}
106+
defer response.Body.Close()
107107
if response.StatusCode != 204 {
108108
e2e.Logf("delete %s failed, response code is %d", imageIndex, response.StatusCode)
109109
return false, nil
@@ -140,10 +140,10 @@ func (c *QuayCLI) CheckTagNotExist(imageIndex string) (bool, error) {
140140
return false, err
141141
}
142142
response, err := client.Do(reqest)
143-
defer response.Body.Close()
144143
if err != nil {
145144
return false, err
146145
}
146+
defer response.Body.Close()
147147
if response.StatusCode == 404 {
148148
e2e.Logf("tag %s not exist", imageIndex)
149149
return true, nil
@@ -198,10 +198,10 @@ func (c *QuayCLI) GetTags(imageIndex string) ([]TagInfo, error) {
198198
return result, err
199199
}
200200
response, err := client.Do(reqest)
201-
defer response.Body.Close()
202201
if err != nil {
203202
return result, err
204203
}
204+
defer response.Body.Close()
205205
e2e.Logf("%s", response.Status)
206206
if response.StatusCode != 200 {
207207
e2e.Logf("get %s failed, response code is %d", imageIndex, response.StatusCode)
@@ -263,10 +263,10 @@ func (c *QuayCLI) TryChangeTag(imageTag, manifestDigest string) (bool, error) {
263263
return false, err
264264
}
265265
response, err := client.Do(request)
266-
defer response.Body.Close()
267266
if err != nil {
268267
return false, err
269268
}
269+
defer response.Body.Close()
270270
if response.StatusCode != 201 {
271271
e2e.Logf("change %s failed, response code is %d", imageTag, response.StatusCode)
272272
return false, nil

test/extended/util/compat_otp/db/sqlit.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package db
22

3-
43
import (
54
"database/sql"
65
"fmt"
@@ -244,7 +243,7 @@ func (c *Sqlit) Query(dbFilePath string, table string, column string) ([]string,
244243
}
245244
return valueList, nil
246245
default:
247-
err := fmt.Errorf("do not support to query table " + table)
246+
err := fmt.Errorf("do not support to query table %s", table)
248247
return nil, err
249248
}
250249
}

test/extended/util/compat_otp/framework.go

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package compat_otp
22

3-
import exutil "github.com/openshift/origin/test/extended/util"
4-
53
import (
64
"bufio"
75
"context"
@@ -19,8 +17,22 @@ import (
1917
"time"
2018

2119
g "github.com/onsi/ginkgo/v2"
20+
. "github.com/onsi/gomega"
2221
o "github.com/onsi/gomega"
23-
22+
appsv1 "github.com/openshift/api/apps/v1"
23+
buildv1 "github.com/openshift/api/build/v1"
24+
configv1 "github.com/openshift/api/config/v1"
25+
imagev1 "github.com/openshift/api/image/v1"
26+
operatorv1 "github.com/openshift/api/operator/v1"
27+
appsv1clienttyped "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1"
28+
buildv1clienttyped "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1"
29+
imagev1typedclient "github.com/openshift/client-go/image/clientset/versioned/typed/image/v1"
30+
"github.com/openshift/library-go/pkg/apps/appsutil"
31+
"github.com/openshift/library-go/pkg/build/naming"
32+
"github.com/openshift/library-go/pkg/git"
33+
"github.com/openshift/library-go/pkg/image/imageutil"
34+
exutil "github.com/openshift/origin/test/extended/util"
35+
testdata "github.com/openshift/origin/test/extended/util/compat_otp/testdata"
2436
authorizationapi "k8s.io/api/authorization/v1"
2537
batchv1 "k8s.io/api/batch/v1"
2638
corev1 "k8s.io/api/core/v1"
@@ -47,22 +59,6 @@ import (
4759
e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"
4860
"k8s.io/kubernetes/test/e2e/framework/statefulset"
4961
"k8s.io/kubernetes/test/utils/image"
50-
51-
appsv1 "github.com/openshift/api/apps/v1"
52-
buildv1 "github.com/openshift/api/build/v1"
53-
configv1 "github.com/openshift/api/config/v1"
54-
imagev1 "github.com/openshift/api/image/v1"
55-
operatorv1 "github.com/openshift/api/operator/v1"
56-
appsv1clienttyped "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1"
57-
buildv1clienttyped "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1"
58-
imagev1typedclient "github.com/openshift/client-go/image/clientset/versioned/typed/image/v1"
59-
"github.com/openshift/library-go/pkg/apps/appsutil"
60-
"github.com/openshift/library-go/pkg/build/naming"
61-
"github.com/openshift/library-go/pkg/git"
62-
"github.com/openshift/library-go/pkg/image/imageutil"
63-
testdata "github.com/openshift/origin/test/extended/util/compat_otp/testdata"
64-
65-
. "github.com/onsi/gomega"
6662
)
6763

6864
func init() {
@@ -424,7 +420,7 @@ func DumpPodStates(oc *exutil.CLI) {
424420
e2e.Logf("Error dumping pod states: %v", err)
425421
return
426422
}
427-
e2e.Logf(out)
423+
e2e.Logf("%s", out)
428424
}
429425

430426
// DumpPodStatesInNamespace dumps the state of all pods in the provided namespace.
@@ -435,7 +431,7 @@ func DumpPodStatesInNamespace(namespace string, oc *exutil.CLI) {
435431
e2e.Logf("Error dumping pod states: %v", err)
436432
return
437433
}
438-
e2e.Logf(out)
434+
e2e.Logf("%s", out)
439435
}
440436

441437
// DumpPodLogsStartingWith will dump any pod starting with the name prefix provided
@@ -514,7 +510,7 @@ func DumpPodsCommand(c kubernetes.Interface, ns string, selector labels.Selector
514510
}
515511
for name, stdout := range values {
516512
stdout = strings.TrimSuffix(stdout, "\n")
517-
e2e.Logf(name + ": " + strings.Join(strings.Split(stdout, "\n"), fmt.Sprintf("\n%s: ", name)))
513+
e2e.Logf("%s: %s", name, strings.Join(strings.Split(stdout, "\n"), fmt.Sprintf("\n%s: ", name)))
518514
}
519515
}
520516

@@ -526,7 +522,7 @@ func DumpConfigMapStates(oc *exutil.CLI) {
526522
e2e.Logf("Error dumping configMap states: %v", err)
527523
return
528524
}
529-
e2e.Logf(out)
525+
e2e.Logf("%s", out)
530526
}
531527

532528
// GetMasterThreadDump will get a golang thread stack dump

test/extended/util/compat_otp/hypeshift_cluster.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ func ValidHypershiftAndGetGuestKubeConf(oc *exutil.CLI) (string, string, string)
8787
if os.Getenv("GUEST_KUBECONFIG") != "" {
8888
e2e.Logf("the kubeconfig you set GUEST_KUBECONFIG must be that of the hosted cluster %s in namespace %s", clusterName, hostedclusterNS)
8989
hostedClusterKubeconfigFile = os.Getenv("GUEST_KUBECONFIG")
90-
e2e.Logf(fmt.Sprintf("use a known hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile))
90+
e2e.Logf("use a known hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile)
9191
} else {
9292
hostedClusterKubeconfigFile = "/tmp/guestcluster-kubeconfig-" + clusterName + "-" + GetRandomString()
9393
output, err := exec.Command("bash", "-c", fmt.Sprintf("hypershift create kubeconfig --name %s --namespace %s > %s",
9494
clusterName, hostedclusterNS, hostedClusterKubeconfigFile)).Output()
9595
e2e.Logf("the cmd output: %s", string(output))
9696
o.Expect(err).NotTo(o.HaveOccurred())
97-
e2e.Logf(fmt.Sprintf("create a new hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile))
97+
e2e.Logf("create a new hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile)
9898
}
9999
e2e.Logf("if you want hostedcluster controlplane namespace, you could get it by combining %s and %s with -", hostedclusterNS, clusterName)
100100
return clusterName, hostedClusterKubeconfigFile, hostedclusterNS
@@ -140,14 +140,14 @@ func ValidHypershiftAndGetGuestKubeConfWithNoSkip(oc *exutil.CLI) (string, strin
140140
if os.Getenv("GUEST_KUBECONFIG") != "" {
141141
e2e.Logf("the kubeconfig you set GUEST_KUBECONFIG must be that of the guestcluster %s in namespace %s", clusterName, hostedclusterNS)
142142
hostedClusterKubeconfigFile = os.Getenv("GUEST_KUBECONFIG")
143-
e2e.Logf(fmt.Sprintf("use a known hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile))
143+
e2e.Logf("use a known hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile)
144144
} else {
145145
hostedClusterKubeconfigFile = "/tmp/guestcluster-kubeconfig-" + clusterName + "-" + GetRandomString()
146146
output, err := exec.Command("bash", "-c", fmt.Sprintf("hypershift create kubeconfig --name %s --namespace %s > %s",
147147
clusterName, hostedclusterNS, hostedClusterKubeconfigFile)).Output()
148148
e2e.Logf("the cmd output: %s", string(output))
149149
o.Expect(err).NotTo(o.HaveOccurred())
150-
e2e.Logf(fmt.Sprintf("create a new hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile))
150+
e2e.Logf("create a new hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile)
151151
}
152152
e2e.Logf("if you want hostedcluster controlplane namespace, you could get it by combining %s and %s with -", hostedclusterNS, clusterName)
153153
return clusterName, hostedClusterKubeconfigFile, hostedclusterNS

test/extended/util/compat_otp/jenkins/ref.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/xml"
66
"fmt"
77
"io/ioutil"
8+
"net"
89
"net/url"
910
"os"
1011
"regexp"
@@ -20,6 +21,7 @@ import (
2021
e2e "k8s.io/kubernetes/test/e2e/framework"
2122

2223
buildv1 "github.com/openshift/api/build/v1"
24+
2325
exutil "github.com/openshift/origin/test/extended/util"
2426
exurl "github.com/openshift/origin/test/extended/util/compat_otp/url"
2527
)
@@ -89,7 +91,7 @@ func (j *JenkinsRef) Namespace() string {
8991
// BuildURI builds a URI for the Jenkins server.
9092
func (j *JenkinsRef) BuildURI(resourcePathFormat string, a ...interface{}) string {
9193
resourcePath := fmt.Sprintf(resourcePathFormat, a...)
92-
return fmt.Sprintf("http://%s:%v/%s", j.host, j.port, resourcePath)
94+
return fmt.Sprintf("http://%s/%s", net.JoinHostPort(j.host, j.port), resourcePath)
9395
}
9496

9597
// GetResource submits a GET request to this Jenkins server.
@@ -271,7 +273,7 @@ func (j *JenkinsRef) ProcessJenkinsJobUsingVars(filename, namespace string, vars
271273
e2e.Logf("problem diagnosing /tmp: %v", dbgerr)
272274
} else {
273275
for _, file := range files {
274-
e2e.Logf("found file %s under temp isdir %q mode %s", file.Name(), file.IsDir(), file.Mode().String())
276+
e2e.Logf("found file %s under temp isdir %t mode %s", file.Name(), file.IsDir(), file.Mode().String())
275277
}
276278
}
277279
}
@@ -333,7 +335,7 @@ func (j *JenkinsRef) GetJobConsoleLogsAndMatchViaBuildResult(br *exutil.BuildRes
333335
return "", err
334336
}
335337
bldURI = strings.Trim(url.Path, "/")
336-
return j.WaitForContent(match, 200, 10*time.Minute, bldURI)
338+
return j.WaitForContent(match, 200, 10*time.Minute, "%s", bldURI)
337339
}
338340
return "", fmt.Errorf("build %#v is missing the build uri annontation", br.Build)
339341
}
@@ -476,7 +478,7 @@ func DumpLogs(oc *exutil.CLI, t *exutil.BuildResult) (string, error) {
476478
return "", err
477479
}
478480
jenkinsRef := NewRef(oc)
479-
log, _, err := jenkinsRef.GetResource(jenkinsLogURL.Path)
481+
log, _, err := jenkinsRef.GetResource("%s", jenkinsLogURL.Path)
480482
if err != nil {
481483
return "", fmt.Errorf("cannot get jenkins log: %v", err)
482484
}

test/extended/util/compat_otp/logext/log.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package logext
22

3-
43
/*
54
65
*/

test/extended/util/compat_otp/nfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func SetupK8SNFSServerAndVolume(oc *exutil.CLI, count int) (*kapiv1.Pod, []*kapi
5252
pvs := []*kapiv1.PersistentVolume{}
5353
volLabel := labels.Set{e2epv.VolumeSelectorKey: oc.Namespace()}
5454
for i := 0; i < count; i++ {
55-
e2e.Logf(fmt.Sprintf("Creating persistent volume %d", i))
55+
e2e.Logf("Creating persistent volume %d", i)
5656
pvConfig := e2epv.PersistentVolumeConfig{
5757
NamePrefix: "nfs-",
5858
Labels: volLabel,

0 commit comments

Comments
 (0)