@@ -170,8 +170,9 @@ func checkKubernetesVersion(ctx context.Context, config *rest.Config, namespace
170
170
}
171
171
172
172
type checkSecretOpts struct {
173
- RequiredFields []string
174
- Validator func (* corev1.Secret ) ([]ValidationError , error )
173
+ RequiredFields []string
174
+ RecommendedFields []string
175
+ Validator func (* corev1.Secret ) ([]ValidationError , error )
175
176
}
176
177
177
178
type CheckSecretOpt func (* checkSecretOpts )
@@ -182,6 +183,12 @@ func CheckSecretRequiredData(entries ...string) CheckSecretOpt {
182
183
}
183
184
}
184
185
186
+ func CheckSecretRecommendedData (entries ... string ) CheckSecretOpt {
187
+ return func (cso * checkSecretOpts ) {
188
+ cso .RecommendedFields = append (cso .RecommendedFields , entries ... )
189
+ }
190
+ }
191
+
185
192
func CheckSecretRule (validator func (* corev1.Secret ) ([]ValidationError , error )) CheckSecretOpt {
186
193
return func (cso * checkSecretOpts ) {
187
194
cso .Validator = validator
@@ -226,6 +233,15 @@ func CheckSecret(name string, opts ...CheckSecretOpt) ValidationCheck {
226
233
})
227
234
}
228
235
}
236
+ for _ , k := range cfg .RecommendedFields {
237
+ _ , ok := secret .Data [k ]
238
+ if ! ok {
239
+ res = append (res , ValidationError {
240
+ Message : fmt .Sprintf ("secret %s has no %s entry" , name , k ),
241
+ Type : ValidationStatusWarning ,
242
+ })
243
+ }
244
+ }
229
245
230
246
if cfg .Validator != nil {
231
247
vres , err := cfg .Validator (secret )
0 commit comments