Skip to content

Commit d5d74cb

Browse files
committed
Teach uniquemarkers about 1.35 DV markers
1 parent 87d6e5e commit d5d74cb

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

pkg/analysis/uniquemarkers/analyzer.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,5 +280,33 @@ func defaultUniqueMarkers() []UniqueMarker {
280280
},
281281
},
282282
// ------
283+
284+
// K8s-specific unique markers
285+
// ------
286+
{
287+
Identifier: markersconsts.K8sFormatMarker,
288+
},
289+
{
290+
Identifier: markersconsts.K8sMinLengthMarker,
291+
},
292+
{
293+
Identifier: markersconsts.K8sMaxLengthMarker,
294+
},
295+
{
296+
Identifier: markersconsts.K8sMinItemsMarker,
297+
},
298+
{
299+
Identifier: markersconsts.K8sMaxItemsMarker,
300+
},
301+
{
302+
Identifier: markersconsts.K8sMinimumMarker,
303+
},
304+
{
305+
Identifier: markersconsts.K8sMaximumMarker,
306+
},
307+
{
308+
Identifier: markersconsts.K8sListTypeMarker,
309+
},
310+
// ------
283311
}
284312
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package a
2+
3+
type K8s struct {
4+
// +k8s:format:=date-time
5+
UniqueFormat string
6+
7+
// +k8s:format:=date-time
8+
// +k8s:format:=password
9+
NonUniqueFormat string // want "field NonUniqueFormat has multiple definitions of marker k8s:format when only a single definition should exist"
10+
11+
// +k8s:minLength:=10
12+
UniqueMinLength string
13+
14+
// +k8s:minLength:=10
15+
// +k8s:minLength:=20
16+
NonUniqueMinLength string // want "field NonUniqueMinLength has multiple definitions of marker k8s:minLength when only a single definition should exist"
17+
18+
// +k8s:maxLength:=100
19+
UniqueMaxLength string
20+
21+
// +k8s:maxLength:=100
22+
// +k8s:maxLength:=200
23+
NonUniqueMaxLength string // want "field NonUniqueMaxLength has multiple definitions of marker k8s:maxLength when only a single definition should exist"
24+
25+
// +k8s:minItems:=10
26+
UniqueMinItems []string
27+
28+
// +k8s:minItems:=10
29+
// +k8s:minItems:=20
30+
NonUniqueMinItems []string // want "field NonUniqueMinItems has multiple definitions of marker k8s:minItems when only a single definition should exist"
31+
32+
// +k8s:maxItems:=100
33+
UniqueMaxItems []string
34+
35+
// +k8s:maxItems:=100
36+
// +k8s:maxItems:=200
37+
NonUniqueMaxItems []string // want "field NonUniqueMaxItems has multiple definitions of marker k8s:maxItems when only a single definition should exist"
38+
39+
// +k8s:listType:=map
40+
UniqueListType []string
41+
42+
// +k8s:listType:=map
43+
// +k8s:listType:=atomic
44+
NonUniqueListType []string // want "field NonUniqueListType has multiple definitions of marker k8s:listType when only a single definition should exist"
45+
}

0 commit comments

Comments
 (0)