๐Ÿ“ฆ Kong / kubernetes-configuration

๐Ÿ“„ .golangci-kube-api.yaml ยท 104 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
104version: "2"
linters:
  default: none
  enable:
    - kubeapilinter
  settings:
    custom:
      kubeapilinter:
        type: module
        description: Kube API LInter lints Kube like APIs based on API conventions and best practices.
        settings:
          linters:
            disable:
              - "*"
            enable:
              - jsontags
              - duplicatemarkers
              - conditions
              # - maxlength
              - integers
              - nobools
              - nofloats
              - nomaps
              - nophase
              - optionalorrequired
              - requiredfields
              - statusoptional
              - statussubresource
              - uniquemarkers
          lintersConfig:
            conditions:
              isFirstField: Warn
              useProtobuf: Warn
              usePatchStrategy: Warn
            nomaps:
              policy: AllowStringToStringMaps
            # We allow underscores as that's what many Konnect related fields use.
            jsonTags:
              jsonTagRegex: "^[a-z][a-z0-9_]*(?:[A-Z][a-z0-9_]*)*$"
            optionalOrRequired:
              preferredOptionalMarker: optional
              preferredRequiredMarker: required
  exclusions:
    rules:
      - linters:
          - kubeapilinter
        path: .*
        text: "(optionalorrequired: embedded field  must be marked as optional or required)"
      - linters:
          - kubeapilinter
        path: .*
        text: "(optionalorrequired: field Spec must be marked as optional or required)"
      # NOTE: kubeapilinter has been introduced after v1alpha1/konnect_gateway_controlplane_types.go
      #       has been created and to prevent changes in the API and docs we disable the rule.
      - linters:
          - kubeapilinter
        path: api/konnect/v1alpha1/konnect_gateway_controlplane_types.go
        text: "nobools: field CloudGateway pointer should not use a bool. Use a string type with meaningful constant values as an enum."
      # NOTE: Let the old APIs be as they are.
      - linters:
          - kubeapilinter
        path: api/konnect/v1alpha1/.*
        text: "conditions: Conditions field is missing the following markers: patchStrategy=merge, patchMergeKey=type"
      # NOTE: Let the old APIs be as they are.
      - linters:
          - kubeapilinter
        path: api/konnect/v1alpha1/.*
        text: "conditions: Conditions field has incorrect tags, should be:"
      # NOTE: Let the old APIs be as they are.
      - linters:
          - kubeapilinter
        path: api/konnect/v1alpha1/.*
        text: "conditions: Conditions field must be the first field in the struct"

      # TODO: remove this.
      - linters:
          - kubeapilinter
        path: api/.*
        text: "requiredfields: field .* should have the omitempty tag."

      # TODO: remove this.
      - linters:
          - kubeapilinter
        path: api/.*
        text: "requiredfields: field .* does not allow the zero value. It must have the omitzero tag."

      # TODO: remove this.
      - linters:
          - kubeapilinter
        path: api/konnect/(v1alpha1|v1alpha2)/.*
        text: 'requiredfields: field .* has a valid zero value .* but the validation is not complete'

      # TODO: remove this.
      - linters:
          - kubeapilinter
        path: api/gateway-operator/v2beta1/shared_types.go
        text: 'requiredfields: field .* has a valid zero value .* but the validation is not complete'

      # TODO: remove this.
      - linters:
          - kubeapilinter
        path: api/gateway-operator/v2beta1/shared_types.go
        text: 'requiredfields: field Strategy has a valid zero value .* and should be a pointer.'