Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDPCP-11600 - Revisit Availability zone on datahub #97

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/resources/datahub_azure_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Required:

Optional:

- `availability_zones` (Set of String) List of availability zones that this instance group is associated with.
- `recipes` (Set of String) The set of recipe names that are going to be applied on the given instance group.

<a id="nestedatt--instance_group--attached_volume_configuration"></a>
Expand Down
73 changes: 73 additions & 0 deletions resources/datahub/common_scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,76 @@ var instanceGroupSchemaAttributes = map[string]schema.Attribute{
},
},
}

var azureInstanceGroupSchemaAttributes = map[string]schema.Attribute{
"instance_group": schema.ListNestedAttribute{
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"node_count": schema.Int64Attribute{
MarkdownDescription: "The cluster node count. Has to be greater or equal than 0 and less than 100,000.",
Required: true,
},
"availability_zones": schema.SetAttribute{
MarkdownDescription: "List of availability zones that this instance group is associated with.",
ElementType: types.StringType,
Optional: true,
},
"instance_group_name": schema.StringAttribute{
MarkdownDescription: "The name of the instance group.",
Required: true,
},
"instance_group_type": schema.StringAttribute{
MarkdownDescription: "The type of the instance group.",
Required: true,
},
"instance_type": schema.StringAttribute{
MarkdownDescription: "The cloud provider-side instance type.",
Required: true,
},
"root_volume_size": schema.Int64Attribute{
MarkdownDescription: "The size of the root volume in GB",
Required: true,
},
"recipes": schema.SetAttribute{
MarkdownDescription: "The set of recipe names that are going to be applied on the given instance group.",
ElementType: types.StringType,
Optional: true,
},
"attached_volume_configuration": schema.ListNestedAttribute{
Required: true,
MarkdownDescription: "Configuration regarding the attached volume to the specific instance group.",
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"volume_size": schema.Int64Attribute{
MarkdownDescription: "The size of the volume in GB.",
Required: true,
},
"volume_count": schema.Int64Attribute{
MarkdownDescription: "The number of volumes to be attached.",
Required: true,
},
"volume_type": schema.StringAttribute{
MarkdownDescription: "The - cloud provider - type of the volume.",
Required: true,
},
},
},
},
"recovery_mode": schema.StringAttribute{
MarkdownDescription: "The type of the recovery mode.",
Required: true,
},
"volume_encryption": schema.SingleNestedAttribute{
MarkdownDescription: "The volume encryption related configuration.",
Required: true,
Attributes: map[string]schema.Attribute{
"encryption": schema.BoolAttribute{
Required: true,
},
},
},
},
},
},
}
7 changes: 7 additions & 0 deletions resources/datahub/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ func fromModelToAzureRequest(model azureDatahubResourceModel, ctx context.Contex
igRecipes = append(igRecipes, recipe.ValueString())
}
}
var azs []string
if group.AvailabilityZones != nil && len(group.AvailabilityZones) > 0 {
for _, az := range group.AvailabilityZones {
azs = append(azs, az.ValueString())
}
}
rootVolumeSize := int32(group.RootVolumeSize.ValueInt64())
ig := &datahubmodels.AzureInstanceGroupRequest{
AttachedVolumeConfiguration: volReqs,
Expand All @@ -137,6 +143,7 @@ func fromModelToAzureRequest(model azureDatahubResourceModel, ctx context.Contex
RecipeNames: igRecipes,
RecoveryMode: group.RecoveryMode.ValueString(),
RootVolumeSize: &rootVolumeSize,
AvailabilityZones: azs,
}
igs = append(igs, ig)
}
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 @@ -24,6 +24,7 @@ type InstanceGroup struct {
RecoveryMode types.String `tfsdk:"recovery_mode"`
VolumeEncryption VolumeEncryption `tfsdk:"volume_encryption"`
Recipes []types.String `tfsdk:"recipes"`
AvailabilityZones []types.String `tfsdk:"availability_zones"`
}

type AttachedVolumeConfiguration struct {
Expand Down
2 changes: 1 addition & 1 deletion resources/datahub/schema_azure_datahub.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
func (r *azureDatahubResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
attr := map[string]schema.Attribute{}
utils.Append(attr, generalAttributes)
utils.Append(attr, instanceGroupSchemaAttributes)
utils.Append(attr, azureInstanceGroupSchemaAttributes)
utils.Append(attr, map[string]schema.Attribute{
"cluster_template": schema.StringAttribute{
MarkdownDescription: "The name of the cluster template.",
Expand Down
Loading