@@ -42,21 +42,21 @@ var (
42
42
maxVolumeSize = * resource .NewScaledQuantity (64 , resource .Tera )
43
43
)
44
44
45
- func (a * NodeClass ) SupportedVerbs () []admissionregistrationv1.OperationType {
45
+ func (a * EC2NodeClass ) SupportedVerbs () []admissionregistrationv1.OperationType {
46
46
return []admissionregistrationv1.OperationType {
47
47
admissionregistrationv1 .Create ,
48
48
admissionregistrationv1 .Update ,
49
49
}
50
50
}
51
51
52
- func (a * NodeClass ) Validate (ctx context.Context ) (errs * apis.FieldError ) {
52
+ func (a * EC2NodeClass ) Validate (ctx context.Context ) (errs * apis.FieldError ) {
53
53
return errs .Also (
54
54
apis .ValidateObjectMetadata (a ).ViaField ("metadata" ),
55
55
a .Spec .validate (ctx ).ViaField ("spec" ),
56
56
)
57
57
}
58
58
59
- func (in * NodeClassSpec ) validate (_ context.Context ) (errs * apis.FieldError ) {
59
+ func (in * EC2NodeClassSpec ) validate (_ context.Context ) (errs * apis.FieldError ) {
60
60
return errs .Also (
61
61
in .validateSubnetSelectorTerms ().ViaField (subnetSelectorTermsPath ),
62
62
in .validateSecurityGroupSelectorTerms ().ViaField (securityGroupSelectorTermsPath ),
@@ -69,7 +69,7 @@ func (in *NodeClassSpec) validate(_ context.Context) (errs *apis.FieldError) {
69
69
)
70
70
}
71
71
72
- func (in * NodeClassSpec ) validateSubnetSelectorTerms () (errs * apis.FieldError ) {
72
+ func (in * EC2NodeClassSpec ) validateSubnetSelectorTerms () (errs * apis.FieldError ) {
73
73
if len (in .SubnetSelectorTerms ) == 0 {
74
74
errs = errs .Also (apis .ErrMissingOneOf ())
75
75
}
@@ -89,7 +89,7 @@ func (in *SubnetSelectorTerm) validate() (errs *apis.FieldError) {
89
89
return errs
90
90
}
91
91
92
- func (in * NodeClassSpec ) validateSecurityGroupSelectorTerms () (errs * apis.FieldError ) {
92
+ func (in * EC2NodeClassSpec ) validateSecurityGroupSelectorTerms () (errs * apis.FieldError ) {
93
93
if len (in .SecurityGroupSelectorTerms ) == 0 {
94
94
errs = errs .Also (apis .ErrMissingOneOf ())
95
95
}
@@ -112,7 +112,7 @@ func (in *SecurityGroupSelectorTerm) validate() (errs *apis.FieldError) {
112
112
return errs
113
113
}
114
114
115
- func (in * NodeClassSpec ) validateAMISelectorTerms () (errs * apis.FieldError ) {
115
+ func (in * EC2NodeClassSpec ) validateAMISelectorTerms () (errs * apis.FieldError ) {
116
116
for _ , term := range in .AMISelectorTerms {
117
117
errs = errs .Also (term .validate ())
118
118
}
@@ -122,9 +122,9 @@ func (in *NodeClassSpec) validateAMISelectorTerms() (errs *apis.FieldError) {
122
122
//nolint:gocyclo
123
123
func (in * AMISelectorTerm ) validate () (errs * apis.FieldError ) {
124
124
errs = errs .Also (validateTags (in .Tags ).ViaField ("tags" ))
125
- if len (in .Tags ) == 0 && in .ID == "" && in .Name == "" && in . SSM == "" {
126
- errs = errs .Also (apis .ErrGeneric ("expect at least one, got none" , "tags" , "id" , "name" , "ssm" ))
127
- } else if in .ID != "" && (len (in .Tags ) > 0 || in .Name != "" || in .SSM != "" || in . Owner != "" ) {
125
+ if len (in .Tags ) == 0 && in .ID == "" && in .Name == "" {
126
+ errs = errs .Also (apis .ErrGeneric ("expect at least one, got none" , "tags" , "id" , "name" ))
127
+ } else if in .ID != "" && (len (in .Tags ) > 0 || in .Name != "" || in .Owner != "" ) {
128
128
errs = errs .Also (apis .ErrGeneric (`"id" is mutually exclusive, cannot be set with a combination of other fields in` ))
129
129
}
130
130
return errs
@@ -142,7 +142,7 @@ func validateTags(m map[string]string) (errs *apis.FieldError) {
142
142
return errs
143
143
}
144
144
145
- func (in * NodeClassSpec ) validateMetadataOptions () (errs * apis.FieldError ) {
145
+ func (in * EC2NodeClassSpec ) validateMetadataOptions () (errs * apis.FieldError ) {
146
146
if in .MetadataOptions == nil {
147
147
return nil
148
148
}
@@ -154,21 +154,21 @@ func (in *NodeClassSpec) validateMetadataOptions() (errs *apis.FieldError) {
154
154
)
155
155
}
156
156
157
- func (in * NodeClassSpec ) validateHTTPEndpoint () * apis.FieldError {
157
+ func (in * EC2NodeClassSpec ) validateHTTPEndpoint () * apis.FieldError {
158
158
if in .MetadataOptions .HTTPEndpoint == nil {
159
159
return nil
160
160
}
161
161
return in .validateStringEnum (* in .MetadataOptions .HTTPEndpoint , "httpEndpoint" , ec2 .LaunchTemplateInstanceMetadataEndpointState_Values ())
162
162
}
163
163
164
- func (in * NodeClassSpec ) validateHTTPProtocolIpv6 () * apis.FieldError {
164
+ func (in * EC2NodeClassSpec ) validateHTTPProtocolIpv6 () * apis.FieldError {
165
165
if in .MetadataOptions .HTTPProtocolIPv6 == nil {
166
166
return nil
167
167
}
168
168
return in .validateStringEnum (* in .MetadataOptions .HTTPProtocolIPv6 , "httpProtocolIPv6" , ec2 .LaunchTemplateInstanceMetadataProtocolIpv6_Values ())
169
169
}
170
170
171
- func (in * NodeClassSpec ) validateHTTPPutResponseHopLimit () * apis.FieldError {
171
+ func (in * EC2NodeClassSpec ) validateHTTPPutResponseHopLimit () * apis.FieldError {
172
172
if in .MetadataOptions .HTTPPutResponseHopLimit == nil {
173
173
return nil
174
174
}
@@ -179,14 +179,14 @@ func (in *NodeClassSpec) validateHTTPPutResponseHopLimit() *apis.FieldError {
179
179
return nil
180
180
}
181
181
182
- func (in * NodeClassSpec ) validateHTTPTokens () * apis.FieldError {
182
+ func (in * EC2NodeClassSpec ) validateHTTPTokens () * apis.FieldError {
183
183
if in .MetadataOptions .HTTPTokens == nil {
184
184
return nil
185
185
}
186
186
return in .validateStringEnum (* in .MetadataOptions .HTTPTokens , "httpTokens" , ec2 .LaunchTemplateHttpTokensState_Values ())
187
187
}
188
188
189
- func (in * NodeClassSpec ) validateStringEnum (value , field string , validValues []string ) * apis.FieldError {
189
+ func (in * EC2NodeClassSpec ) validateStringEnum (value , field string , validValues []string ) * apis.FieldError {
190
190
for _ , validValue := range validValues {
191
191
if value == validValue {
192
192
return nil
@@ -195,7 +195,7 @@ func (in *NodeClassSpec) validateStringEnum(value, field string, validValues []s
195
195
return apis .ErrInvalidValue (fmt .Sprintf ("%s not in %v" , value , strings .Join (validValues , ", " )), field )
196
196
}
197
197
198
- func (in * NodeClassSpec ) validateBlockDeviceMappings () (errs * apis.FieldError ) {
198
+ func (in * EC2NodeClassSpec ) validateBlockDeviceMappings () (errs * apis.FieldError ) {
199
199
for i , blockDeviceMapping := range in .BlockDeviceMappings {
200
200
if err := in .validateBlockDeviceMapping (blockDeviceMapping ); err != nil {
201
201
errs = errs .Also (err .ViaFieldIndex (blockDeviceMappingsPath , i ))
@@ -204,18 +204,18 @@ func (in *NodeClassSpec) validateBlockDeviceMappings() (errs *apis.FieldError) {
204
204
return errs
205
205
}
206
206
207
- func (in * NodeClassSpec ) validateBlockDeviceMapping (blockDeviceMapping * BlockDeviceMapping ) (errs * apis.FieldError ) {
207
+ func (in * EC2NodeClassSpec ) validateBlockDeviceMapping (blockDeviceMapping * BlockDeviceMapping ) (errs * apis.FieldError ) {
208
208
return errs .Also (in .validateDeviceName (blockDeviceMapping ), in .validateEBS (blockDeviceMapping ))
209
209
}
210
210
211
- func (in * NodeClassSpec ) validateDeviceName (blockDeviceMapping * BlockDeviceMapping ) * apis.FieldError {
211
+ func (in * EC2NodeClassSpec ) validateDeviceName (blockDeviceMapping * BlockDeviceMapping ) * apis.FieldError {
212
212
if blockDeviceMapping .DeviceName == nil {
213
213
return apis .ErrMissingField ("deviceName" )
214
214
}
215
215
return nil
216
216
}
217
217
218
- func (in * NodeClassSpec ) validateEBS (blockDeviceMapping * BlockDeviceMapping ) (errs * apis.FieldError ) {
218
+ func (in * EC2NodeClassSpec ) validateEBS (blockDeviceMapping * BlockDeviceMapping ) (errs * apis.FieldError ) {
219
219
if blockDeviceMapping .EBS == nil {
220
220
return apis .ErrMissingField ("ebs" )
221
221
}
@@ -230,14 +230,14 @@ func (in *NodeClassSpec) validateEBS(blockDeviceMapping *BlockDeviceMapping) (er
230
230
return errs
231
231
}
232
232
233
- func (in * NodeClassSpec ) validateVolumeType (blockDeviceMapping * BlockDeviceMapping ) * apis.FieldError {
233
+ func (in * EC2NodeClassSpec ) validateVolumeType (blockDeviceMapping * BlockDeviceMapping ) * apis.FieldError {
234
234
if blockDeviceMapping .EBS .VolumeType != nil {
235
235
return in .validateStringEnum (* blockDeviceMapping .EBS .VolumeType , "volumeType" , ec2 .VolumeType_Values ())
236
236
}
237
237
return nil
238
238
}
239
239
240
- func (in * NodeClassSpec ) validateVolumeSize (blockDeviceMapping * BlockDeviceMapping ) * apis.FieldError {
240
+ func (in * EC2NodeClassSpec ) validateVolumeSize (blockDeviceMapping * BlockDeviceMapping ) * apis.FieldError {
241
241
// If an EBS mapping is present, one of volumeSize or snapshotID must be present
242
242
if blockDeviceMapping .EBS .SnapshotID != nil && blockDeviceMapping .EBS .VolumeSize == nil {
243
243
return nil
@@ -249,7 +249,7 @@ func (in *NodeClassSpec) validateVolumeSize(blockDeviceMapping *BlockDeviceMappi
249
249
return nil
250
250
}
251
251
252
- func (in * NodeClassSpec ) validateUserData () (errs * apis.FieldError ) {
252
+ func (in * EC2NodeClassSpec ) validateUserData () (errs * apis.FieldError ) {
253
253
if in .UserData == nil {
254
254
return nil
255
255
}
@@ -259,7 +259,7 @@ func (in *NodeClassSpec) validateUserData() (errs *apis.FieldError) {
259
259
return errs
260
260
}
261
261
262
- func (in * NodeClassSpec ) validateAMIFamily () (errs * apis.FieldError ) {
262
+ func (in * EC2NodeClassSpec ) validateAMIFamily () (errs * apis.FieldError ) {
263
263
if in .AMIFamily == nil {
264
264
return nil
265
265
}
@@ -269,7 +269,7 @@ func (in *NodeClassSpec) validateAMIFamily() (errs *apis.FieldError) {
269
269
return errs .Also (in .validateStringEnum (* in .AMIFamily , amiFamilyPath , SupportedAMIFamilies ))
270
270
}
271
271
272
- func (in * NodeClassSpec ) validateTags () (errs * apis.FieldError ) {
272
+ func (in * EC2NodeClassSpec ) validateTags () (errs * apis.FieldError ) {
273
273
for k , v := range in .Tags {
274
274
if k == "" {
275
275
errs = errs .Also (apis .ErrInvalidValue (fmt .Sprintf (
0 commit comments