From d2bca9ca4c9e5619cc7aae7f0bff947bf13b6f35 Mon Sep 17 00:00:00 2001 From: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> Date: Tue, 4 Mar 2025 20:36:09 -0800 Subject: [PATCH 1/4] feat(kql_database): deprecate invitation_token and add invitation_token_wo --- docs/resources/kql_database.md | 4 +- internal/pkg/fabricitem/resource_item.go | 14 +----- ...ource_item_config_definition_properties.go | 25 +++------- .../resource_item_config_properties.go | 20 +++----- .../fabricitem/resource_item_definition.go | 17 ------- .../resource_item_definition_properties.go | 17 ------- .../fabricitem/resource_item_properties.go | 12 ----- internal/services/domain/resource_domain.go | 12 ----- .../resource_domain_role_assignments.go | 12 ----- .../resource_domain_workspace_assignments.go | 12 ----- .../models_resource_kql_database.go | 12 +++-- .../kqldatabase/resource_kql_database.go | 12 ++++- .../schema_resource_kql_database.go | 49 ++++++++++++++++++- .../spark/resource_spark_custom_pool.go | 15 ------ .../resource_spark_environment_settings.go | 12 ----- .../resource_spark_workspace_settings.go | 12 ----- .../services/workspace/resource_workspace.go | 12 ----- .../workspace/resource_workspace_git.go | 12 ----- .../resource_workspace_role_assignment.go | 12 ----- 19 files changed, 80 insertions(+), 213 deletions(-) diff --git a/docs/resources/kql_database.md b/docs/resources/kql_database.md index 7f2e58f2..d01f56a5 100644 --- a/docs/resources/kql_database.md +++ b/docs/resources/kql_database.md @@ -140,7 +140,9 @@ Required: Optional: -- `invitation_token` (String, Sensitive) Invitation token to follow the source database. Only allowed when `database_type` is `Shortcut`. +- `invitation_token` (String, Sensitive, Deprecated) Invitation token to follow the source database. Only allowed when `database_type` is `Shortcut`. +- `invitation_token_wo` (String) Invitation token (WO) to follow the source database. Only allowed when `database_type` is `Shortcut`. +- `invitation_token_wo_version` (String) The version of the invitation_token_wo - `source_cluster_uri` (String) The URI of the source Eventhouse or Azure Data Explorer cluster. Only allowed when `database_type` is `Shortcut`. - `source_database_name` (String) The name of the database to follow in the source Eventhouse or Azure Data Explorer cluster. Only allowed when `database_type` is `Shortcut`. diff --git a/internal/pkg/fabricitem/resource_item.go b/internal/pkg/fabricitem/resource_item.go index 211aaf3b..61bfac89 100644 --- a/internal/pkg/fabricitem/resource_item.go +++ b/internal/pkg/fabricitem/resource_item.go @@ -79,10 +79,6 @@ func (r *ResourceFabricItem) Create(ctx context.Context, req resource.CreateRequ tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceFabricItemModel @@ -172,11 +168,6 @@ func (r *ResourceFabricItem) Update(ctx context.Context, req resource.UpdateRequ tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan resourceFabricItemModel @@ -219,10 +210,7 @@ func (r *ResourceFabricItem) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) - + var state resourceFabricItemModel if resp.Diagnostics.Append(req.State.Get(ctx, &state)...); resp.Diagnostics.HasError() { diff --git a/internal/pkg/fabricitem/resource_item_config_definition_properties.go b/internal/pkg/fabricitem/resource_item_config_definition_properties.go index 1836bc19..1d6259b1 100644 --- a/internal/pkg/fabricitem/resource_item_config_definition_properties.go +++ b/internal/pkg/fabricitem/resource_item_config_definition_properties.go @@ -57,11 +57,6 @@ func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfcon tflog.Debug(ctx, "MODIFY PLAN", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "MODIFY PLAN", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) if !req.State.Raw.IsNull() && !req.Plan.Raw.IsNull() { var plan, state ResourceFabricItemConfigDefinitionPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] @@ -142,12 +137,12 @@ func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfcon tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) - var plan ResourceFabricItemConfigDefinitionPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] + var plan, config ResourceFabricItemConfigDefinitionPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] + + if resp.Diagnostics.Append(req.Config.Get(ctx, &config)...); resp.Diagnostics.HasError() { + return + } if resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...); resp.Diagnostics.HasError() { return @@ -171,7 +166,7 @@ func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfcon return } - creationPayload, diags := getCreationPayload(ctx, plan.Configuration, r.CreationPayloadSetter) + creationPayload, diags := getCreationPayload(ctx, config.Configuration, r.CreationPayloadSetter) if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { return } @@ -251,11 +246,6 @@ func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfcon tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state ResourceFabricItemConfigDefinitionPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] @@ -322,9 +312,6 @@ func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfcon tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state ResourceFabricItemConfigDefinitionPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] diff --git a/internal/pkg/fabricitem/resource_item_config_properties.go b/internal/pkg/fabricitem/resource_item_config_properties.go index 8b783ad9..9f5aa623 100644 --- a/internal/pkg/fabricitem/resource_item_config_properties.go +++ b/internal/pkg/fabricitem/resource_item_config_properties.go @@ -79,12 +79,12 @@ func (r *ResourceFabricItemConfigProperties[Ttfprop, Titemprop, Ttfconfig, Titem tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) - var plan ResourceFabricItemConfigPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] + var plan, config ResourceFabricItemConfigPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] + + if resp.Diagnostics.Append(req.Config.Get(ctx, &config)...); resp.Diagnostics.HasError() { + return + } if resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...); resp.Diagnostics.HasError() { return @@ -104,7 +104,7 @@ func (r *ResourceFabricItemConfigProperties[Ttfprop, Titemprop, Ttfconfig, Titem reqCreate.setDescription(plan.Description) reqCreate.setType(r.Type) - creationPayload, diags := getCreationPayload(ctx, plan.Configuration, r.CreationPayloadSetter) + creationPayload, diags := getCreationPayload(ctx, config.Configuration, r.CreationPayloadSetter) if resp.Diagnostics.Append(diags...); resp.Diagnostics.HasError() { return } @@ -184,11 +184,6 @@ func (r *ResourceFabricItemConfigProperties[Ttfprop, Titemprop, Ttfconfig, Titem tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state ResourceFabricItemConfigPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] @@ -236,9 +231,6 @@ func (r *ResourceFabricItemConfigProperties[Ttfprop, Titemprop, Ttfconfig, Titem tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state ResourceFabricItemConfigPropertiesModel[Ttfprop, Titemprop, Ttfconfig, Titemconfig] diff --git a/internal/pkg/fabricitem/resource_item_definition.go b/internal/pkg/fabricitem/resource_item_definition.go index 538943f5..e6284b83 100644 --- a/internal/pkg/fabricitem/resource_item_definition.go +++ b/internal/pkg/fabricitem/resource_item_definition.go @@ -61,11 +61,6 @@ func (r *ResourceFabricItemDefinition) ModifyPlan(ctx context.Context, req resou tflog.Debug(ctx, "MODIFY PLAN", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "MODIFY PLAN", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) if !req.State.Raw.IsNull() && !req.Plan.Raw.IsNull() { var plan, state resourceFabricItemDefinitionModel @@ -128,10 +123,6 @@ func (r *ResourceFabricItemDefinition) Create(ctx context.Context, req resource. tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceFabricItemDefinitionModel @@ -225,11 +216,6 @@ func (r *ResourceFabricItemDefinition) Update(ctx context.Context, req resource. tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state resourceFabricItemDefinitionModel @@ -294,9 +280,6 @@ func (r *ResourceFabricItemDefinition) Delete(ctx context.Context, req resource. tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceFabricItemDefinitionModel diff --git a/internal/pkg/fabricitem/resource_item_definition_properties.go b/internal/pkg/fabricitem/resource_item_definition_properties.go index a1b1a1ac..996cf866 100644 --- a/internal/pkg/fabricitem/resource_item_definition_properties.go +++ b/internal/pkg/fabricitem/resource_item_definition_properties.go @@ -51,11 +51,6 @@ func (r *ResourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) ModifyPlan( tflog.Debug(ctx, "MODIFY PLAN", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "MODIFY PLAN", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) if !req.State.Raw.IsNull() && !req.Plan.Raw.IsNull() { var plan, state ResourceFabricItemDefinitionPropertiesModel[Ttfprop, Titemprop] @@ -118,10 +113,6 @@ func (r *ResourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Create(ctx tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan ResourceFabricItemDefinitionPropertiesModel[Ttfprop, Titemprop] @@ -220,11 +211,6 @@ func (r *ResourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Update(ctx tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state ResourceFabricItemDefinitionPropertiesModel[Ttfprop, Titemprop] @@ -291,9 +277,6 @@ func (r *ResourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Delete(ctx tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state ResourceFabricItemDefinitionPropertiesModel[Ttfprop, Titemprop] diff --git a/internal/pkg/fabricitem/resource_item_properties.go b/internal/pkg/fabricitem/resource_item_properties.go index 7b3788b4..c38dfda9 100644 --- a/internal/pkg/fabricitem/resource_item_properties.go +++ b/internal/pkg/fabricitem/resource_item_properties.go @@ -75,10 +75,6 @@ func (r *ResourceFabricItemProperties[Ttfprop, Titemprop]) Create(ctx context.Co tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan ResourceFabricItemPropertiesModel[Ttfprop, Titemprop] @@ -173,11 +169,6 @@ func (r *ResourceFabricItemProperties[Ttfprop, Titemprop]) Update(ctx context.Co tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state ResourceFabricItemPropertiesModel[Ttfprop, Titemprop] @@ -225,9 +216,6 @@ func (r *ResourceFabricItemProperties[Ttfprop, Titemprop]) Delete(ctx context.Co tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state ResourceFabricItemPropertiesModel[Ttfprop, Titemprop] diff --git a/internal/services/domain/resource_domain.go b/internal/services/domain/resource_domain.go index ca9ebe8b..45bae860 100644 --- a/internal/services/domain/resource_domain.go +++ b/internal/services/domain/resource_domain.go @@ -139,10 +139,6 @@ func (r *resourceDomain) Create(ctx context.Context, req resource.CreateRequest, tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan, state resourceDomainModel @@ -245,11 +241,6 @@ func (r *resourceDomain) Update(ctx context.Context, req resource.UpdateRequest, tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan resourceDomainModel @@ -291,9 +282,6 @@ func (r *resourceDomain) Delete(ctx context.Context, req resource.DeleteRequest, tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceDomainModel diff --git a/internal/services/domain/resource_domain_role_assignments.go b/internal/services/domain/resource_domain_role_assignments.go index 6c1fbce4..c75be87e 100644 --- a/internal/services/domain/resource_domain_role_assignments.go +++ b/internal/services/domain/resource_domain_role_assignments.go @@ -142,10 +142,6 @@ func (r *resourceDomainRoleAssignments) Create(ctx context.Context, req resource tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceDomainRoleAssignmentsModel @@ -229,11 +225,6 @@ func (r *resourceDomainRoleAssignments) Update(ctx context.Context, req resource tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state resourceDomainRoleAssignmentsModel @@ -307,9 +298,6 @@ func (r *resourceDomainRoleAssignments) Delete(ctx context.Context, req resource tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceDomainRoleAssignmentsModel diff --git a/internal/services/domain/resource_domain_workspace_assignments.go b/internal/services/domain/resource_domain_workspace_assignments.go index 358d3932..dcf3a27b 100644 --- a/internal/services/domain/resource_domain_workspace_assignments.go +++ b/internal/services/domain/resource_domain_workspace_assignments.go @@ -111,10 +111,6 @@ func (r *resourceDomainWorkspaceAssignments) Create(ctx context.Context, req res tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceDomainWorkspaceAssignmentsModel @@ -199,11 +195,6 @@ func (r *resourceDomainWorkspaceAssignments) Update(ctx context.Context, req res tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state resourceDomainWorkspaceAssignmentsModel @@ -283,9 +274,6 @@ func (r *resourceDomainWorkspaceAssignments) Delete(ctx context.Context, req res tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceDomainWorkspaceAssignmentsModel diff --git a/internal/services/kqldatabase/models_resource_kql_database.go b/internal/services/kqldatabase/models_resource_kql_database.go index 9bffef3a..1d4dab17 100644 --- a/internal/services/kqldatabase/models_resource_kql_database.go +++ b/internal/services/kqldatabase/models_resource_kql_database.go @@ -10,9 +10,11 @@ import ( ) type kqlDatabaseConfigurationModel struct { - DatabaseType types.String `tfsdk:"database_type"` - EventhouseID customtypes.UUID `tfsdk:"eventhouse_id"` - InvitationToken types.String `tfsdk:"invitation_token"` - SourceClusterURI customtypes.URL `tfsdk:"source_cluster_uri"` - SourceDatabaseName types.String `tfsdk:"source_database_name"` + DatabaseType types.String `tfsdk:"database_type"` + EventhouseID customtypes.UUID `tfsdk:"eventhouse_id"` + InvitationToken types.String `tfsdk:"invitation_token"` + InvitationTokenWO types.String `tfsdk:"invitation_token_wo"` + InvitationTokenWOVersion types.String `tfsdk:"invitation_token_wo_version"` + SourceClusterURI customtypes.URL `tfsdk:"source_cluster_uri"` + SourceDatabaseName types.String `tfsdk:"source_database_name"` } diff --git a/internal/services/kqldatabase/resource_kql_database.go b/internal/services/kqldatabase/resource_kql_database.go index 9827ddcf..131c2323 100644 --- a/internal/services/kqldatabase/resource_kql_database.go +++ b/internal/services/kqldatabase/resource_kql_database.go @@ -37,10 +37,18 @@ func NewResourceKQLDatabase() resource.Resource { creationPayload.DatabaseType = &kqlDatabaseType creationPayload.ParentEventhouseItemID = from.EventhouseID.ValueStringPointer() - if !from.InvitationToken.IsNull() && !from.InvitationToken.IsUnknown() { - creationPayload.InvitationToken = from.InvitationToken.ValueStringPointer() + var invitationToken *string + + if !from.InvitationTokenWO.IsNull() && !from.InvitationTokenWO.IsUnknown() { + invitationToken = from.InvitationTokenWO.ValueStringPointer() + } else if !from.InvitationToken.IsNull() && !from.InvitationToken.IsUnknown() { + invitationToken = from.InvitationToken.ValueStringPointer() + } else { + invitationToken = nil } + creationPayload.InvitationToken = invitationToken + if !from.SourceClusterURI.IsNull() && !from.SourceClusterURI.IsUnknown() { creationPayload.SourceClusterURI = from.SourceClusterURI.ValueStringPointer() } diff --git a/internal/services/kqldatabase/schema_resource_kql_database.go b/internal/services/kqldatabase/schema_resource_kql_database.go index b824cea8..beab1235 100644 --- a/internal/services/kqldatabase/schema_resource_kql_database.go +++ b/internal/services/kqldatabase/schema_resource_kql_database.go @@ -69,11 +69,32 @@ func getResourceKQLDatabaseConfigurationAttributes() map[string]schema.Attribute MarkdownDescription: "Invitation token to follow the source database. Only allowed when `database_type` is `" + string(fabkqldatabase.TypeShortcut) + "`.", Optional: true, Sensitive: true, + DeprecationMessage: "This attribute is deprecated. Use `invitation_token_wo` instead.", PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, + Validators: []validator.String{ + stringvalidator.PreferWriteOnlyAttribute( + path.MatchRelative().AtParent().AtName("invitation_token_wo"), + ), + stringvalidator.ConflictsWith( + path.MatchRelative().AtParent().AtName("invitation_token_wo"), + path.MatchRelative().AtParent().AtName("source_cluster_uri"), + path.MatchRelative().AtParent().AtName("source_database_name"), + ), + superstringvalidator.NullIfAttributeIsOneOf( + path.MatchRelative().AtParent().AtName("database_type"), + []attr.Value{types.StringValue(string(fabkqldatabase.TypeReadWrite))}, + ), + }, + }, + "invitation_token_wo": schema.StringAttribute{ + MarkdownDescription: "Invitation token (WO) to follow the source database. Only allowed when `database_type` is `" + string(fabkqldatabase.TypeShortcut) + "`.", + Optional: true, + WriteOnly: true, Validators: []validator.String{ stringvalidator.ConflictsWith( + path.MatchRelative().AtParent().AtName("invitation_token"), path.MatchRelative().AtParent().AtName("source_cluster_uri"), path.MatchRelative().AtParent().AtName("source_database_name"), ), @@ -81,6 +102,24 @@ func getResourceKQLDatabaseConfigurationAttributes() map[string]schema.Attribute path.MatchRelative().AtParent().AtName("database_type"), []attr.Value{types.StringValue(string(fabkqldatabase.TypeReadWrite))}, ), + stringvalidator.AlsoRequires( + path.MatchRelative().AtParent().AtName("invitation_token_wo_version"), + ), + }, + }, + "invitation_token_wo_version": schema.StringAttribute{ + MarkdownDescription: "The version of the `invitation_token_wo`", + Optional: true, + Validators: []validator.String{ + stringvalidator.ConflictsWith( + path.MatchRelative().AtParent().AtName("invitation_token"), + ), + stringvalidator.AlsoRequires( + path.MatchRelative().AtParent().AtName("invitation_token_wo"), + ), + }, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), }, }, "source_cluster_uri": schema.StringAttribute{ @@ -91,7 +130,10 @@ func getResourceKQLDatabaseConfigurationAttributes() map[string]schema.Attribute stringplanmodifier.RequiresReplace(), }, Validators: []validator.String{ - stringvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("invitation_token")), + stringvalidator.ConflictsWith( + path.MatchRelative().AtParent().AtName("invitation_token"), + path.MatchRelative().AtParent().AtName("invitation_token_wo"), + ), stringvalidator.AlsoRequires(path.MatchRelative().AtParent().AtName("source_database_name")), superstringvalidator.NullIfAttributeIsOneOf( path.MatchRelative().AtParent().AtName("database_type"), @@ -106,7 +148,10 @@ func getResourceKQLDatabaseConfigurationAttributes() map[string]schema.Attribute stringplanmodifier.RequiresReplace(), }, Validators: []validator.String{ - stringvalidator.ConflictsWith(path.MatchRelative().AtParent().AtName("invitation_token")), + stringvalidator.ConflictsWith( + path.MatchRelative().AtParent().AtName("invitation_token"), + path.MatchRelative().AtParent().AtName("invitation_token_wo"), + ), superstringvalidator.NullIfAttributeIsOneOf( path.MatchRelative().AtParent().AtName("database_type"), []attr.Value{types.StringValue(string(fabkqldatabase.TypeReadWrite))}, diff --git a/internal/services/spark/resource_spark_custom_pool.go b/internal/services/spark/resource_spark_custom_pool.go index fe0f406a..520594be 100644 --- a/internal/services/spark/resource_spark_custom_pool.go +++ b/internal/services/spark/resource_spark_custom_pool.go @@ -191,10 +191,6 @@ func (r *resourceSparkCustomPool) Create(ctx context.Context, req resource.Creat tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceSparkCustomPoolModel @@ -286,11 +282,6 @@ func (r *resourceSparkCustomPool) Update(ctx context.Context, req resource.Updat tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan resourceSparkCustomPoolModel @@ -336,9 +327,6 @@ func (r *resourceSparkCustomPool) Delete(ctx context.Context, req resource.Delet tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceSparkCustomPoolModel @@ -368,9 +356,6 @@ func (r *resourceSparkCustomPool) ImportState(ctx context.Context, req resource. tflog.Debug(ctx, "IMPORT", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "id": req.ID, - }) workspaceID, poolID, found := strings.Cut(req.ID, "/") if !found { diff --git a/internal/services/spark/resource_spark_environment_settings.go b/internal/services/spark/resource_spark_environment_settings.go index fb762320..0f473fc1 100644 --- a/internal/services/spark/resource_spark_environment_settings.go +++ b/internal/services/spark/resource_spark_environment_settings.go @@ -293,10 +293,6 @@ func (r *resourceSparkEnvironmentSettings) Create(ctx context.Context, req resou tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceSparkEnvironmentSettingsModel @@ -396,11 +392,6 @@ func (r *resourceSparkEnvironmentSettings) Update(ctx context.Context, req resou tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan resourceSparkEnvironmentSettingsModel @@ -452,9 +443,6 @@ func (r *resourceSparkEnvironmentSettings) Delete(ctx context.Context, req resou tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) resp.Diagnostics.AddWarning( "delete operation not supported", diff --git a/internal/services/spark/resource_spark_workspace_settings.go b/internal/services/spark/resource_spark_workspace_settings.go index 883914d1..41dd8c5a 100644 --- a/internal/services/spark/resource_spark_workspace_settings.go +++ b/internal/services/spark/resource_spark_workspace_settings.go @@ -308,10 +308,6 @@ func (r *resourceSparkWorkspaceSettings) Create(ctx context.Context, req resourc tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceSparkWorkspaceSettingsModel @@ -407,11 +403,6 @@ func (r *resourceSparkWorkspaceSettings) Update(ctx context.Context, req resourc tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan resourceSparkWorkspaceSettingsModel @@ -459,9 +450,6 @@ func (r *resourceSparkWorkspaceSettings) Delete(ctx context.Context, req resourc tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) resp.Diagnostics.AddWarning( "delete operation not supported", diff --git a/internal/services/workspace/resource_workspace.go b/internal/services/workspace/resource_workspace.go index 67a049f0..6f62b906 100644 --- a/internal/services/workspace/resource_workspace.go +++ b/internal/services/workspace/resource_workspace.go @@ -199,10 +199,6 @@ func (r *resourceWorkspace) Create(ctx context.Context, req resource.CreateReque tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan, state resourceWorkspaceModel @@ -331,11 +327,6 @@ func (r *resourceWorkspace) Update(ctx context.Context, req resource.UpdateReque tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan, state, intermediary resourceWorkspaceModel @@ -497,9 +488,6 @@ func (r *resourceWorkspace) Delete(ctx context.Context, req resource.DeleteReque tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceWorkspaceModel diff --git a/internal/services/workspace/resource_workspace_git.go b/internal/services/workspace/resource_workspace_git.go index 457758ab..d45f6997 100644 --- a/internal/services/workspace/resource_workspace_git.go +++ b/internal/services/workspace/resource_workspace_git.go @@ -197,10 +197,6 @@ func (r *resourceWorkspaceGit) Create(ctx context.Context, req resource.CreateRe tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceWorkspaceGitModel @@ -346,11 +342,6 @@ func (r *resourceWorkspaceGit) Update(ctx context.Context, req resource.UpdateRe tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) // in real world, this should not reach here resp.Diagnostics.AddError( @@ -371,9 +362,6 @@ func (r *resourceWorkspaceGit) Delete(ctx context.Context, req resource.DeleteRe tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceWorkspaceGitModel diff --git a/internal/services/workspace/resource_workspace_role_assignment.go b/internal/services/workspace/resource_workspace_role_assignment.go index 2ee8637f..63ce103b 100644 --- a/internal/services/workspace/resource_workspace_role_assignment.go +++ b/internal/services/workspace/resource_workspace_role_assignment.go @@ -120,10 +120,6 @@ func (r *resourceWorkspaceRoleAssignment) Create(ctx context.Context, req resour tflog.Debug(ctx, "CREATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "CREATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - }) var plan resourceWorkspaceRoleAssignmentModel @@ -209,11 +205,6 @@ func (r *resourceWorkspaceRoleAssignment) Update(ctx context.Context, req resour tflog.Debug(ctx, "UPDATE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "UPDATE", map[string]any{ - "config": req.Config, - "plan": req.Plan, - "state": req.State, - }) var plan resourceWorkspaceRoleAssignmentModel @@ -255,9 +246,6 @@ func (r *resourceWorkspaceRoleAssignment) Delete(ctx context.Context, req resour tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - tflog.Trace(ctx, "DELETE", map[string]any{ - "state": req.State, - }) var state resourceWorkspaceRoleAssignmentModel From 26f300294b7377e72e4b402effd3e6397691beb4 Mon Sep 17 00:00:00 2001 From: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> Date: Tue, 4 Mar 2025 20:52:50 -0800 Subject: [PATCH 2/4] feat(kql_database): change invitation_token_wo_version type to int --- docs/resources/kql_database.md | 2 +- .../kqldatabase/models_resource_kql_database.go | 2 +- .../services/kqldatabase/resource_kql_database.go | 7 ++++--- .../kqldatabase/schema_resource_kql_database.go | 14 ++++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/resources/kql_database.md b/docs/resources/kql_database.md index d01f56a5..91eff6aa 100644 --- a/docs/resources/kql_database.md +++ b/docs/resources/kql_database.md @@ -142,7 +142,7 @@ Optional: - `invitation_token` (String, Sensitive, Deprecated) Invitation token to follow the source database. Only allowed when `database_type` is `Shortcut`. - `invitation_token_wo` (String) Invitation token (WO) to follow the source database. Only allowed when `database_type` is `Shortcut`. -- `invitation_token_wo_version` (String) The version of the invitation_token_wo +- `invitation_token_wo_version` (Number) The version of the `invitation_token_wo` - `source_cluster_uri` (String) The URI of the source Eventhouse or Azure Data Explorer cluster. Only allowed when `database_type` is `Shortcut`. - `source_database_name` (String) The name of the database to follow in the source Eventhouse or Azure Data Explorer cluster. Only allowed when `database_type` is `Shortcut`. diff --git a/internal/services/kqldatabase/models_resource_kql_database.go b/internal/services/kqldatabase/models_resource_kql_database.go index 1d4dab17..58ed1738 100644 --- a/internal/services/kqldatabase/models_resource_kql_database.go +++ b/internal/services/kqldatabase/models_resource_kql_database.go @@ -14,7 +14,7 @@ type kqlDatabaseConfigurationModel struct { EventhouseID customtypes.UUID `tfsdk:"eventhouse_id"` InvitationToken types.String `tfsdk:"invitation_token"` InvitationTokenWO types.String `tfsdk:"invitation_token_wo"` - InvitationTokenWOVersion types.String `tfsdk:"invitation_token_wo_version"` + InvitationTokenWOVersion types.Int32 `tfsdk:"invitation_token_wo_version"` SourceClusterURI customtypes.URL `tfsdk:"source_cluster_uri"` SourceDatabaseName types.String `tfsdk:"source_database_name"` } diff --git a/internal/services/kqldatabase/resource_kql_database.go b/internal/services/kqldatabase/resource_kql_database.go index 131c2323..6a07d8f7 100644 --- a/internal/services/kqldatabase/resource_kql_database.go +++ b/internal/services/kqldatabase/resource_kql_database.go @@ -39,11 +39,12 @@ func NewResourceKQLDatabase() resource.Resource { var invitationToken *string - if !from.InvitationTokenWO.IsNull() && !from.InvitationTokenWO.IsUnknown() { + switch { + case !from.InvitationTokenWO.IsNull() && !from.InvitationTokenWO.IsUnknown(): invitationToken = from.InvitationTokenWO.ValueStringPointer() - } else if !from.InvitationToken.IsNull() && !from.InvitationToken.IsUnknown() { + case !from.InvitationToken.IsNull() && !from.InvitationToken.IsUnknown(): invitationToken = from.InvitationToken.ValueStringPointer() - } else { + default: invitationToken = nil } diff --git a/internal/services/kqldatabase/schema_resource_kql_database.go b/internal/services/kqldatabase/schema_resource_kql_database.go index beab1235..7a341b7d 100644 --- a/internal/services/kqldatabase/schema_resource_kql_database.go +++ b/internal/services/kqldatabase/schema_resource_kql_database.go @@ -4,10 +4,12 @@ package kqldatabase import ( + "github.com/hashicorp/terraform-plugin-framework-validators/int32validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int32planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -107,19 +109,19 @@ func getResourceKQLDatabaseConfigurationAttributes() map[string]schema.Attribute ), }, }, - "invitation_token_wo_version": schema.StringAttribute{ + "invitation_token_wo_version": schema.Int32Attribute{ MarkdownDescription: "The version of the `invitation_token_wo`", Optional: true, - Validators: []validator.String{ - stringvalidator.ConflictsWith( + Validators: []validator.Int32{ + int32validator.ConflictsWith( path.MatchRelative().AtParent().AtName("invitation_token"), ), - stringvalidator.AlsoRequires( + int32validator.AlsoRequires( path.MatchRelative().AtParent().AtName("invitation_token_wo"), ), }, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + PlanModifiers: []planmodifier.Int32{ + int32planmodifier.RequiresReplace(), }, }, "source_cluster_uri": schema.StringAttribute{ From 95b4721bb0235a17d059d200ecfe5ea3266a971f Mon Sep 17 00:00:00 2001 From: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> Date: Tue, 4 Mar 2025 20:52:59 -0800 Subject: [PATCH 3/4] chore: changelog --- .changes/unreleased/changed-20250304-204546.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/changed-20250304-204546.yaml diff --git a/.changes/unreleased/changed-20250304-204546.yaml b/.changes/unreleased/changed-20250304-204546.yaml new file mode 100644 index 00000000..5daee5a2 --- /dev/null +++ b/.changes/unreleased/changed-20250304-204546.yaml @@ -0,0 +1,5 @@ +kind: changed +body: Introduction of the write-only attribute for Invitation Token in the KQL Database resource. +time: 2025-03-04T20:45:46.9774432-08:00 +custom: + Issue: "281" From a765df2833e44aaa0abc9854e90099e0f7e1fa80 Mon Sep 17 00:00:00 2001 From: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> Date: Tue, 4 Mar 2025 21:08:17 -0800 Subject: [PATCH 4/4] docs(kql_database): update invitation_token_wo description to indicate write-only status --- docs/resources/kql_database.md | 2 +- internal/pkg/fabricitem/resource_item.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/kql_database.md b/docs/resources/kql_database.md index 91eff6aa..863dd511 100644 --- a/docs/resources/kql_database.md +++ b/docs/resources/kql_database.md @@ -141,7 +141,7 @@ Required: Optional: - `invitation_token` (String, Sensitive, Deprecated) Invitation token to follow the source database. Only allowed when `database_type` is `Shortcut`. -- `invitation_token_wo` (String) Invitation token (WO) to follow the source database. Only allowed when `database_type` is `Shortcut`. +- `invitation_token_wo` (String, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) Invitation token (WO) to follow the source database. Only allowed when `database_type` is `Shortcut`. - `invitation_token_wo_version` (Number) The version of the `invitation_token_wo` - `source_cluster_uri` (String) The URI of the source Eventhouse or Azure Data Explorer cluster. Only allowed when `database_type` is `Shortcut`. - `source_database_name` (String) The name of the database to follow in the source Eventhouse or Azure Data Explorer cluster. Only allowed when `database_type` is `Shortcut`. diff --git a/internal/pkg/fabricitem/resource_item.go b/internal/pkg/fabricitem/resource_item.go index 61bfac89..d301e07e 100644 --- a/internal/pkg/fabricitem/resource_item.go +++ b/internal/pkg/fabricitem/resource_item.go @@ -210,7 +210,7 @@ func (r *ResourceFabricItem) Delete(ctx context.Context, req resource.DeleteRequ tflog.Debug(ctx, "DELETE", map[string]any{ "action": "start", }) - + var state resourceFabricItemModel if resp.Diagnostics.Append(req.State.Get(ctx, &state)...); resp.Diagnostics.HasError() {