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 authored and keyki committed Mar 28, 2024
1 parent 1292c53 commit d39b8f0
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 147 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ matrix.go-version }}
cache: false
- name: Setup Terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: '1.5.*'
terraform_wrapper: false

- name: Run linters
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: latest
args: --timeout 3m

- name: Generate
Expand All @@ -53,9 +53,8 @@ jobs:
with:
go-version-file: 'go.mod'
- name: Run linters
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: latest
args: --timeout 3m

test:
Expand Down
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 d39b8f0

Please sign in to comment.