Skip to content

Conversation

@dikhan
Copy link
Owner

@dikhan dikhan commented Dec 17, 2020

What problem does this Pull Request solve?

Please link to the issue number here (issue will be closed when PR is merged): Closes #268

Terraform Plugin SDK v2 Upgrade checklist:

  • Dropped Support for Terraform 0.11 and Below
  • Version 2 of the Module
  • A New Acceptance Testing Driver
  • More Support for context.Context
  • Support for Diagnostics
  • Support for Resource-Level and Field-Level Descriptions
  • New Diagnostics-Enabled Map Validators
    • N/A
  • Support for Debuggable Provider Binaries
  • Support for Provider Metadata
    • N/A
  • Louder helper/schema.ResourceData.Set Errors in Testing
    • N/A
  • More Consistent Usage of github.com/mitchellh/go-testing-interface
    • N/A
  • Corrected Results of helper/acctest.RandIntRange
    • N/A
  • Clearer Handling of nil for helper/resource.NonRetryableError and helper/resource.RetryableError
    • N/A
  • More Robust Handling of helper/schema.TypeSet Hashes
    • N/A
  • Stronger Validation for helper/schema.Schema.Computed Fields
    • N/A, the OpenAPI Terraform provider does not support/allow Computed properties that are not Optional.
  • More Robust Validation of helper/schema.TypeMap Elems
  • More Robust Validation of helper/resource.TestCheckResourceAttrPair
    • N/A: helper/resource.TestCheckResourceAttrPair are not used at the moment
  • More Robust Validation of Test Sweepers
    • N/A
  • Deprecation of helper/schema.ExistsFunc
    • N/A: helper/schema.ExistsFunc was not supported already
  • Deprecation of helper/schema.SchemaValidateFunc
  • Removal of helper/mutexkv Package
    • N/A: helper/mutexkv Package was not used
  • Removal of helper/pathorcontents Package
    • N/A: helper/pathorcontents Package was not used
  • Removal of httpclient Package
  • Removal of helper/hashcode Package
    • Replaced with hash/crc32 Package instead as advised
  • Removal of the acctest Package
    • N/A: acctest Package was not used
  • Removal of the terraform.ResourceProvider Interface
  • Removal of the helper/schema.Provider.StopContext method
    • N/A: helper/schema.Provider.StopContext method was not used
  • Removal of helper/schema.ResourceData.SetPartial
    • N/A: helper/schema.ResourceData.SetPartial was not used
  • Removal of the helper/schema.Provider.MetaReset property
    • N/A: helper/schema.Provider.MetaReset was not used
  • Removal of Deprecated Validation Functions
    • N/A: Validation Functions was not used
  • Removal of helper/schema.Schema.PromoteSingle
    • N/A: helper/schema.Schema.PromoteSingle was not used
  • Removal of helper/schema.ResourceData.UnsafeSetFieldRaw
    • N/A: helper/schema.ResourceData.UnsafeSetFieldRaw was not used
  • Removal of helper/schema.Resource.Refresh
    • N/A: helper/schema.Schema.Refresh was not used
  • Removal of helper/schema.Schema.Removed
    • N/A: helper/schema.Schema.Removed was not used
  • Removal of helper/encryption Package
    • N/A: helper/encryption Package was not used
  • Removal of Discouraged Variables, Functions, Types, and Interfaces
    • N/A

Type of change

What type of change does your code introduce to the provider? Please put an x (w/o heading/trailing white spaces) in the boxes that apply:

  • New feature (change that adds new functionality)
  • Bug-fix (change that fixes current functionality)
  • Tech debt (enhances the current functionality)
  • New release (pumps the version)

Checklist

Please put an x (w/o heading/trailing white spaces) in the boxes that apply:

  • I have read and followed the CONTRIBUTING guidelines
  • I have added tests that prove my fix is effective or that my feature works
  • I have made sure code compiles correctly and all tests are passing by running make test-all
  • I have added/updated necessary documentation (if appropriate)
  • I have added the following info to the title of the PR (pick the appropriate option for the type of change). This is important because the release notes will include this information.
    • Feature Request: PRs related to feature requests should have in the title [FeatureRequest: Issue #X] <PR Title>
    • Bug Fixes: PRs related to bug fixes should have in the title [BugFix: Issue #X] <PR Title>
    • Tech Debt: PRs related to technical debt should have in the title [TechDebt: Issue #X] <PR Title>
    • New Release: PRs related to a new release should have in the title [NewRelease] vX.Y.Z

Checklist for Admins

  • Label is populated
  • PR is assigned to the corresponding project
  • PR has at least 1 reviewer and 1 assignee

@dikhan dikhan self-assigned this Dec 17, 2020
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from b238ee2 to ed73607 Compare December 17, 2020 04:23
…deprecation notice

// Providers is the ResourceProvider that will be under test.
// Deprecated: Providers is deprecated, please use ProviderFactories
As per Terraform notes: It is recommended, but not required, that providers that have not already dropped support for 0.11 issue a major version bump when upgrading to version 2 of the SDK, to indicate this dropped support.

https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#dropped-support-for-terraform-0-11-and-below
https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#version-2-of-the-module
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from 6b129c8 to eff1b13 Compare December 18, 2020 01:33
@codecov
Copy link

codecov bot commented Dec 19, 2020

Codecov Report

Merging #274 (2f1f61a) into master (5d335a8) will increase coverage by 1.03%.
The diff coverage is 68.49%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #274      +/-   ##
==========================================
+ Coverage   90.97%   92.00%   +1.03%     
==========================================
  Files          61       60       -1     
  Lines        3091     3041      -50     
==========================================
- Hits         2812     2798      -14     
+ Misses        184      164      -20     
+ Partials       95       79      -16     
Impacted Files Coverage Δ
openapi/openapi_client.go 84.54% <ø> (ø)
openapi/openapi_spec_header.go 100.00% <ø> (ø)
openapi/openapi_spec_resource_schema_definition.go 97.36% <ø> (ø)
.../openapi_spec_security_definition_apikey_header.go 100.00% <ø> (ø)
...i_spec_security_definition_apikey_header_bearer.go 100.00% <ø> (ø)
...i/openapi_spec_security_definition_apikey_query.go 100.00% <ø> (ø)
...pi_spec_security_definition_apikey_query_bearer.go 100.00% <ø> (ø)
...i_spec_security_definition_apikey_refresh_token.go 84.21% <ø> (ø)
openapi/openapi_spec_security_schemes.go 100.00% <ø> (ø)
openapi/openapi_stub_backend_configuration.go 86.66% <ø> (ø)
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d335a8...2f1f61a. Read the comment docs.

@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from 28be277 to 3d2b872 Compare December 19, 2020 18:13
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch 3 times, most recently from 31c866c to cc3f054 Compare December 21, 2020 00:46
dikhan added 12 commits January 17, 2021 20:18
…' Module

As per Terraform notes: It is recommended, but not required, that providers that have not already dropped support for 0.11 issue a major version bump when upgrading to version 2 of the SDK, to indicate this dropped support.

https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#dropped-support-for-terraform-0-11-and-below
https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#version-2-of-the-module
  - Terraform Plugin SDK v2 Upgrade Guide: Using a *helper/schema.Resource
    as the value of the Elem property for a *helper/schema.Schema previously
    yielded unspecified and likely confusing behavior, and was unsupported. It now returns an error.
    https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#more-robust-validation-of-helper-schema-typemap-elems

Internal notes:
  - This commit introduces breaking changes and OpenAPI property of type object will now be translated into a Terraform
  schema of TypeList with Elem *Resource and MaxItems 1 (read more in the openapi_terraform_provider_v1.0.0.md)
  - Deprecated the extension `x-terraform-complex-object-legacy-config` since object type now follow the extension's behaviour
  by default (read more in the how_to.md)
  - Removed from SpecSchemaDefinitionProperty the field EnableLegacyComplexObjectBlockConfiguration that mapped to the x-terraform-complex-object-legacy-config extension
  - convertPayloadToLocalStateDataValue no longer accepts `useString bool` as that was introduced as a workaround to be
  able to support helper/schema.TypeMap with *helper/schema.Resource as the value of the Elem property which expected data stored
  in the state as string no matter what type the actual what type the key property of the hashmap was. This eliminates the undefined behaviour not supported with using helper/schema.TypeMap with *helper/schema.Resource as the value of the Elem property.
  - populatePayload no longer expects string types to not match the actual proeprty type, which was the case when processing hashmaps properties due to how Terraform
  stores the data as string.
  - Fixed unit tests and integration tests
  - updated release notes with deprecated support for OpenAPI property type object with internal Terraform schema representation
  of TypeMap with Elem *Resource
…ud functions

  - Terraform Plugin SDK v2 Upgrade Guide: A number of new functions have been added that return a diag.Diagnostics type. This type can be used to return multiple errors and warnings to Terraform, and to associate those errors or warnings with specific fields. The functions supporting diagnostics are: helper/schema.CreateContextFunc, helper/schema.ReadContextFunc, helper/schema.UpdateContextFunc and helper/schema.DeleteContextFunc.
    https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#support-for-diagnostics
  - Terraform Plugin SDK v2 Upgrade Guide: The helper/schema.Resource and helper/schema.Schema types both now have Description properties that accept strings. These properties are laying the groundwork for future improvements to Terraform, and will have no visible effect to the Terraform CLI at the moment. If you’d like to build in support for your provider starting now, it’s recommended that you set these properties to whatever you’d document the resource or field as in your terraform.io docs for the resource. You can globally set the format of the text in these fields by setting the global variable helper/schema.DescriptionKind. Its acceptable values are helper/schema.StringPlain (plain text, the default) or helper/schema.StringMarkdown (markdown formatting).
    https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#support-for-resource-level-and-field-level-descriptions
 - Terraform Plugin SDK v2 Upgrade Guide: The helper/schema.SchemaValidateFunc type and the properties that use it, including helper/schema.Schema.ValidateFunc, are now deprecated in favor of helper/schema.SchemaValidateDiagFunc, which gains awareness for diagnostics, allowing more accurate errors to be returned. The helper/validation helper functions will have helper/schema.SchemaValidateDiagFunc equivalents of the validation functions added in a future release to ease the transition. Until that point, a wrapper can be used that wraps the warnings and errors returned from helper/schema.SchemaValidateFunc in a diag.Diagnostics.
   https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#deprecation-of-helper-schema-schemavalidatefunc
Terraform SDK requires Go 1.14 or later when compiling the provider.
… make the plugin fail upon startup

- the regex now matches only against the last match and grabs the last name found
 - It is now possible to publish providers that can have debuggers like delve attached to them. To debug these providers, three things must be done. First, Terraform 0.12.26 or higher must be used when debugging. Second, the provider must modify its main function to optionally start a debuggable server. We recommend the following approach: https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#deprecation-of-helper-schema-schemavalidatefunc
  Link: https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#support-for-debuggable-provider-binaries

This commit includes the following changes:
- If the plugin is called with the debuggable flag, the plugin will be initialized using the debug functionality. The env variable
can also be provided optionality to set the providers address accordingly.
- The installation script has been updated to support only Terraform 0.12 and greater versions of installation modes.
- The example service providers (swaggercodegen and goa) have been updated accordingly to specify the required_providers as well as the source address.
- Updates in the installation documentation to reflect new changes
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from cc3f054 to a74b7f3 Compare January 18, 2021 04:21
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch 2 times, most recently from 6e406ab to 284e93b Compare January 30, 2021 02:17
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from 284e93b to adee174 Compare January 30, 2021 02:29
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from 74b14be to b5d3f84 Compare February 18, 2021 17:04
- Use OpenAPI instead of Swagger
…napi' Module

As per Terraform notes: It is recommended, but not required, that providers that have not already dropped support for 0.11 issue a major version bump when upgrading to version 2 of the SDK, to indicate this dropped support.
  - https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#dropped-support-for-terraform-0-11-and-below
  - https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#version-2-of-the-module
…ud functions for data sources

- Moved crudWithContext from resourceFactory to common so the same logic can be reused
by the resource factory and data factories
@dikhan dikhan force-pushed the feature/bump-to-terraform-sdk-2.0 branch from b5d3f84 to 003cd05 Compare February 18, 2021 17:06
- This latest version seems to fix some issues with the SDK and integration tests
- Updated documentation to make it clear Terraform v0.12.26 or later is needed when
running the integration tests
@dikhan dikhan changed the title Upgrade to Terraform SDK 2.0 [FeatureRequest: Issue #268] Upgrade to Terraform SDK 2.0 Feb 18, 2021
@dikhan dikhan changed the title [FeatureRequest: Issue #268] Upgrade to Terraform SDK 2.0 [FeatureRequest: Issue #268] Major upgrade to Terraform SDK 2.0 Feb 18, 2021
@dikhan dikhan merged commit 19a0c8f into master Feb 19, 2021
@dikhan dikhan deleted the feature/bump-to-terraform-sdk-2.0 branch February 19, 2021 19:05
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.

Upgrade to Terraform SDK 2.0

2 participants