Skip to content

Commit b53e380

Browse files
committed
CDPCP-15137 Present a message to the practitioner that resource update is not supported in the TP
1 parent 1d403a1 commit b53e380

13 files changed

+105
-7
lines changed

resources/datahub/resource_aws_datahub.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ import (
2828
var (
2929
_ resource.ResourceWithConfigure = &awsDatahubResource{}
3030
_ resource.ResourceWithImportState = &awsDatahubResource{}
31+
_ resource.ResourceWithModifyPlan = &awsDatahubResource{}
3132
)
3233

3334
type awsDatahubResource struct {
3435
client *cdp.Client
3536
}
3637

38+
func (r *awsDatahubResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
39+
if !req.State.Raw.IsNull() {
40+
resp.Diagnostics.AddError(
41+
"Resource Update Considerations",
42+
"Due to provider limitations of this technical preview, modifications are not possible. "+
43+
"Use the web interface or the CLI to update this resource.")
44+
}
45+
}
46+
3747
func (r *awsDatahubResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
3848
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
3949
}

resources/datahub/resource_azure_datahub.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ import (
2828
var (
2929
_ resource.ResourceWithConfigure = &azureDatahubResource{}
3030
_ resource.ResourceWithImportState = &azureDatahubResource{}
31+
_ resource.ResourceWithModifyPlan = &azureDatahubResource{}
3132
)
3233

3334
type azureDatahubResource struct {
3435
client *cdp.Client
3536
}
3637

38+
func (r *azureDatahubResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
39+
if !req.State.Raw.IsNull() {
40+
resp.Diagnostics.AddError(
41+
"Resource Update Considerations",
42+
"Due to provider limitations of this technical preview, modifications are not possible. "+
43+
"Use the web interface or the CLI to update this resource.")
44+
}
45+
}
46+
3747
func (r *azureDatahubResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
3848
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
3949
}

resources/datahub/resource_gcp_datahub.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,22 @@ import (
2828
var (
2929
_ resource.ResourceWithConfigure = &gcpDatahubResource{}
3030
_ resource.ResourceWithImportState = &gcpDatahubResource{}
31+
_ resource.ResourceWithModifyPlan = &gcpDatahubResource{}
3132
)
3233

3334
type gcpDatahubResource struct {
3435
client *cdp.Client
3536
}
3637

38+
func (r *gcpDatahubResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
39+
if !req.State.Raw.IsNull() {
40+
resp.Diagnostics.AddError(
41+
"Resource Update Considerations",
42+
"Due to provider limitations of this technical preview, modifications are not possible. "+
43+
"Use the web interface or the CLI to update this resource.")
44+
}
45+
}
46+
3747
func (r *gcpDatahubResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
3848
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
3949
}

resources/datalake/resource_aws_datalake.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,22 @@ import (
3535
var (
3636
_ resource.ResourceWithConfigure = &awsDatalakeResource{}
3737
_ resource.ResourceWithImportState = &awsDatalakeResource{}
38+
_ resource.ResourceWithModifyPlan = &awsDatalakeResource{}
3839
)
3940

4041
type awsDatalakeResource struct {
4142
client *cdp.Client
4243
}
4344

45+
func (r *awsDatalakeResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
46+
if !req.State.Raw.IsNull() {
47+
resp.Diagnostics.AddError(
48+
"Resource Update Considerations",
49+
"Due to provider limitations of this technical preview, modifications are not possible. "+
50+
"Use the web interface or the CLI to update this resource.")
51+
}
52+
}
53+
4454
func (r *awsDatalakeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
4555
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
4656
}

resources/datalake/resource_azure_datalake.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,22 @@ import (
3131
var (
3232
_ resource.ResourceWithConfigure = &azureDatalakeResource{}
3333
_ resource.ResourceWithImportState = &azureDatalakeResource{}
34+
_ resource.ResourceWithModifyPlan = &azureDatalakeResource{}
3435
)
3536

3637
type azureDatalakeResource struct {
3738
client *cdp.Client
3839
}
3940

41+
func (r *azureDatalakeResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
42+
if !req.State.Raw.IsNull() {
43+
resp.Diagnostics.AddError(
44+
"Resource Update Considerations",
45+
"Due to provider limitations of this technical preview, modifications are not possible. "+
46+
"Use the web interface or the CLI to update this resource.")
47+
}
48+
}
49+
4050
func (r *azureDatalakeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
4151
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
4252
}

resources/datalake/resource_gcp_datalake.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ import (
2727
var (
2828
_ resource.ResourceWithConfigure = &gcpDatalakeResource{}
2929
_ resource.ResourceWithImportState = &gcpDatalakeResource{}
30+
_ resource.ResourceWithModifyPlan = &gcpDatalakeResource{}
3031
)
3132

3233
type gcpDatalakeResource struct {
3334
client *cdp.Client
3435
}
3536

37+
func (r *gcpDatalakeResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
38+
if !req.State.Raw.IsNull() {
39+
resp.Diagnostics.AddError(
40+
"Resource Update Considerations",
41+
"Due to provider limitations of this technical preview, modifications are not possible. "+
42+
"Use the web interface or the CLI to update this resource.")
43+
}
44+
}
45+
3646
func (r *gcpDatalakeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
3747
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
3848
}

resources/environments/converter_freeipa.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,18 @@ func FreeIpaResponseToModel(ipaResp *environmentsmodels.FreeipaDetails, model *t
6565
ipaInstances, instDiags = types.SetValueFrom(ctx, FreeIpaInstanceType, instSet)
6666
diags.Append(instDiags...)
6767

68-
instanceCount, countErr := ConvertIntToInt32IfPossible(len(ipaResp.Instances))
69-
if countErr != nil {
70-
diags.AddWarning(fmt.Sprintf("Unable to convert the numerical value of the length of the instances slice. Fallbacking to %d", ipaResp.InstanceCountByGroup), countErr.Error())
71-
instanceCount = types.Int32Value(ipaResp.InstanceCountByGroup)
68+
var instanceCount basetypes.Int32Value
69+
if val, ok := model.Attributes()["instance_count_by_group"]; ok {
70+
if val.IsNull() {
71+
var countErr error
72+
instanceCount, countErr = ConvertIntToInt32IfPossible(len(ipaResp.Instances))
73+
if countErr != nil {
74+
diags.AddWarning(fmt.Sprintf("Unable to convert the numerical value of the length of the instances slice. Fallbacking to %d", ipaResp.InstanceCountByGroup), countErr.Error())
75+
instanceCount = types.Int32Value(ipaResp.InstanceCountByGroup)
76+
}
77+
} else {
78+
instanceCount = val.(basetypes.Int32Value)
79+
}
7280
}
7381
var ipaDiags diag.Diagnostics
7482
*model, ipaDiags = types.ObjectValueFrom(ctx, FreeIpaDetailsType.AttrTypes, &FreeIpaDetails{

resources/environments/converter_gcp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func createFilledGcpEnvironmentResourceModel() *gcpEnvironmentResourceModel {
132132
var elems []attr.Value
133133
instances, _ := types.SetValue(FreeIpaInstanceType, elems)
134134
freeIpaObj, _ := basetypes.NewObjectValue(FreeIpaDetailsType.AttrTypes, map[string]attr.Value{
135-
"instance_count_by_group": types.Int64Value(123),
135+
"instance_count_by_group": types.Int32Value(123),
136136
"recipes": createSetOfString(),
137137
"instance_type": types.StringValue("someInstanceType"),
138138
"catalog": types.StringValue("someCatalog"),

resources/environments/resource_aws_environment.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
var (
2929
_ resource.ResourceWithConfigure = &awsEnvironmentResource{}
3030
_ resource.ResourceWithImportState = &awsEnvironmentResource{}
31+
_ resource.ResourceWithModifyPlan = &awsEnvironmentResource{}
3132
)
3233

3334
type awsEnvironmentResource struct {
@@ -54,6 +55,15 @@ func (r *awsEnvironmentResource) Configure(_ context.Context, req resource.Confi
5455
r.client = utils.GetCdpClientForResource(req, resp)
5556
}
5657

58+
func (r *awsEnvironmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
59+
if !req.State.Raw.IsNull() {
60+
resp.Diagnostics.AddWarning(
61+
"Resource Update Considerations",
62+
"Due to provider limitations of this technical preview resource modifications are limited to enabling compute clusters. "+
63+
"Use the web interface or the CLI to update this resource.")
64+
}
65+
}
66+
5767
func (r *awsEnvironmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
5868
var data awsEnvironmentResourceModel
5969
diags := req.Plan.Get(ctx, &data)

resources/environments/resource_azure_environment.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
var (
3030
_ resource.ResourceWithConfigure = &azureEnvironmentResource{}
3131
_ resource.ResourceWithImportState = &azureEnvironmentResource{}
32+
_ resource.ResourceWithModifyPlan = &azureEnvironmentResource{}
3233
)
3334

3435
type azureEnvironmentResource struct {
@@ -55,6 +56,15 @@ func (r *azureEnvironmentResource) Configure(_ context.Context, req resource.Con
5556
r.client = utils.GetCdpClientForResource(req, resp)
5657
}
5758

59+
func (r *azureEnvironmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
60+
if !req.State.Raw.IsNull() {
61+
resp.Diagnostics.AddWarning(
62+
"Resource Update Considerations",
63+
"Due to provider limitations of this technical preview resource modifications are limited to enabling compute clusters. "+
64+
"Use the web interface or the CLI to update this resource.")
65+
}
66+
}
67+
5868
func (r *azureEnvironmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
5969
var data azureEnvironmentResourceModel
6070
diags := req.Plan.Get(ctx, &data)

0 commit comments

Comments
 (0)