Skip to content

Commit 0c17b0e

Browse files
committed
fixes #3839 support vpc-<uuid> in target groups binding validation
1 parent e1d32f4 commit 0c17b0e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

webhooks/elbv2/targetgroupbinding_validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const apiPathValidateELBv2TargetGroupBinding = "/validate-elbv2-k8s-aws-v1beta1-targetgroupbinding"
2323

24-
var vpcIDPatternRegex = regexp.MustCompile("^(?:vpc-[0-9a-f]{8}|vpc-[0-9a-f]{17})$")
24+
var vpcIDPatternRegex = regexp.MustCompile("^(?:vpc-[0-9a-f]{8}|vpc-[0-9a-f]{17}|vpc-[0-9a-f]{32})$")
2525

2626
// NewTargetGroupBindingValidator returns a validator for TargetGroupBinding CRD.
2727
func NewTargetGroupBindingValidator(k8sClient client.Client, elbv2Client services.ELBV2, vpcID string, logger logr.Logger) *targetGroupBindingValidator {
@@ -169,7 +169,7 @@ func (v *targetGroupBindingValidator) checkTargetGroupVpcID(ctx context.Context,
169169
return nil
170170
}
171171
if !vpcIDPatternRegex.MatchString(tgb.Spec.VpcID) {
172-
return errors.Errorf("ValidationError: vpcID %v failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8 or 17 lowercase letters (a-f) or numbers.", tgb.Spec.VpcID)
172+
return errors.Errorf("ValidationError: vpcID %v failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8, 17 or 32 lowercase letters (a-f) or numbers.", tgb.Spec.VpcID)
173173
}
174174
vpcID, err := v.getVpcIDFromAWS(ctx, tgb.Spec.TargetGroupARN)
175175
if err != nil {

webhooks/elbv2/targetgroupbinding_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ func Test_targetGroupBindingValidator_checkTargetGroupVpcID(t *testing.T) {
11461146
},
11471147
},
11481148
},
1149-
wantErr: errors.New("ValidationError: vpcID vpcid-@34!dv failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8 or 17 lowercase letters (a-f) or numbers."),
1149+
wantErr: errors.New("ValidationError: vpcID vpcid-@34!dv failed to satisfy constraint: VPC Id must begin with 'vpc-' followed by 8, 17 or 32 lowercase letters (a-f) or numbers."),
11501150
},
11511151
}
11521152
for _, tt := range tests {

0 commit comments

Comments
 (0)