Skip to content

Commit 7be0737

Browse files
committed
chore: add kubeconfig validation on update
Signed-off-by: Artur Shad Nik <arturshadnik@gmail.com>
1 parent d82a541 commit 7be0737

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fleetconfig-controller/internal/webhook/v1beta1/spoke_webhook.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,19 @@ func (v *SpokeCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newOb
143143
return nil, err
144144
}
145145

146-
warn, allErrs := validateAddons(ctx, v.client, spoke)
146+
var (
147+
allErrs field.ErrorList
148+
warn admission.Warnings
149+
)
150+
151+
valid, msg := isKubeconfigValid(spoke.Spec.Kubeconfig)
152+
if !valid {
153+
allErrs = append(allErrs, field.Invalid(
154+
field.NewPath("spec").Child("kubeconfig"), spoke, msg),
155+
)
156+
}
157+
158+
warn, allErrs = validateAddons(ctx, v.client, spoke)
147159

148160
if len(allErrs) > 0 {
149161
return warn, errors.NewInvalid(v1beta1.SpokeGroupKind, spoke.Name, allErrs)

0 commit comments

Comments
 (0)