Skip to content

Commit

Permalink
fixup! terraform-provider: lock-step microservice version (#2733)
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Dec 21, 2023
1 parent 3765be7 commit 859c596
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ type ClusterResourceModel struct {
}

// networkConfigAttribute is the network config attribute's data model.
// needs basetypes because the struct is used in ValidateConfig where these values might still be unknown. A go string type cannot handle unknown values.
type networkConfigAttribute struct {
IPCidrNode string `tfsdk:"ip_cidr_node"`
IPCidrPod string `tfsdk:"ip_cidr_pod"`
IPCidrService string `tfsdk:"ip_cidr_service"`
IPCidrNode basetypes.StringValue `tfsdk:"ip_cidr_node"`
IPCidrPod basetypes.StringValue `tfsdk:"ip_cidr_pod"`
IPCidrService basetypes.StringValue `tfsdk:"ip_cidr_service"`
}

// gcpAttribute is the gcp attribute's data model.
Expand Down Expand Up @@ -406,14 +407,14 @@ func (r *ClusterResource) ValidateConfig(ctx context.Context, req resource.Valid
return
}
// Pod IP CIDR is required for GCP
if strings.EqualFold(data.CSP.ValueString(), cloudprovider.GCP.String()) && networkCfg.IPCidrPod == "" {
if strings.EqualFold(data.CSP.ValueString(), cloudprovider.GCP.String()) && networkCfg.IPCidrPod.ValueString() == "" {
resp.Diagnostics.AddAttributeError(
path.Root("network_config").AtName("ip_cidr_pod"),
"Pod IP CIDR missing", "When csp is set to 'gcp', 'ip_cidr_pod' must be set.",
)
}
// Pod IP CIDR should not be set for other CSPs
if !strings.EqualFold(data.CSP.ValueString(), cloudprovider.GCP.String()) && networkCfg.IPCidrPod != "" {
if !strings.EqualFold(data.CSP.ValueString(), cloudprovider.GCP.String()) && networkCfg.IPCidrPod.ValueString() != "" {
resp.Diagnostics.AddAttributeWarning(
path.Root("network_config").AtName("ip_cidr_pod"),
"Pod IP CIDR not allowed", "When csp is not set to 'gcp', setting 'ip_cidr_pod' has no effect.",
Expand Down Expand Up @@ -783,7 +784,7 @@ func (r *ClusterResource) apply(ctx context.Context, data *ClusterResourceModel,
InitSecret: []byte(data.InitSecret.ValueString()),
APIServerCertSANs: apiServerCertSANs,
Name: data.Name.ValueString(),
IPCidrNode: networkCfg.IPCidrNode,
IPCidrNode: networkCfg.IPCidrNode.ValueString(),
})
switch csp {
case cloudprovider.Azure:
Expand All @@ -798,7 +799,7 @@ func (r *ClusterResource) apply(ctx context.Context, data *ClusterResourceModel,
case cloudprovider.GCP:
stateFile.Infrastructure.GCP = &state.GCP{
ProjectID: gcpConfig.ProjectID,
IPCidrPod: networkCfg.IPCidrPod,
IPCidrPod: networkCfg.IPCidrPod.ValueString(),
}
}

Expand Down Expand Up @@ -933,7 +934,7 @@ func (r *ClusterResource) runInitRPC(ctx context.Context, applier *constellation
MeasurementSalt: payload.measurementSalt,
K8sVersion: payload.k8sVersion,
ConformanceMode: false, // Conformance mode does't need to be configurable through the TF provider for now.
ServiceCIDR: payload.networkCfg.IPCidrService,
ServiceCIDR: payload.networkCfg.IPCidrService.ValueString(),
})
if err != nil {
var nonRetriable *constellation.NonRetriableInitError
Expand Down

0 comments on commit 859c596

Please sign in to comment.