mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Activate lint for unused code.
This commit is contained in:
@@ -23,10 +23,12 @@ linters:
|
||||
- nakedret
|
||||
- staticcheck
|
||||
- structcheck
|
||||
# - stylecheck (panics)
|
||||
# stylecheck demands that acronyms not be treated as words
|
||||
# in camelCase, so JsonOp become JSONOp, etc. Yuck.
|
||||
# - stylecheck
|
||||
# - typecheck (fails in lots of places)
|
||||
- unconvert
|
||||
# - unused (panics)
|
||||
- unused
|
||||
- unparam
|
||||
- varcheck
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func (p *HashTransformerPlugin) Config(
|
||||
// Transform appends hash to generated resources.
|
||||
func (p *HashTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
for _, res := range m.Resources() {
|
||||
if res.NeedHashSuffix() {
|
||||
if res.ShouldAddHashSuffixToName() {
|
||||
h, err := p.hasher.Hash(res)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -389,6 +389,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
|
||||
@@ -70,7 +70,9 @@ func (rv *refVarTransformer) replaceVars(in interface{}) (interface{}, error) {
|
||||
// This field can potentially contain a $(VAR) since it is
|
||||
// of string type.
|
||||
return expansion2.Expand(s, rv.mappingFunc), nil
|
||||
//nolint:staticcheck (erroneously claims that `case nil` is unreachable)
|
||||
// staticcheck erroneously claims that `case nil`
|
||||
// is unreachable here, so suppressing it.
|
||||
//nolint:staticcheck
|
||||
case nil:
|
||||
return nil, nil
|
||||
default:
|
||||
|
||||
@@ -157,7 +157,7 @@ func TestUpdateResourceOptions(t *testing.T) {
|
||||
if !a.Equals(b) {
|
||||
t.Errorf("expected %v got %v", a, b)
|
||||
}
|
||||
if a.NeedHashSuffix() != b.NeedHashSuffix() {
|
||||
if a.ShouldAddHashSuffixToName() != b.ShouldAddHashSuffixToName() {
|
||||
t.Errorf("")
|
||||
}
|
||||
if a.Behavior() != b.Behavior() {
|
||||
|
||||
@@ -222,11 +222,6 @@ func (kt *KustTarget) computeInventory(
|
||||
return ra.Transform(p)
|
||||
}
|
||||
|
||||
func (kt *KustTarget) shouldAddHashSuffixesToGeneratedResources() bool {
|
||||
return kt.kustomization.GeneratorOptions == nil ||
|
||||
!kt.kustomization.GeneratorOptions.DisableNameSuffixHash
|
||||
}
|
||||
|
||||
// AccumulateTarget returns a new ResAccumulator,
|
||||
// holding customized resources and the data/rules used
|
||||
// to do so. The name back references and vars are
|
||||
|
||||
@@ -252,9 +252,10 @@ func (r *Resource) Behavior() types.GenerationBehavior {
|
||||
return r.options.Behavior()
|
||||
}
|
||||
|
||||
// NeedHashSuffix checks if the resource need a hash suffix
|
||||
func (r *Resource) NeedHashSuffix() bool {
|
||||
return r.options != nil && r.options.NeedsHashSuffix()
|
||||
// ShouldAddHashSuffixToName returns true if a resource
|
||||
// content hash should be appended to the name of the resource.
|
||||
func (r *Resource) ShouldAddHashSuffixToName() bool {
|
||||
return r.options != nil && r.options.ShouldAddHashSuffixToName()
|
||||
}
|
||||
|
||||
// GetNamespace returns the namespace the resource thinks it's in.
|
||||
|
||||
@@ -28,18 +28,17 @@ func (g *GenArgs) String() string {
|
||||
}
|
||||
return "{" +
|
||||
strings.Join([]string{
|
||||
"nsfx:" + strconv.FormatBool(g.NeedsHashSuffix()),
|
||||
"nsfx:" + strconv.FormatBool(g.ShouldAddHashSuffixToName()),
|
||||
"beh:" + g.Behavior().String()},
|
||||
",") +
|
||||
"}"
|
||||
}
|
||||
|
||||
// NeedsHashSuffix returns true if the hash suffix is needed.
|
||||
// It is needed when the two conditions are both met
|
||||
// 1) GenArgs is not nil
|
||||
// 2) DisableNameSuffixHash in GeneratorOptions is not set to true
|
||||
func (g *GenArgs) NeedsHashSuffix() bool {
|
||||
return g.args != nil && (g.opts == nil || !g.opts.DisableNameSuffixHash)
|
||||
// ShouldAddHashSuffixToName returns true if a resource
|
||||
// content hash should be appended to the name of the resource.
|
||||
func (g *GenArgs) ShouldAddHashSuffixToName() bool {
|
||||
return g.args != nil &&
|
||||
(g.opts == nil || !g.opts.DisableNameSuffixHash)
|
||||
}
|
||||
|
||||
// Behavior returns Behavior field of GeneratorArgs
|
||||
|
||||
Reference in New Issue
Block a user