Skip to content

Commit 55f0ff5

Browse files
committed
chore: licenses and field validation
1 parent 182ac06 commit 55f0ff5

19 files changed

+97
-320
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ linters:
2727
- name: comment-spacings
2828
- name: import-shadowing
2929
gocyclo:
30-
min-complexity: 65
30+
min-complexity: 70
3131
exclusions:
3232
generated: lax
3333
rules:

api/v1alpha1/dnsrecordset_types.go

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
Copyright 2025.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// SPDX-License-Identifier: AGPL-3.0-only
162

173
package v1alpha1
184

@@ -51,13 +37,16 @@ type DNSRecordSetSpec struct {
5137
RecordType RRType `json:"recordType"`
5238

5339
// Records contains one or more owner names with values appropriate for the RecordType.
40+
// +kubebuilder:validation:MinItems=1
5441
Records []RecordEntry `json:"records"`
5542
}
5643

5744
// RecordEntry represents one owner name and its values.
5845
type RecordEntry struct {
5946
// Name is the owner name (relative to the zone or FQDN).
6047
// +kubebuilder:validation:Required
48+
// +kubebuilder:validation:MinLength=1
49+
// +kubebuilder:validation:Pattern=`^(@|[A-Za-z0-9*._-]+)$`
6150
Name string `json:"name"`
6251
// TTL optionally overrides TTL for this owner/RRset.
6352
// +optional
@@ -103,20 +92,37 @@ type CNAMEValue struct {
10392
}
10493

10594
type SRVRecordSpec struct {
95+
// +kubebuilder:validation:Minimum=0
96+
// +kubebuilder:validation:Maximum=65535
10697
Priority uint16 `json:"priority"`
107-
Weight uint16 `json:"weight"`
108-
Port uint16 `json:"port"`
109-
Target string `json:"target"`
98+
// +kubebuilder:validation:Minimum=0
99+
// +kubebuilder:validation:Maximum=65535
100+
Weight uint16 `json:"weight"`
101+
// +kubebuilder:validation:Minimum=0
102+
// +kubebuilder:validation:Maximum=65535
103+
Port uint16 `json:"port"`
104+
// +kubebuilder:validation:MinLength=1
105+
Target string `json:"target"`
110106
}
111107

112108
type MXRecordSpec struct {
109+
// +kubebuilder:validation:Minimum=0
110+
// +kubebuilder:validation:Maximum=65535
113111
Preference uint16 `json:"preference"`
114-
Exchange string `json:"exchange"`
112+
// +kubebuilder:validation:MinLength=1
113+
Exchange string `json:"exchange"`
115114
}
116115

117116
type CAARecordSpec struct {
118-
Flag uint8 `json:"flag"`
119-
Tag string `json:"tag"`
117+
// 0–255 flag
118+
// +kubebuilder:validation:Minimum=0
119+
// +kubebuilder:validation:Maximum=255
120+
Flag uint8 `json:"flag"`
121+
// RFC-style tags: keep it simple: [a-z0-9]+
122+
// +kubebuilder:validation:MinLength=1
123+
// +kubebuilder:validation:Pattern=`^[a-z0-9]+$`
124+
Tag string `json:"tag"`
125+
// +kubebuilder:validation:MinLength=1
120126
Value string `json:"value"`
121127
}
122128

@@ -128,13 +134,18 @@ type TLSARecordSpec struct {
128134
}
129135

130136
type HTTPSRecordSpec struct {
131-
Priority uint16 `json:"priority"`
132-
Target string `json:"target"`
133-
Params map[string]string `json:"params,omitempty"`
137+
// +kubebuilder:validation:Minimum=0
138+
// +kubebuilder:validation:Maximum=65535
139+
Priority uint16 `json:"priority"`
140+
Target string `json:"target"`
141+
// +optional
142+
Params map[string]string `json:"params,omitempty"`
134143
}
135144

136145
type SOARecordSpec struct {
146+
// +kubebuilder:validation:MinLength=1
137147
MName string `json:"mname"`
148+
// +kubebuilder:validation:MinLength=1
138149
RName string `json:"rname"`
139150
// +optional
140151
Serial uint32 `json:"serial,omitempty"`

api/v1alpha1/dnszone_types.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
Copyright 2025.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// SPDX-License-Identifier: AGPL-3.0-only
162

173
package v1alpha1
184

api/v1alpha1/dnszoneclass_types.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
Copyright 2025.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// SPDX-License-Identifier: AGPL-3.0-only
162

173
package v1alpha1
184

api/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
Copyright 2025.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// SPDX-License-Identifier: AGPL-3.0-only
162

173
// Package v1alpha1 contains API Schema definitions for the dns v1alpha1 API group.
184
// +kubebuilder:object:generate=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
/*
2-
Copyright 2025.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// SPDX-License-Identifier: AGPL-3.0-only
162

173
package main
184

config/crd/bases/dns.networking.miloapis.com_dnsrecordsets.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,17 @@ spec:
108108
items:
109109
properties:
110110
flag:
111+
description: 0–255 flag
112+
maximum: 255
113+
minimum: 0
111114
type: integer
112115
tag:
116+
description: 'RFC-style tags: keep it simple: [a-z0-9]+'
117+
minLength: 1
118+
pattern: ^[a-z0-9]+$
113119
type: string
114120
value:
121+
minLength: 1
115122
type: string
116123
required:
117124
- flag
@@ -134,6 +141,8 @@ spec:
134141
type: string
135142
type: object
136143
priority:
144+
maximum: 65535
145+
minimum: 0
137146
type: integer
138147
target:
139148
type: string
@@ -146,8 +155,11 @@ spec:
146155
items:
147156
properties:
148157
exchange:
158+
minLength: 1
149159
type: string
150160
preference:
161+
maximum: 65535
162+
minimum: 0
151163
type: integer
152164
required:
153165
- exchange
@@ -157,6 +169,8 @@ spec:
157169
name:
158170
description: Name is the owner name (relative to the zone or
159171
FQDN).
172+
minLength: 1
173+
pattern: ^(@|[A-Za-z0-9*._-]+)$
160174
type: string
161175
ns:
162176
properties:
@@ -179,6 +193,7 @@ spec:
179193
format: int32
180194
type: integer
181195
mname:
196+
minLength: 1
182197
type: string
183198
refresh:
184199
format: int32
@@ -187,6 +202,7 @@ spec:
187202
format: int32
188203
type: integer
189204
rname:
205+
minLength: 1
190206
type: string
191207
serial:
192208
format: int32
@@ -202,12 +218,19 @@ spec:
202218
items:
203219
properties:
204220
port:
221+
maximum: 65535
222+
minimum: 0
205223
type: integer
206224
priority:
225+
maximum: 65535
226+
minimum: 0
207227
type: integer
208228
target:
229+
minLength: 1
209230
type: string
210231
weight:
232+
maximum: 65535
233+
minimum: 0
211234
type: integer
212235
required:
213236
- port
@@ -224,6 +247,8 @@ spec:
224247
type: string
225248
type: object
226249
priority:
250+
maximum: 65535
251+
minimum: 0
227252
type: integer
228253
target:
229254
type: string
@@ -266,6 +291,7 @@ spec:
266291
required:
267292
- name
268293
type: object
294+
minItems: 1
269295
type: array
270296
required:
271297
- dnsZoneRef

hack/boilerplate.go.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
/*
2-
Copyright 2025.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// SPDX-License-Identifier: AGPL-3.0-only

internal/config/zz_generated.deepcopy.go

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)