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

Add suppress diff for path argument of databricks_directory resource when it ends with / #2204

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

alexott
Copy link
Contributor

@alexott alexott commented Apr 8, 2023

Changes

Right now if we have directory declared as follows:

resource "databricks_directory" "test" {
  path = "/Users/user@domain/TF_DIR_WITH_SLASH/"
}

on update it's trying to recreate resource because REST API returns normalized path, without ending /, and this leads to following:

  # databricks_directory.test must be replaced
-/+ resource "databricks_directory" "test" {
      ~ id               = "/Users/user@domain/TF_DIR_WITH_SLASH/" -> (known after apply)
      ~ object_id        = 696671922817959 -> (known after apply)
      ~ path             = "/Users/user@domain/TF_DIR_WITH_SLASH" -> "/Users/user@domain/TF_DIR_WITH_SLASH/" # forces replacement
        # (1 unchanged attribute hidden)
    }

this patch fixes this behavior

Tests

  • make test run locally
  • separate test was added to check behaviour
  • tested manually
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

…rce when it ends with `/`

Right now if we have directory declared as follows:

```hcl
resource "databricks_directory" "test" {
  path = "/Users/user@domain/TF_DIR_WITH_SLASH/"
}
```

on update it's trying to recreate resource because REST API returns normalized path,
without ending `/`, and this leads to following:

```
  # databricks_directory.test must be replaced
-/+ resource "databricks_directory" "test" {
      ~ id               = "/Users/user@domain/TF_DIR_WITH_SLASH/" -> (known after apply)
      ~ object_id        = 696671922817959 -> (known after apply)
      ~ path             = "/Users/user@domain/TF_DIR_WITH_SLASH" -> "/Users/user@domain/TF_DIR_WITH_SLASH/" # forces replacement
        # (1 unchanged attribute hidden)
    }
```

this patch fixes this behavior
@alexott alexott requested review from a team April 8, 2023 14:03
@codecov-commenter
Copy link

Codecov Report

Merging #2204 (3b1b952) into master (1c9ef13) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2204   +/-   ##
=======================================
  Coverage   88.74%   88.74%           
=======================================
  Files         137      137           
  Lines       11220    11222    +2     
=======================================
+ Hits         9957     9959    +2     
  Misses        853      853           
  Partials      410      410           
Impacted Files Coverage Δ
workspace/resource_directory.go 100.00% <100.00%> (ø)

@nfx nfx enabled auto-merge (squash) April 11, 2023 09:46
@nfx nfx merged commit e30b8e0 into master Apr 11, 2023
nfx added a commit that referenced this pull request Apr 14, 2023
# Version changelog

## 1.14.3

 * Add exporter support for [databricks_sql_alert](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_alert) ([#2207](#2207)).
 * Add support for notifications in [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) resource ([#2218](#2218)).
 * Add suppress diff for `path` argument of [databricks_directory](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/directory) resource when it ends with `/` ([#2204](#2204)).
 * Exporter: don't export `storage` when [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) was created with default value ([#2203](#2203)).
 * Exporter: phase 1 of support for Account-level exports ([#2205](#2205)).
 * Fixed regression in [databricks_group](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/group) data not to require workspace admin privileges ([#2210](#2210)).
 * Suppress diff for `edition` attribute in [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) ([#2219](#2219)).
@nfx nfx mentioned this pull request Apr 14, 2023
nfx added a commit that referenced this pull request Apr 14, 2023
# Version changelog

## 1.14.3

 * Add exporter support for [databricks_sql_alert](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_alert) ([#2207](#2207)).
 * Add support for notifications in [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) resource ([#2218](#2218)).
 * Add suppress diff for `path` argument of [databricks_directory](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/directory) resource when it ends with `/` ([#2204](#2204)).
 * Exporter: don't export `storage` when [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) was created with default value ([#2203](#2203)).
 * Exporter: phase 1 of support for Account-level exports ([#2205](#2205)).
 * Fixed regression in [databricks_group](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/group) data not to require workspace admin privileges ([#2210](#2210)).
 * Suppress diff for `edition` attribute in [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) ([#2219](#2219)).
slwbuild pushed a commit to slwbuild/terraform-provider-databricks that referenced this pull request Apr 24, 2023
…rce when it ends with `/` (databricks#2204)

Right now if we have directory declared as follows:

```hcl
resource "databricks_directory" "test" {
  path = "/Users/user@domain/TF_DIR_WITH_SLASH/"
}
```

on update it's trying to recreate resource because REST API returns normalized path,
without ending `/`, and this leads to following:

```
  # databricks_directory.test must be replaced
-/+ resource "databricks_directory" "test" {
      ~ id               = "/Users/user@domain/TF_DIR_WITH_SLASH/" -> (known after apply)
      ~ object_id        = 696671922817959 -> (known after apply)
      ~ path             = "/Users/user@domain/TF_DIR_WITH_SLASH" -> "/Users/user@domain/TF_DIR_WITH_SLASH/" # forces replacement
        # (1 unchanged attribute hidden)
    }
```

this patch fixes this behavior
slwbuild pushed a commit to slwbuild/terraform-provider-databricks that referenced this pull request Apr 24, 2023
# Version changelog

## 1.14.3

 * Add exporter support for [databricks_sql_alert](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_alert) ([databricks#2207](databricks#2207)).
 * Add support for notifications in [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) resource ([databricks#2218](databricks#2218)).
 * Add suppress diff for `path` argument of [databricks_directory](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/directory) resource when it ends with `/` ([databricks#2204](databricks#2204)).
 * Exporter: don't export `storage` when [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) was created with default value ([databricks#2203](databricks#2203)).
 * Exporter: phase 1 of support for Account-level exports ([databricks#2205](databricks#2205)).
 * Fixed regression in [databricks_group](https://registry.terraform.io/providers/databricks/databricks/latest/docs/data-sources/group) data not to require workspace admin privileges ([databricks#2210](databricks#2210)).
 * Suppress diff for `edition` attribute in [databricks_pipeline](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/pipeline) ([databricks#2219](databricks#2219)).
@nkvuong nkvuong deleted the directory-path-suppress-diff branch October 3, 2023 10:31
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.

3 participants