mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Merge pull request #129813 from yongruilin/golangci-featuregate-add
feat: add a lint rule to prevent Add unversioned featuregate
This commit is contained in:
commit
547654a8a1
@ -46,6 +46,12 @@ issues:
|
|||||||
text: should not be used because managedFields was removed
|
text: should not be used because managedFields was removed
|
||||||
path: _test.go$
|
path: _test.go$
|
||||||
|
|
||||||
|
# Adding unversioned feature gates is allowed in tests
|
||||||
|
- linters:
|
||||||
|
- forbidigo
|
||||||
|
text: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
|
path: _test.go$
|
||||||
|
|
||||||
# The Kubernetes naming convention for conversion functions uses underscores
|
# The Kubernetes naming convention for conversion functions uses underscores
|
||||||
# and intentionally deviates from normal Go conventions to make those function
|
# and intentionally deviates from normal Go conventions to make those function
|
||||||
# names more readable. Same for SetDefaults_*.
|
# names more readable. Same for SetDefaults_*.
|
||||||
@ -197,6 +203,10 @@ linters-settings: # please keep this alphabetized
|
|||||||
- p: \.Extract
|
- p: \.Extract
|
||||||
pkg: ^k8s\.io/client-go/applyconfigurations/
|
pkg: ^k8s\.io/client-go/applyconfigurations/
|
||||||
msg: should not be used because managedFields was removed
|
msg: should not be used because managedFields was removed
|
||||||
|
- p: \.Add$
|
||||||
|
pkg: ^k8s\.io/component-base/featuregate$
|
||||||
|
type: ^MutableFeatureGate$
|
||||||
|
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
- p: ^gomega\.BeTrue$
|
- p: ^gomega\.BeTrue$
|
||||||
pkg: ^github.com/onsi/gomega$
|
pkg: ^github.com/onsi/gomega$
|
||||||
msg: "it does not produce a good failure message - use BeTrueBecause with an explicit printf-style failure message instead, or plain Go: if ... { ginkgo.Fail(...) }"
|
msg: "it does not produce a good failure message - use BeTrueBecause with an explicit printf-style failure message instead, or plain Go: if ... { ginkgo.Fail(...) }"
|
||||||
|
@ -46,6 +46,12 @@ issues:
|
|||||||
text: should not be used because managedFields was removed
|
text: should not be used because managedFields was removed
|
||||||
path: _test.go$
|
path: _test.go$
|
||||||
|
|
||||||
|
# Adding unversioned feature gates is allowed in tests
|
||||||
|
- linters:
|
||||||
|
- forbidigo
|
||||||
|
text: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
|
path: _test.go$
|
||||||
|
|
||||||
# The Kubernetes naming convention for conversion functions uses underscores
|
# The Kubernetes naming convention for conversion functions uses underscores
|
||||||
# and intentionally deviates from normal Go conventions to make those function
|
# and intentionally deviates from normal Go conventions to make those function
|
||||||
# names more readable. Same for SetDefaults_*.
|
# names more readable. Same for SetDefaults_*.
|
||||||
@ -243,6 +249,10 @@ linters-settings: # please keep this alphabetized
|
|||||||
- p: \.Extract
|
- p: \.Extract
|
||||||
pkg: ^k8s\.io/client-go/applyconfigurations/
|
pkg: ^k8s\.io/client-go/applyconfigurations/
|
||||||
msg: should not be used because managedFields was removed
|
msg: should not be used because managedFields was removed
|
||||||
|
- p: \.Add$
|
||||||
|
pkg: ^k8s\.io/component-base/featuregate$
|
||||||
|
type: ^MutableFeatureGate$
|
||||||
|
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
revive:
|
revive:
|
||||||
# Only these rules are enabled.
|
# Only these rules are enabled.
|
||||||
rules:
|
rules:
|
||||||
|
@ -46,6 +46,12 @@ issues:
|
|||||||
text: should not be used because managedFields was removed
|
text: should not be used because managedFields was removed
|
||||||
path: _test.go$
|
path: _test.go$
|
||||||
|
|
||||||
|
# Adding unversioned feature gates is allowed in tests
|
||||||
|
- linters:
|
||||||
|
- forbidigo
|
||||||
|
text: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
|
path: _test.go$
|
||||||
|
|
||||||
# TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components
|
# TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components
|
||||||
# with different owners it's hard to fix everything in a single pr. This will therefore be done in multiple prs.
|
# with different owners it's hard to fix everything in a single pr. This will therefore be done in multiple prs.
|
||||||
- path: (pkg/volume/*|test/*|azure/*|pkg/cmd/wait*|request/bearertoken/*|metrics/*|filters/*)
|
- path: (pkg/volume/*|test/*|azure/*|pkg/cmd/wait*|request/bearertoken/*|metrics/*|filters/*)
|
||||||
@ -245,6 +251,10 @@ linters-settings: # please keep this alphabetized
|
|||||||
- p: \.Extract
|
- p: \.Extract
|
||||||
pkg: ^k8s\.io/client-go/applyconfigurations/
|
pkg: ^k8s\.io/client-go/applyconfigurations/
|
||||||
msg: should not be used because managedFields was removed
|
msg: should not be used because managedFields was removed
|
||||||
|
- p: \.Add$
|
||||||
|
pkg: ^k8s\.io/component-base/featuregate$
|
||||||
|
type: ^MutableFeatureGate$
|
||||||
|
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
gocritic:
|
gocritic:
|
||||||
enabled-checks:
|
enabled-checks:
|
||||||
- equalFold
|
- equalFold
|
||||||
|
@ -46,6 +46,12 @@ issues:
|
|||||||
text: should not be used because managedFields was removed
|
text: should not be used because managedFields was removed
|
||||||
path: _test.go$
|
path: _test.go$
|
||||||
|
|
||||||
|
# Adding unversioned feature gates is allowed in tests
|
||||||
|
- linters:
|
||||||
|
- forbidigo
|
||||||
|
text: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
|
path: _test.go$
|
||||||
|
|
||||||
{{- if .Base}}
|
{{- if .Base}}
|
||||||
|
|
||||||
# TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components
|
# TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components
|
||||||
@ -200,6 +206,10 @@ linters-settings: # please keep this alphabetized
|
|||||||
- p: \.Extract
|
- p: \.Extract
|
||||||
pkg: ^k8s\.io/client-go/applyconfigurations/
|
pkg: ^k8s\.io/client-go/applyconfigurations/
|
||||||
msg: should not be used because managedFields was removed
|
msg: should not be used because managedFields was removed
|
||||||
|
- p: \.Add$
|
||||||
|
pkg: ^k8s\.io/component-base/featuregate$
|
||||||
|
type: ^MutableFeatureGate$
|
||||||
|
msg: should not use MutableFeatureGate.Add, use AddVersioned instead
|
||||||
{{- if .Hints}}
|
{{- if .Hints}}
|
||||||
- p: ^gomega\.BeTrue$
|
- p: ^gomega\.BeTrue$
|
||||||
pkg: ^github.com/onsi/gomega$
|
pkg: ^github.com/onsi/gomega$
|
||||||
|
@ -65,7 +65,7 @@ func (a *clientAdapter) Add(in map[clientfeatures.Feature]clientfeatures.Feature
|
|||||||
}
|
}
|
||||||
out[featuregate.Feature(name)] = converted
|
out[featuregate.Feature(name)] = converted
|
||||||
}
|
}
|
||||||
return a.mfg.Add(out)
|
return a.mfg.Add(out) //nolint:forbidigo // No need to support versioned feature gates in client adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set implements the unexported interface that client-go feature gate testing expects for
|
// Set implements the unexported interface that client-go feature gate testing expects for
|
||||||
|
@ -865,7 +865,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates))
|
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)) //nolint:forbidigo // TODO(https://github.com/kubernetes/enhancements/tree/master/keps/sig-architecture/4330-compatibility-versions): Remove this once we complete the migration to versioned feature gates
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.AddVersioned(defaultVersionedKubernetesFeatureGates))
|
runtime.Must(utilfeature.DefaultMutableFeatureGate.AddVersioned(defaultVersionedKubernetesFeatureGates))
|
||||||
runtime.Must(zpagesfeatures.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
|
runtime.Must(zpagesfeatures.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates))
|
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)) //nolint:forbidigo // TODO(https://github.com/kubernetes/enhancements/tree/master/keps/sig-architecture/4330-compatibility-versions): Remove this once we complete the migration to versioned feature gates
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.AddVersioned(defaultVersionedKubernetesFeatureGates))
|
runtime.Must(utilfeature.DefaultMutableFeatureGate.AddVersioned(defaultVersionedKubernetesFeatureGates))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,5 +68,5 @@ func featureGates() map[featuregate.Feature]featuregate.FeatureSpec {
|
|||||||
|
|
||||||
// AddFeatureGates adds all feature gates used by this package.
|
// AddFeatureGates adds all feature gates used by this package.
|
||||||
func AddFeatureGates(mutableFeatureGate featuregate.MutableFeatureGate) error {
|
func AddFeatureGates(mutableFeatureGate featuregate.MutableFeatureGate) error {
|
||||||
return mutableFeatureGate.Add(featureGates())
|
return mutableFeatureGate.Add(featureGates()) //nolint:forbidigo // The logging feature gates are by design unversioned (perpetual alpha/beta).
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(testFeatureGates))
|
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(testFeatureGates)) //nolint:forbidigo // Part of a unit test.
|
||||||
}
|
}
|
||||||
|
|
||||||
var testFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
var testFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
||||||
|
@ -27,7 +27,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates))
|
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultKubernetesFeatureGates)) //nolint:forbidigo // Part of a unit test.
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
||||||
|
Loading…
Reference in New Issue
Block a user