|
1 | 1 | package a
|
2 | 2 |
|
3 |
| -// +optional |
| 3 | +// It must be ignored since it is not a type |
| 4 | +// +kubebuilder:validation:Enum=foo;bar;baz |
| 5 | +// +kubebuilder:validation:Enum=foo;bar;baz |
| 6 | +var Variable string |
| 7 | + |
4 | 8 | // +kubebuilder:validation:Enum=foo;bar;baz
|
5 | 9 | type Enum string // want "Enum has duplicated markers kubebuilder:validation:Enum"
|
6 | 10 |
|
7 |
| -// It must be ignored since it is not a type |
8 |
| -// +required |
9 |
| -var Variable string |
| 11 | +// +kubebuilder:validation:MaxLength=10 |
| 12 | +// +kubebuilder:validation:MaxLength=11 |
| 13 | +type MaxLength int |
| 14 | + |
| 15 | +// +kubebuilder:validation:MaxLength=10 |
| 16 | +type DuplicatedMaxLength int // want "DuplicatedMaxLength has duplicated markers kubebuilder:validation:MaxLength=10" |
10 | 17 |
|
11 |
| -// +kubebuilder:subresource:status |
12 | 18 | // +kubebuilder:object:root=true
|
| 19 | +// +kubebuilder:subresource:status |
13 | 20 | type DuplicateMarkerSpec struct { // want "DuplicateMarkerSpec has duplicated markers kubebuilder:object:root"
|
14 | 21 | // +kubebuilder:validation:Required
|
15 |
| - Foo string `json:"foo"` |
| 22 | + // shpuld be ignored since it only has single marker |
| 23 | + UniqueRequired string `json:"uniqueRequired"` |
| 24 | + |
| 25 | + // +listType=map |
| 26 | + // +listMapKey=primaryKey |
| 27 | + // +listMapKey=secondaryKey |
| 28 | + // +required |
| 29 | + // should be ignored since listMapKey is allowed to have different values |
| 30 | + Map Map `json:"map"` |
| 31 | + |
| 32 | + // +optional |
| 33 | + // +kubebuilder:validation:XValidation:rule="self >= 1 && self <= 3",message="must be 1 to 5" |
| 34 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="replicas must be immutable" |
| 35 | + // should be ignored since XValidation is allowed to have different values |
| 36 | + Replicas *int `json:"replicas"` |
| 37 | + |
| 38 | + // +kubebuilder:validation:MaxLength=11 |
| 39 | + // +kubebuilder:validation:MaxLength=10 |
| 40 | + // should be ignored since MaxLength is allowed to have different values |
| 41 | + Maxlength int `json:"maxlength"` |
16 | 42 |
|
17 | 43 | // +kubebuilder:validation:Required
|
| 44 | + DuplicatedRequired string `json:"duplicatedRequired"` // want "DuplicatedRequired has duplicated markers kubebuilder:validation:Required" |
| 45 | + |
| 46 | + // +kubebuilder:validation:Enum=foo;bar;baz |
| 47 | + DuplicatedEnum string `json:"duplicatedEnum"` // want "DuplicatedEnum has duplicated markers kubebuilder:validation:Enum" |
| 48 | + |
18 | 49 | // +kubebuilder:validation:MaxLength=10
|
19 |
| - DuplicatedFoo string `json:"duplicatedFoo"` // want "DuplicatedFoo has duplicated markers kubebuilder:validation:Required" |
| 50 | + DuplicatedMaxLength int `json:"duplicatedMaxLength"` // want "DuplicatedMaxLength has duplicated markers kubebuilder:validation:MaxLength=10" |
| 51 | + |
| 52 | + // +listType=map |
| 53 | + // +listMapKey=primaryKey |
| 54 | + // +listMapKey=secondaryKey |
| 55 | + // +required |
| 56 | + DuplicatedListTypeMap Map `json:"duplicatedListTypeMap"` // want "DuplicatedListTypeMap has duplicated markers listType=map" |
| 57 | + |
| 58 | + // +optional |
| 59 | + // +kubebuilder:validation:XValidation:rule="self >= 1 && self <= 3",message="must be 1 to 5" |
| 60 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="replicas must be immutable" |
| 61 | + DuplicatedReplicas *int `json:"duplicatedReplicas"` // want "DuplicatedReplicas has duplicated markers kubebuilder:validation:XValidation:rule=\"self >= 1 && self <= 3\",message=\"must be 1 to 5\"" |
| 62 | + |
| 63 | + // +optional |
| 64 | + // +kubebuilder:validation:XValidation:rule="self >= 1 && self <= 3",message="must be 1 to 5" |
| 65 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="replicas must be immutable" |
| 66 | + DuplicatedUnorderedValidationReplicas *int `json:"duplicatedUnorderedValidationReplicas"` // want "DuplicatedUnorderedValidationReplicas has duplicated markers kubebuilder:validation:XValidation:message=\"must be 1 to 5\",rule=\"self >= 1 && self <= 3\"" |
| 67 | +} |
| 68 | + |
| 69 | +type Map struct { |
| 70 | + // +required |
| 71 | + PrimaryKey string `json:"primaryKey"` |
| 72 | + // +required |
| 73 | + SecondaryKey string `json:"secondaryKey"` |
| 74 | + // +required |
| 75 | + Value string `json:"value"` |
20 | 76 | }
|
0 commit comments