Skip to content

Commit 8be6e84

Browse files
Kamil PrzybylKamil Przybyl
authored andcommitted
feat: check for AnnotationInternal immutability
1 parent 3e58652 commit 8be6e84

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/alb/ingress/ingressclass_webhook.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ func (v *IngressClassValidator) handleUpdate(ctx context.Context, req admission.
7777
return resp
7878
}
7979

80+
// Check immutability for AnnotationInternal
81+
oldInternal := oldClass.Annotations[AnnotationInternal]
82+
newInternal := newClass.Annotations[AnnotationInternal]
83+
if oldInternal != newInternal {
84+
return admission.Denied(fmt.Sprintf("The annotation '%s' is immutable and cannot be changed after creation.", AnnotationInternal))
85+
}
86+
8087
if resp := v.validateIPUpdate(ctx, oldClass, newClass); !resp.Allowed {
8188
return resp
8289
}
@@ -92,6 +99,13 @@ func (v *IngressClassValidator) validateBaseAnnotations(ingressClass *networking
9299
}
93100
}
94101

102+
// Check if AnnotationInternal is a boolean.
103+
if val, ok := ingressClass.Annotations[AnnotationInternal]; ok {
104+
if _, err := strconv.ParseBool(val); err != nil {
105+
return admission.Denied(fmt.Sprintf("Annotation '%s' must be a valid boolean (true or false).", AnnotationInternal))
106+
}
107+
}
108+
95109
// Network Mode Check.
96110
mode, exists := ingressClass.Annotations[AnnotationNetworkMode]
97111
if !exists {

0 commit comments

Comments
 (0)