Skip to content

Commit e55ba3e

Browse files
author
Simon Emms
committed
[installer]: add recommended secret checks
If field(s) not found, it returns a warning rather than an error
1 parent f3da7ba commit e55ba3e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

components/installer/pkg/cluster/checks.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ func checkKubernetesVersion(ctx context.Context, config *rest.Config, namespace
170170
}
171171

172172
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)
175176
}
176177

177178
type CheckSecretOpt func(*checkSecretOpts)
@@ -182,6 +183,12 @@ func CheckSecretRequiredData(entries ...string) CheckSecretOpt {
182183
}
183184
}
184185

186+
func CheckSecretRecommendedData(entries ...string) CheckSecretOpt {
187+
return func(cso *checkSecretOpts) {
188+
cso.RecommendedFields = append(cso.RecommendedFields, entries...)
189+
}
190+
}
191+
185192
func CheckSecretRule(validator func(*corev1.Secret) ([]ValidationError, error)) CheckSecretOpt {
186193
return func(cso *checkSecretOpts) {
187194
cso.Validator = validator
@@ -226,6 +233,15 @@ func CheckSecret(name string, opts ...CheckSecretOpt) ValidationCheck {
226233
})
227234
}
228235
}
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+
}
229245

230246
if cfg.Validator != nil {
231247
vres, err := cfg.Validator(secret)

0 commit comments

Comments
 (0)