Skip to content

Commit 43682f9

Browse files
committed
Fix golint errors πŸ‘¨β€πŸ³
Signed-off-by: Vincent Demeester <[email protected]>
1 parent ed125c9 commit 43682f9

File tree

9 files changed

+40
-43
lines changed

9 files changed

+40
-43
lines changed

β€Žpkg/artifacts/artifacts_storage.goβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ func ConfigMapNeedsPVC(configMap *corev1.ConfigMap, err error, logger *zap.Sugar
189189
logger.Warn("the configmap has no data")
190190
return true, nil
191191
}
192-
if location, ok := configMap.Data[BucketLocationKey]; !ok {
192+
location, ok := configMap.Data[BucketLocationKey]
193+
if !ok {
194+
return true, nil
195+
}
196+
logger.Warnf("the configmap key %q is empty", BucketLocationKey)
197+
if strings.TrimSpace(location) == "" {
193198
return true, nil
194-
} else {
195-
logger.Warnf("the configmap key %q is empty", BucketLocationKey)
196-
if strings.TrimSpace(location) == "" {
197-
return true, nil
198-
}
199199
}
200200
return false, nil
201201
}

β€Žpkg/credentials/gitcreds/ssh.goβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (dc *sshGitConfig) Set(value string) error {
6363
secretName := parts[0]
6464
url := parts[1]
6565

66-
e, err := newSshEntry(url, secretName)
66+
e, err := newSSHEnrty(url, secretName)
6767
if err != nil {
6868
return err
6969
}
@@ -143,7 +143,7 @@ func (be *sshEntry) Write(sshDir string) error {
143143
return ioutil.WriteFile(be.path(sshDir), []byte(be.privateKey), 0600)
144144
}
145145

146-
func newSshEntry(u, secretName string) (*sshEntry, error) {
146+
func newSSHEnrty(u, secretName string) (*sshEntry, error) {
147147
secretPath := credentials.VolumeName(secretName)
148148

149149
pk, err := ioutil.ReadFile(filepath.Join(secretPath, corev1.SSHAuthPrivateKey))

β€Žpkg/pod/entrypoint_lookup_test.goβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ func (f fakeCache) Get(imageName, _, _ string) ([]string, name.Digest, error) {
9191

9292
d, found := f[imageName]
9393
if !found {
94-
return nil, name.Digest{}, fmt.Errorf("Image %q not found", imageName)
94+
return nil, name.Digest{}, fmt.Errorf("image %q not found", imageName)
9595
}
9696
if d.seen {
97-
return nil, name.Digest{}, fmt.Errorf("Image %q was already looked up!", imageName)
97+
return nil, name.Digest{}, fmt.Errorf("image %q was already looked up", imageName)
9898
}
9999
d.seen = true
100100
dig, err := name.NewDigest(ref.Context().RepositoryStr()+"@"+d.digest, name.WeakValidation)

β€Žpkg/reconciler/pipelinerun/pipelinerun_test.goβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ func getRunName(pr *v1alpha1.PipelineRun) string {
6464

6565
// getPipelineRunController returns an instance of the PipelineRun controller/reconciler that has been seeded with
6666
// d, where d represents the state of the system (existing resources) needed for the test.
67-
func getPipelineRunController(t *testing.T, d test.Data) (test.TestAssets, func()) {
67+
func getPipelineRunController(t *testing.T, d test.Data) (test.Assets, func()) {
6868
ctx, _ := ttesting.SetupFakeContext(t)
6969
c, _ := test.SeedTestData(t, ctx, d)
7070
configMapWatcher := configmap.NewInformedWatcher(c.Kube, system.GetNamespace())
7171
ctx, cancel := context.WithCancel(ctx)
72-
return test.TestAssets{
72+
return test.Assets{
7373
Controller: NewController(images)(ctx, configMapWatcher),
7474
Clients: c,
7575
}, cancel

β€Žpkg/reconciler/taskrun/taskrun_test.goβ€Ž

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const (
5555
taskNameLabelKey = pipeline.GroupName + pipeline.TaskLabelKey
5656
taskRunNameLabelKey = pipeline.GroupName + pipeline.TaskRunLabelKey
5757
workspaceDir = "/workspace"
58-
currentApiVersion = "tekton.dev/v1alpha1"
58+
currentAPIVersion = "tekton.dev/v1alpha1"
5959
)
6060

6161
var (
@@ -237,7 +237,7 @@ func getRunName(tr *v1alpha1.TaskRun) string {
237237

238238
// getTaskRunController returns an instance of the TaskRun controller/reconciler that has been seeded with
239239
// d, where d represents the state of the system (existing resources) needed for the test.
240-
func getTaskRunController(t *testing.T, d test.Data) (test.TestAssets, func()) {
240+
func getTaskRunController(t *testing.T, d test.Data) (test.Assets, func()) {
241241
ctx, _ := ttesting.SetupFakeContext(t)
242242
ctx, cancel := context.WithCancel(ctx)
243243
cloudEventClientBehaviour := cloudevent.FakeClientBehaviour{
@@ -246,7 +246,7 @@ func getTaskRunController(t *testing.T, d test.Data) (test.TestAssets, func()) {
246246
ctx = cloudevent.WithClient(ctx, &cloudEventClientBehaviour)
247247
c, _ := test.SeedTestData(t, ctx, d)
248248
configMapWatcher := configmap.NewInformedWatcher(c.Kube, system.GetNamespace())
249-
return test.TestAssets{
249+
return test.Assets{
250250
Controller: NewController(images)(ctx, configMapWatcher),
251251
Clients: c,
252252
}, cancel
@@ -286,7 +286,7 @@ func TestReconcile_ExplicitDefaultSA(t *testing.T) {
286286
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-run-success"),
287287
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
288288
tb.PodOwnerReference("TaskRun", "test-taskrun-run-success",
289-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
289+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
290290
tb.PodSpec(
291291
tb.PodServiceAccountName(defaultSAName),
292292
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
@@ -321,7 +321,7 @@ func TestReconcile_ExplicitDefaultSA(t *testing.T) {
321321
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-with-sa-run-success"),
322322
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
323323
tb.PodOwnerReference("TaskRun", "test-taskrun-with-sa-run-success",
324-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
324+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
325325
tb.PodSpec(
326326
tb.PodServiceAccountName("test-sa"),
327327
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
@@ -540,7 +540,7 @@ func TestReconcile(t *testing.T) {
540540
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-run-success"),
541541
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
542542
tb.PodOwnerReference("TaskRun", "test-taskrun-run-success",
543-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
543+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
544544
tb.PodSpec(
545545
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
546546
tb.PodRestartPolicy(corev1.RestartPolicyNever),
@@ -574,7 +574,7 @@ func TestReconcile(t *testing.T) {
574574
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-with-sa-run-success"),
575575
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
576576
tb.PodOwnerReference("TaskRun", "test-taskrun-with-sa-run-success",
577-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
577+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
578578
tb.PodSpec(
579579
tb.PodServiceAccountName("test-sa"),
580580
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
@@ -609,7 +609,7 @@ func TestReconcile(t *testing.T) {
609609
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-substitution"),
610610
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
611611
tb.PodOwnerReference("TaskRun", "test-taskrun-substitution",
612-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
612+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
613613
tb.PodSpec(
614614
tb.PodVolumes(
615615
workspaceVolume, homeVolume, toolsVolume, downwardVolume,
@@ -683,7 +683,7 @@ func TestReconcile(t *testing.T) {
683683
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-with-taskspec"),
684684
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
685685
tb.PodOwnerReference("TaskRun", "test-taskrun-with-taskspec",
686-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
686+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
687687
tb.PodSpec(
688688
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
689689
tb.PodRestartPolicy(corev1.RestartPolicyNever),
@@ -735,7 +735,7 @@ func TestReconcile(t *testing.T) {
735735
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-with-cluster-task"),
736736
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
737737
tb.PodOwnerReference("TaskRun", "test-taskrun-with-cluster-task",
738-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
738+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
739739
tb.PodSpec(
740740
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
741741
tb.PodRestartPolicy(corev1.RestartPolicyNever),
@@ -768,7 +768,7 @@ func TestReconcile(t *testing.T) {
768768
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-with-resource-spec"),
769769
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
770770
tb.PodOwnerReference("TaskRun", "test-taskrun-with-resource-spec",
771-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
771+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
772772
tb.PodSpec(
773773
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
774774
tb.PodRestartPolicy(corev1.RestartPolicyNever),
@@ -818,7 +818,7 @@ func TestReconcile(t *testing.T) {
818818
tb.PodLabel(taskRunNameLabelKey, "test-taskrun-with-pod"),
819819
tb.PodLabel(podconvert.ManagedByLabelKey, podconvert.ManagedByLabelValue),
820820
tb.PodOwnerReference("TaskRun", "test-taskrun-with-pod",
821-
tb.OwnerReferenceAPIVersion(currentApiVersion)),
821+
tb.OwnerReferenceAPIVersion(currentAPIVersion)),
822822
tb.PodSpec(
823823
tb.PodVolumes(workspaceVolume, homeVolume, toolsVolume, downwardVolume),
824824
tb.PodRestartPolicy(corev1.RestartPolicyNever),

β€Žpkg/reconciler/taskrun/timeout_check.goβ€Ž

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,5 @@ func CheckTimeout(tr *v1alpha1.TaskRun) bool {
3535
return false
3636
}
3737
runtime := time.Since(tr.Status.StartTime.Time)
38-
if runtime > timeout {
39-
return true
40-
} else {
41-
return false
42-
}
38+
return runtime > timeout
4339
}

β€Žpkg/reconciler/timeout_handler.goβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ type StatusKey interface {
4545
GetRunKey() string
4646
}
4747

48-
// backoff contains state of exponential backoff for a given StatusKey
49-
type backoff struct {
48+
// Backoff contains state of exponential backoff for a given StatusKey
49+
type Backoff struct {
5050
// NumAttempts reflects the number of times a given StatusKey has been delayed
5151
NumAttempts uint
5252
// NextAttempt is the point in time at which this backoff expires
@@ -66,7 +66,7 @@ type TimeoutSet struct {
6666
stopCh <-chan struct{}
6767
done map[string]chan bool
6868
doneMut sync.Mutex
69-
backoffs map[string]backoff
69+
backoffs map[string]Backoff
7070
backoffsMut sync.Mutex
7171
}
7272

@@ -78,7 +78,7 @@ func NewTimeoutHandler(
7878
return &TimeoutSet{
7979
stopCh: stopCh,
8080
done: make(map[string]chan bool),
81-
backoffs: make(map[string]backoff),
81+
backoffs: make(map[string]Backoff),
8282
logger: logger,
8383
}
8484
}
@@ -135,14 +135,14 @@ func (t *TimeoutSet) getOrCreateFinishedChan(runObj StatusKey) chan bool {
135135
// describing the time at which the next attempt should be performed.
136136
// Additionally a boolean is returned indicating whether a backoff for the
137137
// TaskRun is already in progress.
138-
func (t *TimeoutSet) GetBackoff(tr *v1alpha1.TaskRun) (backoff, bool) {
138+
func (t *TimeoutSet) GetBackoff(tr *v1alpha1.TaskRun) (Backoff, bool) {
139139
t.backoffsMut.Lock()
140140
defer t.backoffsMut.Unlock()
141141
b := t.backoffs[tr.GetRunKey()]
142142
if time.Now().Before(b.NextAttempt) {
143143
return b, true
144144
}
145-
b.NumAttempts += 1
145+
b.NumAttempts++
146146
b.NextAttempt = time.Now().Add(backoffDuration(b.NumAttempts, rand.Intn))
147147
timeoutDeadline := tr.Status.StartTime.Time.Add(tr.Spec.Timeout.Duration)
148148
if timeoutDeadline.Before(b.NextAttempt) {

β€Žtest/controller.goβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ type Informers struct {
7272
Pod coreinformers.PodInformer
7373
}
7474

75-
// TestAssets holds references to the controller, logs, clients, and informers.
76-
type TestAssets struct {
75+
// Assets holds references to the controller, logs, clients, and informers.
76+
type Assets struct {
7777
Controller *controller.Impl
7878
Clients Clients
7979
}
8080

8181
// SeedTestData returns Clients and Informers populated with the
8282
// given Data.
83+
// nolint: golint
8384
func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers) {
8485
c := Clients{
8586
Kube: fakekubeclient.Get(ctx),

β€Žtest/helm_task_test.goβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ func TestHelmDeployPipelineRun(t *testing.T) {
9999
}
100100

101101
t.Log("Waiting for service to get external IP")
102-
var serviceIp string
102+
var serviceIP string
103103
if err := WaitForServiceExternalIPState(c, namespace, helmDeployServiceName, func(svc *corev1.Service) (bool, error) {
104104
ingress := svc.Status.LoadBalancer.Ingress
105105
if ingress != nil {
106106
if len(ingress) > 0 {
107-
serviceIp = ingress[0].IP
107+
serviceIP = ingress[0].IP
108108
return true, nil
109109
}
110110
}
@@ -117,20 +117,20 @@ func TestHelmDeployPipelineRun(t *testing.T) {
117117
knativetest.CleanupOnInterrupt(func() { helmCleanup(c, t, namespace) }, t.Logf)
118118
defer helmCleanup(c, t, namespace)
119119

120-
if serviceIp != "" {
120+
if serviceIP != "" {
121121
t.Log("Polling service with external IP")
122122
waitErr := wait.PollImmediate(100*time.Millisecond, 30*time.Second, func() (bool, error) {
123-
resp, err := http.Get(fmt.Sprintf("http://%s:8080", serviceIp))
123+
resp, err := http.Get(fmt.Sprintf("http://%s:8080", serviceIP))
124124
if err != nil {
125125
return false, nil
126126
}
127127
if resp != nil && resp.StatusCode != http.StatusOK {
128-
return true, xerrors.Errorf("Expected 200 but received %d response code from service at http://%s:8080", resp.StatusCode, serviceIp)
128+
return true, xerrors.Errorf("Expected 200 but received %d response code from service at http://%s:8080", resp.StatusCode, serviceIP)
129129
}
130130
return true, nil
131131
})
132132
if waitErr != nil {
133-
t.Errorf("Error from pinging service IP %s : %s", serviceIp, waitErr)
133+
t.Errorf("Error from pinging service IP %s : %s", serviceIP, waitErr)
134134
}
135135

136136
} else {

0 commit comments

Comments
Β (0)