mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-24 15:55:17 -04:00
terraform-provider: validate pod ip cidr only on gcp (#2838)
This commit is contained in:
parent
4db0662b06
commit
5faa374ede
2 changed files with 45 additions and 3 deletions
|
@ -215,9 +215,6 @@ func (r *ClusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re
|
|||
MarkdownDescription: "CIDR range of the cluster's pod network. Only required for clusters running on GCP.",
|
||||
Description: "CIDR range of the cluster's pod network. Only required for clusters running on GCP.",
|
||||
Optional: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.RegexMatches(cidrRegex, "Pod IP CIDR must be a valid CIDR range."),
|
||||
},
|
||||
},
|
||||
"ip_cidr_service": schema.StringAttribute{
|
||||
MarkdownDescription: "CIDR range of the cluster's service network.",
|
||||
|
@ -673,6 +670,16 @@ func (r *ClusterResource) validateGCPNetworkConfig(ctx context.Context, data *Cl
|
|||
"Pod IP CIDR not allowed", "When csp is not set to 'gcp', setting 'ip_cidr_pod' has no effect.",
|
||||
)
|
||||
}
|
||||
|
||||
// Pod IP CIDR should be a valid CIDR on GCP
|
||||
if strings.EqualFold(data.CSP.ValueString(), cloudprovider.GCP.String()) &&
|
||||
!cidrRegex.MatchString(networkCfg.IPCidrPod.ValueString()) {
|
||||
diags.AddAttributeError(
|
||||
path.Root("network_config").AtName("ip_pod_cidr"),
|
||||
"Invalid CIDR range", "Pod IP CIDR must be a valid CIDR range.",
|
||||
)
|
||||
}
|
||||
|
||||
return diags
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue