diff --git a/resources/datahub/resource_aws_datahub.go b/resources/datahub/resource_aws_datahub.go index 14818b5b..06852739 100644 --- a/resources/datahub/resource_aws_datahub.go +++ b/resources/datahub/resource_aws_datahub.go @@ -28,12 +28,22 @@ import ( var ( _ resource.ResourceWithConfigure = &awsDatahubResource{} _ resource.ResourceWithImportState = &awsDatahubResource{} + _ resource.ResourceWithModifyPlan = &awsDatahubResource{} ) type awsDatahubResource struct { client *cdp.Client } +func (r *awsDatahubResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddError( + "Resource Update Considerations", + "Due to provider limitations of this technical preview, modifications are not possible. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *awsDatahubResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/resources/datahub/resource_azure_datahub.go b/resources/datahub/resource_azure_datahub.go index 6be2e91b..d56fff07 100644 --- a/resources/datahub/resource_azure_datahub.go +++ b/resources/datahub/resource_azure_datahub.go @@ -28,12 +28,22 @@ import ( var ( _ resource.ResourceWithConfigure = &azureDatahubResource{} _ resource.ResourceWithImportState = &azureDatahubResource{} + _ resource.ResourceWithModifyPlan = &azureDatahubResource{} ) type azureDatahubResource struct { client *cdp.Client } +func (r *azureDatahubResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddError( + "Resource Update Considerations", + "Due to provider limitations of this technical preview, modifications are not possible. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *azureDatahubResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/resources/datahub/resource_gcp_datahub.go b/resources/datahub/resource_gcp_datahub.go index 0388b92a..2346fd8d 100644 --- a/resources/datahub/resource_gcp_datahub.go +++ b/resources/datahub/resource_gcp_datahub.go @@ -28,12 +28,22 @@ import ( var ( _ resource.ResourceWithConfigure = &gcpDatahubResource{} _ resource.ResourceWithImportState = &gcpDatahubResource{} + _ resource.ResourceWithModifyPlan = &gcpDatahubResource{} ) type gcpDatahubResource struct { client *cdp.Client } +func (r *gcpDatahubResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddError( + "Resource Update Considerations", + "Due to provider limitations of this technical preview, modifications are not possible. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *gcpDatahubResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/resources/datalake/resource_aws_datalake.go b/resources/datalake/resource_aws_datalake.go index f7aae5bb..98e0b056 100644 --- a/resources/datalake/resource_aws_datalake.go +++ b/resources/datalake/resource_aws_datalake.go @@ -35,12 +35,22 @@ import ( var ( _ resource.ResourceWithConfigure = &awsDatalakeResource{} _ resource.ResourceWithImportState = &awsDatalakeResource{} + _ resource.ResourceWithModifyPlan = &awsDatalakeResource{} ) type awsDatalakeResource struct { client *cdp.Client } +func (r *awsDatalakeResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddError( + "Resource Update Considerations", + "Due to provider limitations of this technical preview, modifications are not possible. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *awsDatalakeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/resources/datalake/resource_azure_datalake.go b/resources/datalake/resource_azure_datalake.go index a27c544d..af98872f 100644 --- a/resources/datalake/resource_azure_datalake.go +++ b/resources/datalake/resource_azure_datalake.go @@ -31,12 +31,22 @@ import ( var ( _ resource.ResourceWithConfigure = &azureDatalakeResource{} _ resource.ResourceWithImportState = &azureDatalakeResource{} + _ resource.ResourceWithModifyPlan = &azureDatalakeResource{} ) type azureDatalakeResource struct { client *cdp.Client } +func (r *azureDatalakeResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddError( + "Resource Update Considerations", + "Due to provider limitations of this technical preview, modifications are not possible. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *azureDatalakeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/resources/datalake/resource_gcp_datalake.go b/resources/datalake/resource_gcp_datalake.go index 8a40caef..82616c5b 100644 --- a/resources/datalake/resource_gcp_datalake.go +++ b/resources/datalake/resource_gcp_datalake.go @@ -27,12 +27,22 @@ import ( var ( _ resource.ResourceWithConfigure = &gcpDatalakeResource{} _ resource.ResourceWithImportState = &gcpDatalakeResource{} + _ resource.ResourceWithModifyPlan = &gcpDatalakeResource{} ) type gcpDatalakeResource struct { client *cdp.Client } +func (r *gcpDatalakeResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddError( + "Resource Update Considerations", + "Due to provider limitations of this technical preview, modifications are not possible. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *gcpDatalakeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/resources/environments/converter_freeipa.go b/resources/environments/converter_freeipa.go index 872f4a31..4acee078 100644 --- a/resources/environments/converter_freeipa.go +++ b/resources/environments/converter_freeipa.go @@ -65,10 +65,18 @@ func FreeIpaResponseToModel(ipaResp *environmentsmodels.FreeipaDetails, model *t ipaInstances, instDiags = types.SetValueFrom(ctx, FreeIpaInstanceType, instSet) diags.Append(instDiags...) - instanceCount, countErr := ConvertIntToInt32IfPossible(len(ipaResp.Instances)) - if countErr != nil { - diags.AddWarning(fmt.Sprintf("Unable to convert the numerical value of the length of the instances slice. Fallbacking to %d", ipaResp.InstanceCountByGroup), countErr.Error()) - instanceCount = types.Int32Value(ipaResp.InstanceCountByGroup) + var instanceCount basetypes.Int32Value + if val, ok := model.Attributes()["instance_count_by_group"]; ok { + if val.IsNull() { + var countErr error + instanceCount, countErr = ConvertIntToInt32IfPossible(len(ipaResp.Instances)) + if countErr != nil { + diags.AddWarning(fmt.Sprintf("Unable to convert the numerical value of the length of the instances slice. Fallbacking to %d", ipaResp.InstanceCountByGroup), countErr.Error()) + instanceCount = types.Int32Value(ipaResp.InstanceCountByGroup) + } + } else { + instanceCount = val.(basetypes.Int32Value) + } } var ipaDiags diag.Diagnostics *model, ipaDiags = types.ObjectValueFrom(ctx, FreeIpaDetailsType.AttrTypes, &FreeIpaDetails{ diff --git a/resources/environments/converter_gcp_test.go b/resources/environments/converter_gcp_test.go index 88342796..d5e9ec90 100644 --- a/resources/environments/converter_gcp_test.go +++ b/resources/environments/converter_gcp_test.go @@ -132,7 +132,7 @@ func createFilledGcpEnvironmentResourceModel() *gcpEnvironmentResourceModel { var elems []attr.Value instances, _ := types.SetValue(FreeIpaInstanceType, elems) freeIpaObj, _ := basetypes.NewObjectValue(FreeIpaDetailsType.AttrTypes, map[string]attr.Value{ - "instance_count_by_group": types.Int64Value(123), + "instance_count_by_group": types.Int32Value(123), "recipes": createSetOfString(), "instance_type": types.StringValue("someInstanceType"), "catalog": types.StringValue("someCatalog"), diff --git a/resources/environments/resource_aws_environment.go b/resources/environments/resource_aws_environment.go index c00b6f43..dfae0ad9 100644 --- a/resources/environments/resource_aws_environment.go +++ b/resources/environments/resource_aws_environment.go @@ -28,6 +28,7 @@ import ( var ( _ resource.ResourceWithConfigure = &awsEnvironmentResource{} _ resource.ResourceWithImportState = &awsEnvironmentResource{} + _ resource.ResourceWithModifyPlan = &awsEnvironmentResource{} ) type awsEnvironmentResource struct { @@ -54,6 +55,15 @@ func (r *awsEnvironmentResource) Configure(_ context.Context, req resource.Confi r.client = utils.GetCdpClientForResource(req, resp) } +func (r *awsEnvironmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddWarning( + "Resource Update Considerations", + "Due to provider limitations of this technical preview resource modifications are limited to enabling compute clusters. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *awsEnvironmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data awsEnvironmentResourceModel diags := req.Plan.Get(ctx, &data) diff --git a/resources/environments/resource_azure_environment.go b/resources/environments/resource_azure_environment.go index 234550e7..9bb13f4f 100644 --- a/resources/environments/resource_azure_environment.go +++ b/resources/environments/resource_azure_environment.go @@ -29,6 +29,7 @@ import ( var ( _ resource.ResourceWithConfigure = &azureEnvironmentResource{} _ resource.ResourceWithImportState = &azureEnvironmentResource{} + _ resource.ResourceWithModifyPlan = &azureEnvironmentResource{} ) type azureEnvironmentResource struct { @@ -55,6 +56,15 @@ func (r *azureEnvironmentResource) Configure(_ context.Context, req resource.Con r.client = utils.GetCdpClientForResource(req, resp) } +func (r *azureEnvironmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddWarning( + "Resource Update Considerations", + "Due to provider limitations of this technical preview resource modifications are limited to enabling compute clusters. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *azureEnvironmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data azureEnvironmentResourceModel diags := req.Plan.Get(ctx, &data) diff --git a/resources/environments/resource_gcp_environment.go b/resources/environments/resource_gcp_environment.go index 1cee3f7e..eac80971 100644 --- a/resources/environments/resource_gcp_environment.go +++ b/resources/environments/resource_gcp_environment.go @@ -26,6 +26,7 @@ import ( var ( _ resource.ResourceWithConfigure = &gcpEnvironmentResource{} _ resource.ResourceWithImportState = &gcpEnvironmentResource{} + _ resource.ResourceWithModifyPlan = &gcpEnvironmentResource{} ) type gcpEnvironmentResource struct { @@ -52,6 +53,15 @@ func (r *gcpEnvironmentResource) Configure(_ context.Context, req resource.Confi r.client = utils.GetCdpClientForResource(req, resp) } +func (r *gcpEnvironmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { + if !req.State.Raw.IsNull() { + resp.Diagnostics.AddWarning( + "Resource Update Considerations", + "Due to provider limitations of this technical preview resource modifications are limited to enabling compute clusters. "+ + "Use the web interface or the CLI to update this resource.") + } +} + func (r *gcpEnvironmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data gcpEnvironmentResourceModel diags := req.Plan.Get(ctx, &data) diff --git a/resources/environments/schema_environment_config.go b/resources/environments/schema_environment_config.go index 9203db47..c6a4c13a 100644 --- a/resources/environments/schema_environment_config.go +++ b/resources/environments/schema_environment_config.go @@ -441,7 +441,7 @@ var FreeIpaConfigSchema = schema.SingleNestedAttribute{ "os": schema.StringAttribute{ Computed: true, }, - "instance_count_by_group": schema.Int64Attribute{ + "instance_count_by_group": schema.Int32Attribute{ Computed: true, }, "instance_type": schema.StringAttribute{ diff --git a/resources/environments/tftypes_freeipa.go b/resources/environments/tftypes_freeipa.go index dbcc1750..5689bf1d 100644 --- a/resources/environments/tftypes_freeipa.go +++ b/resources/environments/tftypes_freeipa.go @@ -57,7 +57,7 @@ var FreeIpaDetailsType = types.ObjectType{ "catalog": types.StringType, "image_id": types.StringType, "os": types.StringType, - "instance_count_by_group": types.Int64Type, + "instance_count_by_group": types.Int32Type, "instance_type": types.StringType, "instances": types.SetType{ ElemType: FreeIpaInstanceType,