Skip to content

Commit 299b4b0

Browse files
Fixed integration tests
1 parent 77a6160 commit 299b4b0

File tree

6 files changed

+29
-28
lines changed

6 files changed

+29
-28
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.24.0
55
require (
66
github.com/golangci/golangci-lint/v2 v2.5.0
77
github.com/golangci/plugin-module-register v0.1.2
8+
github.com/google/go-cmp v0.7.0
89
github.com/onsi/ginkgo/v2 v2.23.4
910
github.com/onsi/gomega v1.38.0
1011
golang.org/x/tools v0.37.0
@@ -100,7 +101,6 @@ require (
100101
github.com/golangci/revgrep v0.8.0 // indirect
101102
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
102103
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
103-
github.com/google/go-cmp v0.7.0 // indirect
104104
github.com/google/pprof v0.0.0-20250607225305-033d6d78b36a // indirect
105105
github.com/gordonklaus/ineffassign v0.2.0 // indirect
106106
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect

pkg/analysis/noreferences/initializer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ func validateConfig(cfg *Config, fldPath *field.Path) field.ErrorList {
5959
[]string{string(PolicyPreferAbbreviatedReference), string(PolicyNoReferences)},
6060
))
6161
}
62+
6263
return errs
6364
}

pkg/analysis/noreferences/testdata/src/a/a.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ package a
44
// In this mode, Reference/References are flagged at START or END of field names, but Ref/Refs are allowed
55
type TestWithPolicyPreferAbbreviatedReference struct {
66
// Fields ending with Reference should be flagged
7-
NodeReference string `json:"nodeReference"` // want `naming convention "reference-to-ref": field NodeReference: field names should use 'Ref' instead of 'Reference'`
7+
NodeReference string `json:"nodeReference"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.NodeReference: field names should use 'Ref' instead of 'Reference'`
88

9-
ConfigReference string `json:"configReference"` // want `naming convention "reference-to-ref": field ConfigReference: field names should use 'Ref' instead of 'Reference'`
9+
ConfigReference string `json:"configReference"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ConfigReference: field names should use 'Ref' instead of 'Reference'`
1010

1111
// Fields ending with References should be flagged
12-
NodeReferences []string `json:"nodeReferences"` // want `naming convention "reference-to-ref": field NodeReferences: field names should use 'Ref' instead of 'Reference'`
12+
NodeReferences []string `json:"nodeReferences"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.NodeReferences: field names should use 'Ref' instead of 'Reference'`
1313

14-
ConfigReferences []string `json:"configReferences"` // want `naming convention "reference-to-ref": field ConfigReferences: field names should use 'Ref' instead of 'Reference'`
14+
ConfigReferences []string `json:"configReferences"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ConfigReferences: field names should use 'Ref' instead of 'Reference'`
1515

1616
// Fields with Reference at beginning should be flagged
17-
ReferenceCount int `json:"referenceCount"` // want `naming convention "reference-to-ref": field ReferenceCount: field names should use 'Ref' instead of 'Reference'`
17+
ReferenceCount int `json:"referenceCount"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferenceCount: field names should use 'Ref' instead of 'Reference'`
1818

19-
ReferenceData string `json:"referenceData"` // want `naming convention "reference-to-ref": field ReferenceData: field names should use 'Ref' instead of 'Reference'`
19+
ReferenceData string `json:"referenceData"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferenceData: field names should use 'Ref' instead of 'Reference'`
2020

2121
// Fields with References at beginning should be flagged
22-
ReferencesCount int `json:"referencesCount"` // want `naming convention "reference-to-ref": field ReferencesCount: field names should use 'Ref' instead of 'Reference'`
22+
ReferencesCount int `json:"referencesCount"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferencesCount: field names should use 'Ref' instead of 'Reference'`
2323

24-
ReferencesData []string `json:"referencesData"` // want `naming convention "reference-to-ref": field ReferencesData: field names should use 'Ref' instead of 'Reference'`
24+
ReferencesData []string `json:"referencesData"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferencesData: field names should use 'Ref' instead of 'Reference'`
2525

2626
// Fields with Reference in middle are NOT flagged (only start/end boundaries)
2727
CrossReferenceID string `json:"crossReferenceID"`
@@ -30,7 +30,7 @@ type TestWithPolicyPreferAbbreviatedReference struct {
3030
CrossReferencesMap map[string]string `json:"crossReferencesMap"`
3131

3232
// Past tense "Referenced" at end is flagged
33-
Referenced bool `json:"referenced"` // want `naming convention "reference-to-ref": field Referenced: field names should use 'Ref' instead of 'Reference'`
33+
Referenced bool `json:"referenced"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.Referenced: field names should use 'Ref' instead of 'Reference'`
3434

3535
// Fields with Ref/Refs anywhere are ALLOWED in this mode (no diagnostics expected)
3636
NodeRef string `json:"nodeRef"`

pkg/analysis/noreferences/testdata/src/a/a.go.golden

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ package a
44
// In this mode, Reference/References are flagged at START or END of field names, but Ref/Refs are allowed
55
type TestWithPolicyPreferAbbreviatedReference struct {
66
// Fields ending with Reference should be flagged
7-
NodeRef string `json:"nodeRef"` // want `naming convention "reference-to-ref": field NodeReference: field names should use 'Ref' instead of 'Reference'`
7+
NodeRef string `json:"nodeRef"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.NodeReference: field names should use 'Ref' instead of 'Reference'`
88

9-
ConfigRef string `json:"configRef"` // want `naming convention "reference-to-ref": field ConfigReference: field names should use 'Ref' instead of 'Reference'`
9+
ConfigRef string `json:"configRef"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ConfigReference: field names should use 'Ref' instead of 'Reference'`
1010

1111
// Fields ending with References should be flagged
12-
NodeRefs []string `json:"nodeRefs"` // want `naming convention "reference-to-ref": field NodeReferences: field names should use 'Ref' instead of 'Reference'`
12+
NodeRefs []string `json:"nodeRefs"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.NodeReferences: field names should use 'Ref' instead of 'Reference'`
1313

14-
ConfigRefs []string `json:"configRefs"` // want `naming convention "reference-to-ref": field ConfigReferences: field names should use 'Ref' instead of 'Reference'`
14+
ConfigRefs []string `json:"configRefs"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ConfigReferences: field names should use 'Ref' instead of 'Reference'`
1515

1616
// Fields with Reference at beginning should be flagged
17-
RefCount int `json:"refCount"` // want `naming convention "reference-to-ref": field ReferenceCount: field names should use 'Ref' instead of 'Reference'`
17+
RefCount int `json:"refCount"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferenceCount: field names should use 'Ref' instead of 'Reference'`
1818

19-
RefData string `json:"refData"` // want `naming convention "reference-to-ref": field ReferenceData: field names should use 'Ref' instead of 'Reference'`
19+
RefData string `json:"refData"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferenceData: field names should use 'Ref' instead of 'Reference'`
2020

2121
// Fields with References at beginning should be flagged
22-
RefsCount int `json:"refsCount"` // want `naming convention "reference-to-ref": field ReferencesCount: field names should use 'Ref' instead of 'Reference'`
22+
RefsCount int `json:"refsCount"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferencesCount: field names should use 'Ref' instead of 'Reference'`
2323

24-
RefsData []string `json:"refsData"` // want `naming convention "reference-to-ref": field ReferencesData: field names should use 'Ref' instead of 'Reference'`
24+
RefsData []string `json:"refsData"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.ReferencesData: field names should use 'Ref' instead of 'Reference'`
2525

2626
// Fields with Reference in middle are NOT flagged (only start/end boundaries)
2727
CrossReferenceID string `json:"crossReferenceID"`
@@ -30,7 +30,7 @@ type TestWithPolicyPreferAbbreviatedReference struct {
3030
CrossReferencesMap map[string]string `json:"crossReferencesMap"`
3131

3232
// Past tense "Referenced" at end is flagged
33-
Refd bool `json:"refd"` // want `naming convention "reference-to-ref": field Referenced: field names should use 'Ref' instead of 'Reference'`
33+
Refd bool `json:"refd"` // want `naming convention "reference-to-ref": field TestWithPolicyPreferAbbreviatedReference.Referenced: field names should use 'Ref' instead of 'Reference'`
3434

3535
// Fields with Ref/Refs anywhere are ALLOWED in this mode (no diagnostics expected)
3636
NodeRef string `json:"nodeRef"`

pkg/analysis/noreferences/testdata/src/b/b.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ package b
44
// In this mode, all reference-related words (Reference/References/Ref/Refs) are warned about but not removed
55
type TestWithPolicyNoReferences struct {
66
// Fields ending with Reference should be flagged
7-
NodeReference string `json:"nodeReference"` // want `naming convention "no-references": field NodeReference: field names should not contain reference-related words`
7+
NodeReference string `json:"nodeReference"` // want `naming convention "no-references": field TestWithPolicyNoReferences.NodeReference: field names should not contain reference-related words`
88

99
// Fields ending with References should be flagged
10-
ConfigReferences []string `json:"configReferences"` // want `naming convention "no-references": field ConfigReferences: field names should not contain reference-related words`
10+
ConfigReferences []string `json:"configReferences"` // want `naming convention "no-references": field TestWithPolicyNoReferences.ConfigReferences: field names should not contain reference-related words`
1111

1212
// Fields with Reference at beginning should be flagged
13-
ReferenceCount int `json:"referenceCount"` // want `naming convention "no-references": field ReferenceCount: field names should not contain reference-related words`
13+
ReferenceCount int `json:"referenceCount"` // want `naming convention "no-references": field TestWithPolicyNoReferences.ReferenceCount: field names should not contain reference-related words`
1414

1515
// Fields with References at beginning should be flagged
16-
ReferencesData []string `json:"referencesData"` // want `naming convention "no-references": field ReferencesData: field names should not contain reference-related words`
16+
ReferencesData []string `json:"referencesData"` // want `naming convention "no-references": field TestWithPolicyNoReferences.ReferencesData: field names should not contain reference-related words`
1717

1818
// Fields ending with Ref should be flagged
19-
PodRef string `json:"podRef"` // want `naming convention "no-references": field PodRef: field names should not contain reference-related words`
19+
PodRef string `json:"podRef"` // want `naming convention "no-references": field TestWithPolicyNoReferences.PodRef: field names should not contain reference-related words`
2020

2121
// Fields ending with Refs should be flagged
22-
ContainerRefs []string `json:"containerRefs"` // want `naming convention "no-references": field ContainerRefs: field names should not contain reference-related words`
22+
ContainerRefs []string `json:"containerRefs"` // want `naming convention "no-references": field TestWithPolicyNoReferences.ContainerRefs: field names should not contain reference-related words`
2323

2424
// Fields starting with Ref should be flagged
25-
RefStatus string `json:"refStatus"` // want `naming convention "no-references": field RefStatus: field names should not contain reference-related words`
25+
RefStatus string `json:"refStatus"` // want `naming convention "no-references": field TestWithPolicyNoReferences.RefStatus: field names should not contain reference-related words`
2626

2727
// Fields starting with Refs should be flagged
28-
RefsTotal int `json:"refsTotal"` // want `naming convention "no-references": field RefsTotal: field names should not contain reference-related words`
28+
RefsTotal int `json:"refsTotal"` // want `naming convention "no-references": field TestWithPolicyNoReferences.RefsTotal: field names should not contain reference-related words`
2929

3030
// Normal fields should not be flagged
3131
Name string `json:"name"`

tests/integration/testdata/default_configurations/volume.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ type ImageVolumeSource struct {
311311
// This field is optional to allow higher level config management to default or override
312312
// container images in workload controllers like Deployments and StatefulSets.
313313
// +optional
314-
Reference string `json:"reference,omitempty" protobuf:"bytes,1,opt,name=reference"` // want "optionalfields: field Reference should be a pointer." "noreferences: naming convention \"reference-to-ref\": field Reference: field names should use 'Ref' instead of 'Reference'"
314+
Reference string `json:"reference,omitempty" protobuf:"bytes,1,opt,name=reference"` // want "optionalfields: field Reference should be a pointer." "noreferences: naming convention \"reference-to-ref\": field ImageVolumeSource.Reference: field names should use 'Ref' instead of 'Reference'"
315315

316316
// Policy for pulling OCI objects. Possible values are: // want "commentstart: godoc for field ImageVolumeSource.PullPolicy should start with 'pullPolicy ...'"
317317
// Always: the kubelet always attempts to pull the reference. Container creation will fail If the pull fails.

0 commit comments

Comments
 (0)