Skip to content

Commit 4a2ec48

Browse files
Reenable go linters (#181)
1 parent 16cfaa3 commit 4a2ec48

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed

.golangci.yaml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,34 @@ linters:
88
settings:
99
revive:
1010
rules:
11+
# recommended rules https://github.com/mgechev/revive/tree/v1.9.0?tab=readme-ov-file#recommended-configuration
12+
- name: blank-imports
13+
- name: context-as-argument
14+
- name: context-keys-type
1115
- name: dot-imports
12-
disabled: true
13-
- name: indent-error-flow
14-
disabled: true
15-
- name: package-comments
16-
disabled: true
16+
arguments:
17+
- allowedPackages:
18+
- github.com/onsi/ginkgo
19+
- github.com/onsi/gomega
20+
- github.com/onsi/ginkgo/extensions/table
21+
- name: error-return
22+
- name: error-strings
23+
- name: error-naming
24+
- name: exported
25+
arguments:
26+
- disableStutteringCheck
27+
- name: increment-decrement
28+
- name: var-naming
29+
- name: var-declaration
30+
# - name: package-comments
31+
- name: range
32+
- name: receiver-naming
33+
- name: time-naming
34+
- name: unexported-return
35+
# - name: indent-error-flow
36+
- name: errorf
37+
- name: empty-block
38+
- name: superfluous-else
39+
- name: unused-parameter
40+
- name: unreachable-code
41+
- name: redefines-builtin-id

apis/authentication/v1alpha1/openidconnect_webhook_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ import (
1212
. "github.com/onsi/gomega"
1313
"k8s.io/utils/ptr"
1414

15-
. "github.com/gardener/oidc-webhook-authenticator/apis/authentication/v1alpha1"
15+
authenticationv1alpha1 "github.com/gardener/oidc-webhook-authenticator/apis/authentication/v1alpha1"
1616
)
1717

1818
var _ = Describe("OpenidconnectWebhook", func() {
1919
var (
20-
oidc OpenIDConnect
21-
systemPrefix = SystemPrefix
20+
oidc authenticationv1alpha1.OpenIDConnect
21+
systemPrefix = authenticationv1alpha1.SystemPrefix
2222
)
2323

2424
BeforeEach(func() {
25-
oidc = OpenIDConnect{}
25+
oidc = authenticationv1alpha1.OpenIDConnect{}
2626
})
2727

2828
Context("defaulting", func() {
@@ -51,14 +51,14 @@ var _ = Describe("OpenidconnectWebhook", func() {
5151
It("should default supported signing algs", func() {
5252
oidc.Default()
5353
Expect(len(oidc.Spec.SupportedSigningAlgs)).To(Equal(1))
54-
Expect(oidc.Spec.SupportedSigningAlgs[0]).To(Equal(RS256))
54+
Expect(oidc.Spec.SupportedSigningAlgs[0]).To(Equal(authenticationv1alpha1.RS256))
5555
})
5656

5757
It("should not default supported signing algs if explicitly set", func() {
58-
oidc.Spec.SupportedSigningAlgs = []SigningAlgorithm{RS256, RS512}
58+
oidc.Spec.SupportedSigningAlgs = []authenticationv1alpha1.SigningAlgorithm{authenticationv1alpha1.RS256, authenticationv1alpha1.RS512}
5959
oidc.Default()
6060
Expect(len(oidc.Spec.SupportedSigningAlgs)).To(Equal(2))
61-
Expect(oidc.Spec.SupportedSigningAlgs).To(ConsistOf(RS256, RS512))
61+
Expect(oidc.Spec.SupportedSigningAlgs).To(ConsistOf(authenticationv1alpha1.RS256, authenticationv1alpha1.RS512))
6262
})
6363
})
6464

@@ -77,8 +77,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
7777
})
7878

7979
It("should return error for supported signing algorithms that are not allowed", func() {
80-
oidc.Spec.SupportedSigningAlgs = []SigningAlgorithm{
81-
RS256,
80+
oidc.Spec.SupportedSigningAlgs = []authenticationv1alpha1.SigningAlgorithm{
81+
authenticationv1alpha1.RS256,
8282
"deprecated1",
8383
"deprecated2",
8484
}
@@ -178,8 +178,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
178178
})
179179

180180
It("should not return error if new oidc object is valid", func() {
181-
newObj := OpenIDConnect{
182-
Spec: OIDCAuthenticationSpec{
181+
newObj := authenticationv1alpha1.OpenIDConnect{
182+
Spec: authenticationv1alpha1.OIDCAuthenticationSpec{
183183
IssuerURL: "https://secure2.com",
184184
ClientID: "some-id",
185185
},
@@ -190,8 +190,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
190190
})
191191

192192
It("should return error if new oidc object is not valid", func() {
193-
newObj := OpenIDConnect{
194-
Spec: OIDCAuthenticationSpec{
193+
newObj := authenticationv1alpha1.OpenIDConnect{
194+
Spec: authenticationv1alpha1.OIDCAuthenticationSpec{
195195
IssuerURL: "http://notsecure.com",
196196
ClientID: "some-id",
197197
},
@@ -205,8 +205,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
205205
DescribeTable("should not allow username prefix to start with 'system:'",
206206
func(maliciousPrefix string) {
207207
errMessageTemplate := "usernamePrefix: Invalid value: \"%s\": must not start with system:"
208-
newObj := OpenIDConnect{
209-
Spec: OIDCAuthenticationSpec{
208+
newObj := authenticationv1alpha1.OpenIDConnect{
209+
Spec: authenticationv1alpha1.OIDCAuthenticationSpec{
210210
IssuerURL: "https://secure2.com",
211211
ClientID: "some-id",
212212
UsernamePrefix: &maliciousPrefix,
@@ -224,8 +224,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
224224

225225
DescribeTable("should allow username prefix if it does not start with 'system:'",
226226
func(validPrefix string) {
227-
newObj := OpenIDConnect{
228-
Spec: OIDCAuthenticationSpec{
227+
newObj := authenticationv1alpha1.OpenIDConnect{
228+
Spec: authenticationv1alpha1.OIDCAuthenticationSpec{
229229
IssuerURL: "https://secure2.com",
230230
ClientID: "some-id",
231231
UsernamePrefix: &validPrefix,
@@ -246,8 +246,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
246246
DescribeTable("should not allow groups prefix to start with 'system:'",
247247
func(maliciousPrefix string) {
248248
errMessageTemplate := "groupsPrefix: Invalid value: \"%s\": must not start with system:"
249-
newObj := OpenIDConnect{
250-
Spec: OIDCAuthenticationSpec{
249+
newObj := authenticationv1alpha1.OpenIDConnect{
250+
Spec: authenticationv1alpha1.OIDCAuthenticationSpec{
251251
IssuerURL: "https://secure2.com",
252252
ClientID: "some-id",
253253
GroupsPrefix: &maliciousPrefix,
@@ -265,8 +265,8 @@ var _ = Describe("OpenidconnectWebhook", func() {
265265

266266
DescribeTable("should allow groups prefix if it does not start with 'system:'",
267267
func(validPrefix string) {
268-
newObj := OpenIDConnect{
269-
Spec: OIDCAuthenticationSpec{
268+
newObj := authenticationv1alpha1.OpenIDConnect{
269+
Spec: authenticationv1alpha1.OIDCAuthenticationSpec{
270270
IssuerURL: "https://secure2.com",
271271
ClientID: "some-id",
272272
GroupsPrefix: &validPrefix,

0 commit comments

Comments
 (0)