Repository: kubernetes-sigs/security-profiles-operator
Pull request #446 (2021-05-17 10:25:40)

Update golangci-lint to v1.40.1 and fix lints
#### What type of PR is this?


/kind cleanup


#### What this PR does / why we need it:
This updates golangci-lint to the latest release and fixes new lints. It
also enables linters which do not report any issue.

#### Which issue(s) this PR fixes:

<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.

Fixes #

or

None
-->
None
#### Does this PR have test?
None
<!--
If tests aren't applicable just write N/A.
-->

#### Special notes for your reviewer:
None
#### Does this PR introduce a user-facing change?

<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".

For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->

```release-note
None
```


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-sigs/security-profiles-operator/pull/446#" title="Author self-approved">saschagrunert</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fsecurity-profiles-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes-sigs/security-profiles-operator/blob/master/OWNERS)~~ [saschagrunert]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
JAORMX: /lgtm
k8s-ci-robot: New changes are detected. LGTM label has been removed.
saschagrunert: Had to rebase because of the e2e test and metrics name change (suffixed now with `_total`).
JAORMX: /lgtm

Patch:
diff --git a/.golangci.yml b/.golangci.yml
index 46167ae76..e64b6c38b 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -30,8 +30,8 @@ linters:
     - gofumpt
     - goheader
     - goimports
-    - golint
     - gomnd
+    - gomoddirectives
     - gomodguard
     - goprintffuncname
     - gosec
@@ -50,12 +50,13 @@ linters:
     - paralleltest
     - prealloc
     - predeclared
+    - promlinter
     - rowserrcheck
-    - scopelint
     - sqlclosecheck
     - staticcheck
     - structcheck
     - stylecheck
+    - tagliatelle
     - thelper
     - tparallel
     - typecheck
@@ -65,7 +66,7 @@ linters:
     - varcheck
     - wastedassign
     - whitespace
-    - wrapcheck
+    # - wrapcheck
     # - cyclop
     # - exhaustivestruct
     # - forbidigo
diff --git a/Makefile b/Makefile
index 67899044c..0d6ca35dd 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@
 
 GO ?= go
 
-GOLANGCI_LINT_VERSION = v1.38.0
+GOLANGCI_LINT_VERSION = v1.40.1
 REPO_INFRA_VERSION = v0.1.6
 KUSTOMIZE_VERSION = 4.1.2
 
diff --git a/dependencies.yaml b/dependencies.yaml
index 04a805b99..e612a32f7 100644
--- a/dependencies.yaml
+++ b/dependencies.yaml
@@ -1,6 +1,6 @@
 dependencies:
   - name: golangci-lint
-    version: 1.38.0
+    version: 1.40.1
     refPaths:
     - path: Makefile
       match: GOLANGCI_LINT_VERSION = v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?
diff --git a/internal/pkg/daemon/metrics/metrics.go b/internal/pkg/daemon/metrics/metrics.go
index 3b9e209ae..6e9ccbcd3 100644
--- a/internal/pkg/daemon/metrics/metrics.go
+++ b/internal/pkg/daemon/metrics/metrics.go
@@ -33,7 +33,7 @@ import (
 
 const (
 	metricNamespace                      = "security_profiles_operator"
-	metricNameSeccompProfile             = "seccomp_profile"
+	metricNameSeccompProfile             = "seccomp_profile_total"
 	metricLabelValueSeccompProfileUpdate = "update"
 	metricLabelValueSeccompProfileDelete = "delete"
 	metricLabelOperation                 = "operation"
diff --git a/internal/pkg/manager/workloadannotator/workloadannotator.go b/internal/pkg/manager/workloadannotator/workloadannotator.go
index 3bfa2bee7..b9276e8c3 100644
--- a/internal/pkg/manager/workloadannotator/workloadannotator.go
+++ b/internal/pkg/manager/workloadannotator/workloadannotator.go
@@ -172,7 +172,8 @@ func getSeccompProfilesFromPod(pod *corev1.Pod) []string {
 		profiles = append(profiles, *sc.SeccompProfile.LocalhostProfile)
 	}
 	// try to get profile(s) from securityContext in pods
-	containers := append(pod.Spec.Containers, pod.Spec.InitContainers...)
+	containers := pod.Spec.Containers
+	containers = append(containers, pod.Spec.InitContainers...)
 	contains := func(a []string, b string) bool {
 		for _, s := range a {
 			if s == b {


Test patch:
diff --git a/test/tc_metrics_test.go b/test/tc_metrics_test.go
index d1fdeb6a6..8c0b508b3 100644
--- a/test/tc_metrics_test.go
+++ b/test/tc_metrics_test.go
@@ -32,8 +32,8 @@ func (e *e2e) testCaseMetrics(nodes []string) {
 		curlSpodCMD     = curlCMD + metricsURL + "metrics-spod"
 		curlCtrlCMD     = curlCMD + metricsURL + "metrics"
 		profileName     = "metrics-profile"
-		operationDelete = `security_profiles_operator_seccomp_profile{operation="delete"}`
-		operationUpdate = `security_profiles_operator_seccomp_profile{operation="update"}`
+		operationDelete = `security_profiles_operator_seccomp_profile_total{operation="delete"}`
+		operationUpdate = `security_profiles_operator_seccomp_profile_total{operation="update"}`
 	)
 
 	e.logf("Retrieving spo metrics for getting assertions")