Skip to content

Commit

Permalink
Merge pull request #924 from spidernet-io/update/webhook
Browse files Browse the repository at this point in the history
Update the webhook validation process for egressgateway
  • Loading branch information
weizhoublue authored Nov 3, 2023
2 parents 9e8c5dc + 4688c6c commit 5d48e2d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/egressgateway/egress_gateway_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ func (egw *EgressGatewayWebhook) EgressGatewayValidate(ctx context.Context, req
return webhook.Denied(fmt.Sprintf("json unmarshal EgressGateway with error: %v", err))
}

if egw.Config.FileConfig.EnableIPv4 && !egw.Config.FileConfig.EnableIPv6 {
if len(newEg.Spec.Ippools.IPv6) != 0 {
return webhook.Denied("Please do not configure spec.ippools.ipv6, as the current installation settings have not enabled IPv6")
}
}
if !egw.Config.FileConfig.EnableIPv4 && egw.Config.FileConfig.EnableIPv6 {
if len(newEg.Spec.Ippools.IPv4) != 0 {
return webhook.Denied("Please do not configure spec.ippools.ipv4, as the current installation settings have not enabled IPv4")
}
}

if newEg.Spec.ClusterDefault {
egwList := new(egress.EgressGatewayList)
for _, item := range egwList.Items {
Expand Down

0 comments on commit 5d48e2d

Please sign in to comment.