Skip to content

Commit fe0ef02

Browse files
committed
Fix golangci-lint issues
Signed-off-by: Erik Godding Boye <[email protected]>
1 parent 97607f5 commit fe0ef02

File tree

11 files changed

+37
-33
lines changed

11 files changed

+37
-33
lines changed

internal/pki/csr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func EncodeX509(cert *x509.Certificate) ([]byte, error) {
114114
func signatureAlgorithmFromPublicKey(alg x509.PublicKeyAlgorithm, arg any) (x509.SignatureAlgorithm, error) {
115115
var signatureAlgorithm x509.SignatureAlgorithm
116116

117-
switch alg {
117+
switch alg { //nolint:exhaustive // There is a default that appears to be not picked up by the linter
118118
case x509.RSA:
119119
size, ok := arg.(int)
120120
if !ok {

pkg/authority/api/api.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ const (
2424
// `inject-dynamic-ca-from-secret` label.
2525
// If an injectable references a Secret that does NOT have this annotation,
2626
// the dynamic ca-injector will refuse to inject the secret.
27-
DynamicAuthoritySecretLabel = "cert-manager.io/allow-dynamic-ca-injection"
27+
DynamicAuthoritySecretLabel = "cert-manager.io/allow-dynamic-ca-injection" //#nosec G101 - This is not credentials
2828
// WantInjectFromSecretNamespaceLabel is the label that specifies that a
2929
// particular object wants injection of dynamic CAs from secret in
3030
// namespace.
3131
// Must be used in conjunction with WantInjectFromSecretNameLabel.
32-
WantInjectFromSecretNamespaceLabel = "cert-manager.io/inject-dynamic-ca-from-secret-namespace"
32+
WantInjectFromSecretNamespaceLabel = "cert-manager.io/inject-dynamic-ca-from-secret-namespace" //#nosec G101 - This is not credentials
3333
// WantInjectFromSecretNameLabel is the label that specifies that a
3434
// particular object wants injection of dynamic CAs from secret with name.
3535
// Must be used in conjunction with WantInjectFromSecretNamespaceLabel.
36-
WantInjectFromSecretNameLabel = "cert-manager.io/inject-dynamic-ca-from-secret-name"
36+
WantInjectFromSecretNameLabel = "cert-manager.io/inject-dynamic-ca-from-secret-name" //#nosec G101 - This is not credentials
3737

3838
// TLSCABundleKey is used as a data key in Secret resources to store a CA
3939
// certificate bundle.
@@ -42,9 +42,9 @@ const (
4242
// RenewCertificateSecretAnnotation is an annotation that can be set to
4343
// an arbitrary value on a certificate secret to trigger a renewal of the
4444
// certificate managed in the secret.
45-
RenewCertificateSecretAnnotation = "renew.cert-manager.io/requestedAt"
45+
RenewCertificateSecretAnnotation = "renew.cert-manager.io/requestedAt" //#nosec G101 - This is not credentials
4646
// RenewHandledCertificateSecretAnnotation is an annotation that will be set on a
4747
// certificate secret whenever a new certificate is renewed using the
4848
// RenewCertificateSecretAnnotation annotation.
49-
RenewHandledCertificateSecretAnnotation = "renew.cert-manager.io/lastRequestedAt"
49+
RenewHandledCertificateSecretAnnotation = "renew.cert-manager.io/lastRequestedAt" //#nosec G101 - This is not credentials
5050
)

pkg/authority/authority.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ import (
2121
"errors"
2222
"time"
2323

24-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
25-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/cert"
26-
leadercontrollers "github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers"
27-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
2824
corev1 "k8s.io/api/core/v1"
2925
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3026
"k8s.io/apimachinery/pkg/fields"
3127
"k8s.io/apimachinery/pkg/labels"
3228
ctrl "sigs.k8s.io/controller-runtime"
3329
"sigs.k8s.io/controller-runtime/pkg/cache"
3430
"sigs.k8s.io/controller-runtime/pkg/client"
31+
32+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
33+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/cert"
34+
leadercontrollers "github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers"
35+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
3536
)
3637

3738
type LeafOptions struct {

pkg/authority/leader_controllers/ca_secret_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto"
2222
"crypto/x509"
2323

24+
"github.com/go-logr/logr"
2425
corev1 "k8s.io/api/core/v1"
2526
"k8s.io/apimachinery/pkg/api/errors"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -35,7 +36,6 @@ import (
3536
"github.com/cert-manager/webhook-cert-lib/internal/pki"
3637
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
3738
"github.com/cert-manager/webhook-cert-lib/pkg/authority/cert"
38-
"github.com/go-logr/logr"
3939
)
4040

4141
// CASecretReconciler reconciles a CA Secret object

pkg/authority/leader_controllers/injectable_controller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020
"context"
2121
"strings"
2222

23-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
24-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
2523
corev1 "k8s.io/api/core/v1"
2624
"k8s.io/apimachinery/pkg/api/errors"
2725
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -33,6 +31,9 @@ import (
3331
"sigs.k8s.io/controller-runtime/pkg/predicate"
3432
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3533
"sigs.k8s.io/controller-runtime/pkg/source"
34+
35+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
36+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
3637
)
3738

3839
// InjectableReconciler injects CA bundle into resources
@@ -69,11 +70,11 @@ func (r *InjectableReconciler) SetupWithManager(mgr ctrl.Manager) error {
6970
}
7071

7172
requests := make([]reconcile.Request, len(objList.Items))
72-
for _, obj := range objList.Items {
73+
for i, obj := range objList.Items {
7374
req := reconcile.Request{}
7475
req.Namespace = obj.GetNamespace()
7576
req.Name = obj.GetName()
76-
requests = append(requests, req)
77+
requests[i] = req
7778
}
7879
return requests
7980
}),

pkg/authority/leader_controllers/ssa_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ limitations under the License.
1717
package leadercontrollers
1818

1919
import (
20-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
2120
"k8s.io/apimachinery/pkg/types"
2221
"k8s.io/apimachinery/pkg/util/json"
2322
"sigs.k8s.io/controller-runtime/pkg/client"
23+
24+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
2425
)
2526

2627
const (

test/ca_secret_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ package test
1919
import (
2020
"time"
2121

22-
. "github.com/onsi/ginkgo/v2"
23-
. "github.com/onsi/gomega"
24-
2522
corev1 "k8s.io/api/core/v1"
2623
"k8s.io/apimachinery/pkg/types"
2724
"k8s.io/client-go/kubernetes/scheme"
@@ -32,6 +29,9 @@ import (
3229
"github.com/cert-manager/webhook-cert-lib/internal/pki"
3330
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
3431
leadercontrollers "github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers"
32+
33+
. "github.com/onsi/ginkgo/v2"
34+
. "github.com/onsi/gomega"
3535
)
3636

3737
var _ = Describe("CA Secret Controller", Ordered, func() {

test/injectable_controller_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ limitations under the License.
1717
package test
1818

1919
import (
20-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
21-
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
22-
. "github.com/onsi/ginkgo/v2"
23-
. "github.com/onsi/gomega"
24-
25-
leadercontrollers "github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers"
2620
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
2721
corev1 "k8s.io/api/core/v1"
2822
"k8s.io/apimachinery/pkg/types"
@@ -31,6 +25,13 @@ import (
3125
"sigs.k8s.io/controller-runtime/pkg/client"
3226
"sigs.k8s.io/controller-runtime/pkg/envtest/komega"
3327
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
28+
29+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
30+
leadercontrollers "github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers"
31+
"github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers/injectable"
32+
33+
. "github.com/onsi/ginkgo/v2"
34+
. "github.com/onsi/gomega"
3435
)
3536

3637
var _ = Describe("Injectable Controller", Ordered, func() {

test/leaf_cert_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ import (
2020
"crypto/tls"
2121
"time"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
25-
2623
corev1 "k8s.io/api/core/v1"
2724
"k8s.io/apimachinery/pkg/types"
2825
"k8s.io/client-go/kubernetes/scheme"
@@ -35,6 +32,9 @@ import (
3532
"github.com/cert-manager/webhook-cert-lib/pkg/authority/api"
3633
"github.com/cert-manager/webhook-cert-lib/pkg/authority/cert"
3734
leadercontrollers "github.com/cert-manager/webhook-cert-lib/pkg/authority/leader_controllers"
35+
36+
. "github.com/onsi/ginkgo/v2"
37+
. "github.com/onsi/gomega"
3838
)
3939

4040
var _ = Describe("Leaf Certificate Controller", Ordered, func() {

test/suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import (
2020
"context"
2121
"testing"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
25-
2623
"k8s.io/client-go/kubernetes/scheme"
2724
"k8s.io/client-go/rest"
2825
"sigs.k8s.io/controller-runtime/pkg/client"
2926
"sigs.k8s.io/controller-runtime/pkg/envtest"
3027
"sigs.k8s.io/controller-runtime/pkg/envtest/komega"
3128
logf "sigs.k8s.io/controller-runtime/pkg/log"
3229
"sigs.k8s.io/controller-runtime/pkg/log/zap"
30+
31+
. "github.com/onsi/ginkgo/v2"
32+
. "github.com/onsi/gomega"
3333
)
3434

3535
// These tests use Ginkgo (BDD-style Go testing framework). Refer to

0 commit comments

Comments
 (0)