๐Ÿ“ฆ Kong / kong-operator

๐Ÿ“„ .golangci.yaml ยท 298 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298version: "2"
run:
  timeout: 8m
  build-tags:
    - integration_tests
    - e2e_tests
    - istio_tests
    - envtest
    - performance_tests
linters:
  enable:
    - asciicheck
    - bodyclose
    - copyloopvar
    - dogsled
    - durationcheck
    - errorlint
    - exhaustive
    - forbidigo
    - gocritic
    - godoclint
    - gomodguard
    - gosec
    - importas
    - loggercheck
    - misspell
    - nakedret
    - nilerr
    - nolintlint
    - predeclared
    - revive
    # Uncomment or remove - TODO: https://github.com/Kong/kong-operator/issues/1847
    # - testifylint
    - unconvert
    - unused
    - unparam
    - usetesting
    - wastedassign
  settings:
    godoclint:
      default: all
      disable:
        - require-pkg-doc
        - start-with-name
      options:
        max-len:
          # Maximum line length for godocs, not including the `// `, or `/*` or `*/` tokens.
          length: 140
    staticcheck:
      checks:
        - all
        # Incorrect or missing package comment.
        # https://staticcheck.dev/docs/checks/#ST1000
        - -ST1000
        # Incorrectly formatted error string.
        # https://staticcheck.dev/docs/checks/#ST1005
        - -ST1005
        # Underscore in the name of a package.
        # https://staticcheck.dev/docs/checks/#ST1003
        - -ST1003
    exhaustive:
      default-signifies-exhaustive: true
    forbidigo:
      forbid:
        # Uncomment or remove - TODO: https://github.com/Kong/kong-operator/issues/1847
        # - pattern: ^.*Dataplane[^G].*$
        #   msg: Please use camel case 'DataPlane' instead of 'Dataplane'
        - pattern: ^.*Controlplane.*$
          msg: Please use camel case 'ControlPlane' instead of 'Controlplane'
        - pattern: ^.*operatorv1beta1.ControlPlane.*$
          msg: Please use v2beta1 ControlPlane (through github.com/kong/kong-operator/internal/types)
        # NOTE: When all references use the types package, this rule can use .* instead of listing types.
        - pattern: ^.*operatorv2alpha1.ControlPlane.*$
          msg: Please use the types package to refer to the type (through github.com/kong/kong-operator/internal/types)
    gomodguard:
      blocked:
        modules:
          - golang.org/x/exp:
              recommendations:
                - maps
                - slices
                - github.com/samber/lo
          - github.com/pkg/errors:
              recommendations:
                - fmt
                - errors
          - github.com/sirupsen/logrus:
              recommendations:
                - sigs.k8s.io/controller-runtime/pkg/log
                - go.uber.org/zap/zapcore
    govet:
      disable:
        - fieldalignment
        - shadow
      enable-all: true
    importas:
      alias:
        - pkg: k8s.io/api/([a-z])/(v[\w\d]+)
          alias: ${1}${2}
        - pkg: k8s.io/apimachinery/pkg/apis/meta/v1
          alias: metav1
        - pkg: k8s.io/apimachinery/pkg/watch
          alias: apiwatch
        - pkg: sigs.k8s.io/gateway-api/apis/(v[\w\d]+)
          alias: gateway${1}
        - pkg: sigs.k8s.io/controller-runtime/pkg/log
          alias: ctrllog
        - pkg: github.com/Kong/sdk-konnect-go/models/components
          alias: sdkkonnectcomp
        - pkg: github.com/Kong/sdk-konnect-go/models/operations
          alias: sdkkonnectops
        - pkg: github.com/Kong/sdk-konnect-go/models/sdkerrors
          alias: sdkkonnecterrs
        - pkg: github.com/kong/kong-operator/controller/konnect/ops/sdk
          alias: sdkops
        - pkg: github.com/kong/kong-operator/controller/konnect/ops/sdk/mocks
          alias: sdkmocks
        - pkg: github.com/kong/kong-operator/internal/types
          alias: gwtypes
        - pkg: github.com/kong/kong-operator/pkg/utils/kubernetes
          alias: k8sutils
        - pkg: github.com/kong/kong-operator/pkg/utils/kubernetes/resources
          alias: k8sresources
      no-unaliased: true
    revive:
      rules:
        - name: errorf
          severity: warning
          disabled: false
        - name: error-strings
          severity: warning
          disabled: false
        - name: error-naming
          severity: warning
          disabled: false
        - name: duplicated-imports
          severity: warning
          disabled: false
        - name: empty-block
          severity: warning
          disabled: false
        - name: exported
          arguments:
            - checkPrivateReceivers
            - disableStutteringCheck
          severity: warning
          disabled: false
        - name: context-as-argument
          disabled: true
    testifylint:
      enable-all: true
      disable:
        - error-is-as
    usetesting:
      os-temp-dir: true
  exclusions:
    generated: lax
    presets:
      - common-false-positives
      - legacy
      - std-error-handling
    rules:
      - linters:
          - revive
        # pkg/|test/ has been added, see TODO: https://github.com/Kong/kong-operator/issues/1847
        path: internal/|pkg/|test/
        text: 'exported: exported'
      - linters:
          - revive
        path: test/integration
        text: 'exported: exported'
      - linters:
          - revive
        path: test/e2e
        text: 'exported: exported'
      - linters:
          - revive
        path: controller/konnect/ops/.*_mock\.go
        text: 'exported: exported'
      - linters:
          - forbidigo
        text: use of `.*(Create|Delete)Dataplane.+` forbidden because "Please use camel case
      - linters:
          - gosec
        path: .*_test\.go
        text: Use of weak random number generator
      # Remove/adjust whole section - TODO: https://github.com/Kong/kong-operator/issues/1847
      - linters:
          - gosec
        path: .*_test\.go
        text: Potential hardcoded credentials
      - linters:
          - gosec
        path: .*_test\.go
        text: Potential HTTP request made with variable url
      - linters:
          - gosec
        text: integer overflow conversion
      - linters:
          - forbidigo
        path: internal/types/operatortypes.go
        text: use of `operatorv2beta1.(ControlPlane\w*)` forbidden
      - linters:
          - forbidigo
        path: api/test
        text: use of `operatorv1beta1.(ControlPlane\w*)` forbidden
      - linters:
          - forbidigo
        path: test/crdsvalidation/gateway-operator.konghq.com/controlplane_test.go
        text: use of `operatorv1beta1.(ControlPlane\w*)` forbidden
      - linters:
          - godoclint
        path: .*/zz_generated.*\.go
        text: godoc line is too long
      # Cannot configure godoclint to ignore +kubebuilder comments.
      # Ref: https://github.com/godoc-lint/godoc-lint/issues/80
      - linters:
          - godoclint
        path: api/(configuration|gateway-operator|konnect|common)/.*\.go
        text: godoc line is too long
      - linters:
          - godoclint
        path: scripts/.*\.go
        text: godoc line is too long
      - linters:
          - godoclint
        path: internal/types/operatortypes.go
        text: godoc line is too long
      - linters:
          - godoclint
        path: controller/controlplane/controller_consts.go
        text: godoc line is too long
      - linters:
          - godoclint
        path: internal/utils/index/.*\.go
        text: godoc line is too long
      - linters:
          - godoclint
        path: .*_test\.go
        text: symbol should have a godoc
      - linters:
          - godoclint
        path: internal/(types/gatewaytypes.go|telemetry)
        text: symbol should have a godoc
      - linters:
          - godoclint
        path: ingress-controller/internal/(metrics|admission|konnect|util|manager|dataplane|annotations|gatewayapi/aliases\.go|gatewayapi|controllers|clients|store|adminapi|license|diagnostics)
        text: symbol should have a godoc
      - linters:
          - godoclint
        path: ingress-controller/pkg/(manager|telemetry)
        text: symbol should have a godoc
      - linters:
          - godoclint
        path: ingress-controller/test/(consts\.go|envtest|mocks|internal|helpers|integration/isolated|kongintegration)
        text: symbol should have a godoc
      - linters:
          - godoclint
        path: test/(mocks|helpers|integration/utils.go)
        text: symbol should have a godoc
      - linters:
          - godoclint
        path: controller/konnect/ops/
        text: symbol should have a godoc
      # No need to document the sort, error or stringer interface methods.
      - linters:
          - godoclint
        text: symbol should have a godoc \(\"(Swap|Len|Less|Error|String)\"\)
      - linters:
          - godoclint
        text: symbol should have a godoc
        path: api/configuration/v1alpha1/zz_generated_funcs.go
    paths:
      - pkg/clientset
      - config/
      - examples$
issues:
  max-same-issues: 0
  fix: true
formatters:
  enable:
    - gci
    - gofmt
    - goimports
  settings:
    gci:
      sections:
        - standard
        - default
        - prefix(github.com/kong/kong-operator)
      custom-order: true
  exclusions:
    generated: lax
    paths:
      - pkg/clientset
      - config/
      - examples$