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

resource_workspace_conf Delete: only reset enable and enforce properties #2025

Closed
wants to merge 2 commits into from
Closed

resource_workspace_conf Delete: only reset enable and enforce properties #2025

wants to merge 2 commits into from

Conversation

abij
Copy link

@abij abij commented Feb 20, 2023

Make the code aligned with the documentation: https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/workspace_conf#argument-reference

PR for Issue: #1802 (remove a workspace with a non-enable/enforce setting)

@@ -104,6 +104,11 @@ func ResourceWorkspaceConf() *schema.Resource {
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
config := d.Get("custom_config").(map[string]any)
for k, v := range config {
if !strings.HasPrefix(k, "enable") && !strings.HasPrefix(k, "enforce") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really it's not ideal situation as the workspace isn't returned to the original state. One approach would be to collect original values on create/update, and then reset to that values on delete.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point, for example the projectsAllowList (allowed git url's) is something you would like to reset (""), with the companion setting: projectsAllowListPermissions : "ALL_REPOS" (default).

Is there a way how to fetch or store the default values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. something similar.

You can retrieve original values when creating/updating a resource and store original values in a computed property (for example as JSON string, or something like)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a simpler solution could be to do nothing. Delete just removes the resource from backend / state. (This follows others work arounds now) The logic here would be that we are asking for the lack of management over the resource. As we know, we can't actually delete the workspace conf. All workspaces start with a configuration, even if its default. To get a default configuration, a simple inclusion of a workspace_conf with default settings. That to me IS a configuration. Its all grey but i fall into the camp that

Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {

is asking for no more management not default setup.

@pietern pietern requested review from a team as code owners June 5, 2024 08:35
@pietern pietern requested review from tanmay-db and removed request for a team June 5, 2024 08:35
@nkvuong
Copy link
Contributor

nkvuong commented Aug 12, 2024

Resolved by #3737

@nkvuong nkvuong closed this Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants