Skip to content

Commit

Permalink
CDPCP-11068 Flexible server support
Browse files Browse the repository at this point in the history
  • Loading branch information
daszabo committed Jan 24, 2024
1 parent 91409e8 commit 0c132ea
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 22 deletions.
7 changes: 4 additions & 3 deletions resources/environments/environment_action_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ package environments

import (
"context"
"time"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-log/tflog"
"time"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/environments/client/operations"
Expand Down Expand Up @@ -55,13 +56,13 @@ func deleteEnvironmentWithDiagnosticHandle(environmentName string, ctx context.C
params.WithInput(&environmentsmodels.DeleteEnvironmentRequest{EnvironmentName: &environmentName})
_, err := client.Environments.Operations.DeleteEnvironment(params)
if err != nil {
utils.AddEnvironmentDiagnosticsError(err, &resp.Diagnostics, "delete AWS Environment")
utils.AddEnvironmentDiagnosticsError(err, &resp.Diagnostics, "delete Environment")
return err
}

err = waitForEnvironmentToBeDeleted(environmentName, timeoutOneHour, client.Environments, ctx, pollingTimeout)
if err != nil {
utils.AddEnvironmentDiagnosticsError(err, &resp.Diagnostics, "delete AWS Environment")
utils.AddEnvironmentDiagnosticsError(err, &resp.Diagnostics, "delete Environment")
return err
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions resources/environments/model_azure_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type existingAzureNetwork struct {
ResourceGroupName types.String `tfsdk:"resource_group_name"`

SubnetIds types.Set `tfsdk:"subnet_ids"`

FlexibleServerSubnetIds types.Set `tfsdk:"flexible_server_subnet_ids"`
}

type azureFreeIpaDetails struct {
Expand Down
7 changes: 7 additions & 0 deletions resources/environments/resource_azure_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package environments

import (
"context"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -155,6 +156,8 @@ func toAzureEnvironmentResource(ctx context.Context, env *environmentsmodels.Env
if env.Network.Azure != nil {
subnetIds, snDiags := types.SetValueFrom(ctx, types.StringType, env.Network.SubnetIds)
diags.Append(snDiags...)
flexSubnetIds, fsDiags := types.SetValueFrom(ctx, types.StringType, env.Network.Azure.FlexibleServerSubnetIds)
diags.Append(fsDiags...)
var enpDiags diag.Diagnostics
model.ExistingNetworkParams, enpDiags = types.ObjectValueFrom(ctx, map[string]attr.Type{
"aks_private_dns_zone_id": types.StringType,
Expand All @@ -164,12 +167,16 @@ func toAzureEnvironmentResource(ctx context.Context, env *environmentsmodels.Env
"subnet_ids": types.SetType{
ElemType: types.StringType,
},
"flexible_server_subnet_ids": types.SetType{
ElemType: types.StringType,
},
}, &existingAzureNetwork{
AksPrivateDNSZoneID: types.StringValue(env.Network.Azure.AksPrivateDNSZoneID),
DatabasePrivateDNSZoneID: types.StringValue(env.Network.Azure.DatabasePrivateDNSZoneID),
NetworkID: types.StringPointerValue(env.Network.Azure.NetworkID),
ResourceGroupName: types.StringPointerValue(env.Network.Azure.ResourceGroupName),
SubnetIds: subnetIds,
FlexibleServerSubnetIds: flexSubnetIds,
})
diags.Append(enpDiags...)
model.UsePublicIP = types.BoolPointerValue(env.Network.Azure.UsePublicIP)
Expand Down
Loading

0 comments on commit 0c132ea

Please sign in to comment.