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

dbaas: Protect against setting empty tags. #652

Merged
merged 2 commits into from
Jun 29, 2021
Merged

Conversation

andrewsomething
Copy link
Member

There seems to have been a change in the DBaaS API. It is now returning:

  "tags": [
   ""
  ]

in the response body for MongoDB clusters without any tags applied. This is wrong, but we should still protect against this here. Without doing so, we end up with a diff and a failing acceptance test:

$ make testacc TESTARGS='-run=TestAccDigitalOceanDatabaseCluster_MongoDBPassword'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccDigitalOceanDatabaseCluster_MongoDBPassword -timeout 120m
?       github.com/digitalocean/terraform-provider-digitalocean [no test files]
=== RUN   TestAccDigitalOceanDatabaseCluster_MongoDBPassword
=== PAUSE TestAccDigitalOceanDatabaseCluster_MongoDBPassword
=== CONT  TestAccDigitalOceanDatabaseCluster_MongoDBPassword
    resource_digitalocean_database_cluster_test.go:409: Step 1/1 error: After applying this test step, the plan was not empty.
        stdout:
        
        
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        
        Terraform will perform the following actions:
        
          # digitalocean_database_cluster.foobar will be updated in-place
          ~ resource "digitalocean_database_cluster" "foobar" {
                id           = "1f706e9a-ada4-434c-9058-b7086a2a79e4"
                name         = "tf-acc-test-xda03f78tl"
              ~ tags         = [
                  - "",
                ]
                # (14 unchanged attributes hidden)
            }
        
        Plan: 0 to add, 1 to change, 0 to destroy.
    testing_new.go:63: Error running post-test destroy, there may be dangling resources: DatabaseCluster still exists
--- FAIL: TestAccDigitalOceanDatabaseCluster_MongoDBPassword (385.09s)

These changes applied resolve that problem.

Copy link
Member

@bentranter bentranter left a comment

Choose a reason for hiding this comment

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

👍

@scotchneat
Copy link
Contributor

nice catch

@andrewsomething andrewsomething merged commit 3d53e76 into main Jun 29, 2021
@andrewsomething andrewsomething deleted the asb/flatten-tags branch June 29, 2021 15:42
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.

None yet

3 participants