Skip to content

Commit

Permalink
CDPCP-11225 - Expose databaseType field in DL and DH resources (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregito authored Feb 12, 2024
1 parent bc5e0b1 commit c5ab46e
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/resources/datahub_azure_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ output "encryption" {

### Optional

- `database_type` (String)
- `destroy_options` (Attributes) Cluster deletion options. (see [below for nested schema](#nestedatt--destroy_options))
- `instance_group` (Attributes List) (see [below for nested schema](#nestedatt--instance_group))
- `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))
Expand Down
1 change: 1 addition & 0 deletions docs/resources/datalake_azure_datalake.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ A Data Lake is a service which provides a protective ring around the data stored

### Optional

- `database_type` (Number) 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)
- `image` (Attributes) (see [below for nested schema](#nestedatt--image))
- `java_version` (Number)
Expand Down
1 change: 1 addition & 0 deletions resources/datahub/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func fromModelToGcpRequest(model gcpDatahubResourceModel, ctx context.Context) *
func fromModelToAzureRequest(model datahubResourceModel, ctx context.Context) *datahubmodels.CreateAzureClusterRequest {
debug(ctx, "Conversion from datahubResourceModel to CreateAzureClusterRequest started.")
req := datahubmodels.CreateAzureClusterRequest{}
req.DatabaseType = model.DatabaseType.ValueString()
req.ClusterName = model.Name.ValueString()
req.ClusterTemplateName = model.ClusterTemplate.ValueString()
req.EnvironmentName = model.Environment.ValueString()
Expand Down
1 change: 1 addition & 0 deletions resources/datahub/model_datahub.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type datahubResourceModel struct {
Name types.String `tfsdk:"name"`
Status types.String `tfsdk:"status"`
Environment types.String `tfsdk:"environment"`
DatabaseType types.String `tfsdk:"database_type"`
GcpEnvironment types.String `tfsdk:"environment_name"`
InstanceGroup []InstanceGroup `tfsdk:"instance_group"`
PollingOptions *utils.PollingOptions `tfsdk:"polling_options"`
Expand Down
11 changes: 11 additions & 0 deletions resources/datahub/schema_azure_datahub.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"

"github.com/cloudera/terraform-provider-cdp/utils"
)
Expand All @@ -22,6 +24,15 @@ func (r *azureDatahubResource) Schema(_ context.Context, _ resource.SchemaReques
attr := map[string]schema.Attribute{}
utils.Append(attr, generalAttributes)
utils.Append(attr, instanceGroupSchemaAttributes)
utils.Append(attr, map[string]schema.Attribute{
"database_type": schema.StringAttribute{
Optional: true,
Computed: false,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
})
resp.Schema = schema.Schema{
MarkdownDescription: "Creates an Azure Data hub cluster.",
Attributes: attr,
Expand Down
13 changes: 13 additions & 0 deletions resources/datahub/schema_azure_datahub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ func TestAzureSchemaContainsInstanceGroup(t *testing.T) {
PerformValidation(t, test, underTestAttributes[test.field])
}

func TestAzureSchemaContainsDatabaseType(t *testing.T) {
test := TestCaseStructure{
name: "database_type should exist",
field: "database_type",
computed: false,
shouldBeRequired: false,
}

underTestAttributes := createFilledAzureDatahubResourceTestObject()

PerformValidation(t, test, underTestAttributes[test.field])
}

func createFilledAzureDatahubResourceTestObject() map[string]schema.Attribute {
res := &azureDatahubResource{}
schemaResponse := &resource.SchemaResponse{}
Expand Down
2 changes: 2 additions & 0 deletions resources/datalake/model_azure_datalake.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type azureDatalakeResourceModel struct {
StatusReason types.String `tfsdk:"status_reason"`

Tags types.Map `tfsdk:"tags"`

DatabaseType types.String `tfsdk:"database_type"`
}

type azureDatalakeImage struct {
Expand Down
1 change: 1 addition & 0 deletions resources/datalake/resource_azure_datalake.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (r *azureDatalakeResource) Configure(_ context.Context, req resource.Config

func toAzureDatalakeRequest(ctx context.Context, model *azureDatalakeResourceModel) *datalakemodels.CreateAzureDatalakeRequest {
req := &datalakemodels.CreateAzureDatalakeRequest{}
req.DatabaseType = model.DatabaseType.ValueString()
req.CloudProviderConfiguration = &datalakemodels.AzureConfigurationRequest{
ManagedIdentity: model.ManagedIdentity.ValueStringPointer(),
StorageLocation: model.StorageLocationBase.ValueStringPointer(),
Expand Down
4 changes: 4 additions & 0 deletions resources/datalake/schema_azure_datalake.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ var azureDatalakeResourceSchema = schema.Schema{
"java_version": schema.Int64Attribute{
Optional: true,
},
"database_type": schema.Int64Attribute{
MarkdownDescription: "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.",
Optional: true,
},
"product_versions": schema.SetNestedAttribute{
Computed: true,
PlanModifiers: []planmodifier.Set{
Expand Down

0 comments on commit c5ab46e

Please sign in to comment.