Skip to content

Commit

Permalink
CDPCP-11698 Added missing fields to Azure Datalake resource
Browse files Browse the repository at this point in the history
  • Loading branch information
daszabo committed Mar 28, 2024
1 parent c49692e commit 1af9158
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 143 deletions.
3 changes: 3 additions & 0 deletions docs/resources/datalake_azure_datalake.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ A Data Lake is a service which provides a protective ring around the data stored

- `database_type` (String) The type of the azure database. FLEXIBLE_SERVER is the next generation managed PostgreSQL service in Azure that provides maximum flexibility over your database, built-in cost-optimizations. SINGLE_SERVER is a fully managed database service with minimal requirements for customizations of the database.
- `enable_ranger_raz` (Boolean)
- `flexible_server_delegated_subnet_id` (String) This argument allows you to specify the subnet ID for the subnet within which you want to configure your Azure Flexible Server.
- `image` (Attributes) (see [below for nested schema](#nestedatt--image))
- `java_version` (Number)
- `load_balancer_sku` (String) Represents the Azure load balancer SKU type. The current default is BASIC. To disable the load balancer, use type NONE. Possible values: BASIC, STANDARD, NONE
- `multi_az` (Boolean) Creates CDP datalake distributed across multiple availability zones in an Azure region.
- `polling_options` (Attributes) Polling related configuration options that could specify various values that will be used during CDP resource creation. (see [below for nested schema](#nestedatt--polling_options))
- `recipes` (Attributes Set) (see [below for nested schema](#nestedatt--recipes))
- `runtime` (String)
Expand Down
6 changes: 3 additions & 3 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ func TestCdpProvider_Schema(t *testing.T) {
sresps = append(sresps, attribute)
}

unexpectedFields, missingFields := testUtil.CompareStrings(sresps, expectedSchemaFields)
unexpectedFields, missingFields := testUtil.CompareStringSlices(sresps, expectedSchemaFields)

if len(unexpectedFields) > 0 {
t.Errorf("The following unexpected field(s) got introduced: %s", strings.Join(unexpectedFields, ","))
Expand Down Expand Up @@ -720,13 +720,13 @@ func TestCdpProvider_DataSources(t *testing.T) {
func compareResources(actual, expected []func() resource.Resource) (unexpected, missing []string) {
actualNames := testUtil.ToStringSliceFunc(actual, getPackageAndNameOfResource)
expectedNames := testUtil.ToStringSliceFunc(expected, getPackageAndNameOfResource)
return testUtil.CompareStrings(actualNames, expectedNames)
return testUtil.CompareStringSlices(actualNames, expectedNames)
}

func compareDataSources(actual, expected []func() datasource.DataSource) (unexpected, missing []string) {
actualNames := testUtil.ToStringSliceFunc(actual, getPackageAndNameOfDataSource)
expectedNames := testUtil.ToStringSliceFunc(expected, getPackageAndNameOfDataSource)
return testUtil.CompareStrings(actualNames, expectedNames)
return testUtil.CompareStringSlices(actualNames, expectedNames)
}

func getPackageAndNameOfResource(f func() resource.Resource) string {
Expand Down
17 changes: 6 additions & 11 deletions resources/datahub/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"

datahubmodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datahub/models"
"github.com/cloudera/terraform-provider-cdp/utils"
)

func fromModelToAwsRequest(model awsDatahubResourceModel, ctx context.Context) *datahubmodels.CreateAWSClusterRequest {
Expand Down Expand Up @@ -49,7 +50,7 @@ func fromModelToAwsRequest(model awsDatahubResourceModel, ctx context.Context) *
InstanceGroupName: group.InstanceGroupName.ValueStringPointer(),
InstanceGroupType: group.InstanceGroupType.ValueStringPointer(),
InstanceType: group.InstanceType.ValueStringPointer(),
NodeCount: int64To32Pointer(group.NodeCount),
NodeCount: utils.Int64To32Pointer(group.NodeCount),
RecipeNames: igRecipes,
RecoveryMode: group.RecoveryMode.ValueString(),
RootVolumeSize: int64To32(group.RootVolumeSize),
Expand Down Expand Up @@ -131,7 +132,7 @@ func fromModelToGcpRequest(model gcpDatahubResourceModel, ctx context.Context) *
InstanceGroupName: group.InstanceGroupName.ValueStringPointer(),
InstanceGroupType: group.InstanceGroupType.ValueStringPointer(),
InstanceType: group.InstanceType.ValueStringPointer(),
NodeCount: int64To32Pointer(group.NodeCount),
NodeCount: utils.Int64To32Pointer(group.NodeCount),
RecipeNames: igRecipes,
RecoveryMode: group.RecoveryMode.ValueString(),
RootVolumeSize: &volumeSize,
Expand Down Expand Up @@ -210,7 +211,7 @@ func fromModelToAzureRequest(model azureDatahubResourceModel, ctx context.Contex
InstanceGroupName: group.InstanceGroupName.ValueStringPointer(),
InstanceGroupType: group.InstanceGroupType.ValueStringPointer(),
InstanceType: group.InstanceType.ValueStringPointer(),
NodeCount: int64To32Pointer(group.NodeCount),
NodeCount: utils.Int64To32Pointer(group.NodeCount),
RecipeNames: igRecipes,
RecoveryMode: group.RecoveryMode.ValueString(),
RootVolumeSize: &rootVolumeSize,
Expand Down Expand Up @@ -259,8 +260,8 @@ func fromModelToAzureRequest(model azureDatahubResourceModel, ctx context.Contex

func createAttachedVolumeRequest(attachedVolumeConfig AttachedVolumeConfiguration) *datahubmodels.AttachedVolumeRequest {
return &datahubmodels.AttachedVolumeRequest{
VolumeCount: int64To32Pointer(attachedVolumeConfig.VolumeCount),
VolumeSize: int64To32Pointer(attachedVolumeConfig.VolumeSize),
VolumeCount: utils.Int64To32Pointer(attachedVolumeConfig.VolumeCount),
VolumeSize: utils.Int64To32Pointer(attachedVolumeConfig.VolumeSize),
VolumeType: attachedVolumeConfig.VolumeType.ValueStringPointer(),
}
}
Expand All @@ -269,9 +270,3 @@ func int64To32(in types.Int64) int32 {
n64 := in.ValueInt64()
return int32(n64)
}

func int64To32Pointer(in types.Int64) *int32 {
n64 := in.ValueInt64()
var n2 = int32(n64)
return &n2
}
Loading

0 comments on commit 1af9158

Please sign in to comment.