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

Migrate to terraform-plugin-sdk #346

Merged
merged 2 commits into from
Feb 4, 2020

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Oct 23, 2019

Step 1: Upgrade to hashicorp/terraform v0.12.7 to prepare for plugin-sdk migration
this is required to meet the check for tf-migrator constraints

Step 2: Perform the migration

▶ GO111MODULE=on tf-sdk-migrator check
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.7: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.

All constraints satisfied. Provider can be migrated to the new SDK.
▶ GO111MODULE=on tf-sdk-migrator migrate
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.7: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.

All constraints satisfied. Provider can be migrated to the new SDK.

Rewriting provider go.mod file...
Rewriting SDK package imports...
Running `go mod tidy`...
Success! Provider is migrated to github.com/hashicorp/terraform-plugin-sdk v1.1.0.

It looks like this provider vendors dependencies. Don't forget to run `go mod vendor`.
Make sure to review all changes and run all tests.

@bkabrda
Copy link
Contributor

bkabrda commented Feb 4, 2020

@stack72 hey, could you please rebase? I'm ok with migrating to the SDK, but can't merge this because of conflicts. Thanks!

@stack72
Copy link
Contributor Author

stack72 commented Feb 4, 2020

Hi @bkabrda

PR updated and rebased - this would make me very happy if this got merged and released :)

Paul

@bkabrda
Copy link
Contributor

bkabrda commented Feb 4, 2020

Thanks for the quick response! I'm now testing all the changes locally to make sure this doesn't break anything. If tests pass, I'm going to merge (because I like making people happy ;))

@stack72
Copy link
Contributor Author

stack72 commented Feb 4, 2020

Awesome! Let me know if you need any changes :) I'm sure we can also ask the nice people of Terraform to kick off a set of acceptance tests!

@bkabrda
Copy link
Contributor

bkabrda commented Feb 4, 2020

Yeah, I'm trying to run acceptance tests locally, so that will speed things up. Right now, it seems I can't even execute the tests because I'm getting this error:

# github.com/hashicorp/terraform-plugin-sdk/internal/earlyconfig
../../../../pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.1.0/internal/earlyconfig/config.go:89:20: cannot range over reqs (type *tfconfig.ProviderRequirement)
FAIL	github.com/terraform-providers/terraform-provider-datadog/datadog [build failed]
FAIL

Have you seen that already?

@stack72
Copy link
Contributor Author

stack72 commented Feb 4, 2020

What command are you running for this? The code is compiling here:

▶ make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v  -timeout 120m
?   	github.com/terraform-providers/terraform-provider-datadog	[no test files]
=== RUN   TestAccDatadogIpRangesDatasource_existing
=== PAUSE TestAccDatadogIpRangesDatasource_existing
=== RUN   TestDatadogDowntime_import
--- FAIL: TestDatadogDowntime_import (0.00s)
    provider_test.go:33: DATADOG_API_KEY must be set for acceptance tests
=== RUN   TestDatadogIntegrationPagerduty_import
--- FAIL: TestDatadogIntegrationPagerduty_import (0.00s)
    provider_test.go:33: DATADOG_API_KEY must be set for acceptance tests
=== RUN   TestAccLogsCustomPipeline_importBasic
--- FAIL: TestAccLogsCustomPipeline_importBasic (0.00s)
    provider_test.go:33: DATADOG_API_KEY must be set for acceptance tests

@bkabrda
Copy link
Contributor

bkabrda commented Feb 4, 2020

I'm running make testacc as well. I also tried running it with GO111MODULE=off, which gave me pretty much the same error:

# github.com/terraform-providers/terraform-provider-datadog/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/earlyconfig
vendor/github.com/hashicorp/terraform-plugin-sdk/internal/earlyconfig/config.go:89:20: cannot range over reqs (type *tfconfig.ProviderRequirement)
FAIL	github.com/terraform-providers/terraform-provider-datadog/datadog [build failed]
FAIL

```
▶ GO111MODULE=on tf-sdk-migrator check
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.7: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.

All constraints satisfied. Provider can be migrated to the new SDK.
```

```
▶ GO111MODULE=on tf-sdk-migrator migrate
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.7: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.

All constraints satisfied. Provider can be migrated to the new SDK.

Rewriting provider go.mod file...
Rewriting SDK package imports...
Running `go mod tidy`...
Success! Provider is migrated to github.com/hashicorp/terraform-plugin-sdk v1.1.0.

It looks like this provider vendors dependencies. Don't forget to run `go mod vendor`.
Make sure to review all changes and run all tests.
```
@stack72
Copy link
Contributor Author

stack72 commented Feb 4, 2020

@bkabrda looks like this is a way older version of the SDK since I opened it a long time ago - I just upgraded the SDK version - wanna try the updated PR now?

@bkabrda
Copy link
Contributor

bkabrda commented Feb 4, 2020

Yup, the tests are running now. Thanks. Running all the integration tests takes a while, I'll let you know how it goes.

@stack72
Copy link
Contributor Author

stack72 commented Feb 4, 2020

Great news :) Thanks!!

@bkabrda
Copy link
Contributor

bkabrda commented Feb 4, 2020

🎉 all tests are passing. The PR LGTM, so no further objections from my side. Merging. Thanks for the contribution!

@bkabrda bkabrda merged commit 32d929c into DataDog:master Feb 4, 2020
@stack72
Copy link
Contributor Author

stack72 commented Feb 4, 2020

You rock! thanks for this - looking forward to the next release :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants