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

Update to use Terraform Multiplexer #565

Merged
merged 73 commits into from
Sep 13, 2023
Merged

Update to use Terraform Multiplexer #565

merged 73 commits into from
Sep 13, 2023

Conversation

AnPucel
Copy link
Contributor

@AnPucel AnPucel commented Jul 27, 2023

🛠️ Description

This PR introduces the Terraform framework multiplexer at the top level to allow for the migration of Terraform resources from the SDKv2 to the plugin framework.

This also includes migrating the Vault Secrets App data source to the new plugin framework.

There have been manual upgrade tests run on the following resources by creating resources using the HCP Provider version 0.68.0 and switching to a local dev provider with the muxer changes to verify no changes were expected. The following manual tests were run on the following resources:

  • boundary cluster
  • consul cluster
  • vault cluster
  • hvn

This also contains maintainability fixes moving forward:

  • Moving all providers into a new package providersdkv2
  • Creating a separate package for resources and data sources within a new package

🏗️ Acceptance tests

  • Are there any feature flags that are required to use this functionality?
  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

# Vault Secrets tests
=== RUN   TestAcc_dataSourceVaultSecretsAppMigration
--- PASS: TestAcc_dataSourceVaultSecretsAppMigration (33.25s)
=== RUN   TestAcc_dataSourceVaultSecretsApp
--- PASS: TestAcc_dataSourceVaultSecretsApp (17.08s)

# Boundary tests
--- PASS: TestAccBoundaryCluster (246.51s)
PASS

# Consul tests
--- PASS: TestAccConsulCluster (1393.78s)
--- PASS: TestAccConsulSnapshot (1132.88s)
--- PASS: Test_validateConsulClusterTier (0.00s)
    --- PASS: Test_validateConsulClusterTier/development (0.00s)
    --- PASS: Test_validateConsulClusterTier/standard (0.00s)
    --- PASS: Test_validateConsulClusterTier/plus (0.00s)
    --- PASS: Test_validateConsulClusterTier/valid_tier_lowercase (0.00s)
    --- PASS: Test_validateConsulClusterTier/valid_tier_uppercase (0.00s)
    --- PASS: Test_validateConsulClusterTier/valid_tier_mixedcase (0.00s)
    --- PASS: Test_validateConsulClusterTier/invalid_tier (0.00s)
--- PASS: Test_validateConsulClusterSize (0.00s)
    --- PASS: Test_validateConsulClusterSize/valid_size (0.00s)
    --- PASS: Test_validateConsulClusterSize/valid_size_lowercase (0.00s)
    --- PASS: Test_validateConsulClusterSize/valid_size_uppercase (0.00s)
    --- PASS: Test_validateConsulClusterSize/valid_size_mixedcase (0.00s)
    --- PASS: Test_validateConsulClusterSize/invalid_tier (0.00s)
--- PASS: Test_validateConsulClusterCIDR (0.00s)
    --- PASS: Test_validateConsulClusterCIDR/valid_IP_address (0.00s)
    --- PASS: Test_validateConsulClusterCIDR/invalid_ip_address (0.00s)
    --- PASS: Test_validateConsulClusterCIDR/IPV6_unsupported (0.00s)
--- PASS: Test_validateConsulClusterCIDRDescription (0.00s)
    --- PASS: Test_validateConsulClusterCIDRDescription/valid_description (0.00s)
    --- PASS: Test_validateConsulClusterCIDRDescription/invalid_ip_address (0.00s)
PASS
ok      github.com/hashicorp/terraform-provider-hcp/internal/provider   2527.642s

# HVN tests
--- PASS: TestAccHvnPeeringConnection (242.92s)
--- PASS: TestAccHvnRoute (357.69s)
--- PASS: TestAccAwsHvnOnly (163.24s)
--- PASS: TestAccAzureHvnOnly (296.61s)
PASS

# Packer tests
--- PASS: TestAcc_dataSourcePackerBucketNames (57.22s)
--- PASS: TestAcc_dataSourcePacker (15.79s)
--- PASS: TestAcc_dataSourcePacker_revokedIteration (21.30s)
--- PASS: TestAcc_dataSourcePackerRunTask (29.88s)
--- PASS: TestAccPackerRunTask (66.07s)
--- PASS: TestAcc_dataSourcePackerImage_emptyChannel (4.77s)
--- PASS: TestAccPackerChannelAssignment_HCPManagedChannelErrors (12.45s)
--- PASS: TestAcc_dataSourcePackerIteration_revokedIteration (15.56s)
--- PASS: TestAcc_dataSourcePackerImage_channelAndIterationIDReject (0.30s)
--- PASS: TestAccPackerChannelAssignment_InvalidInputs (19.38s)
--- PASS: TestAcc_dataSourcePackerImage_revokedIteration (15.48s)
--- PASS: TestAcc_dataSourcePackerImage_IterationID (16.36s)
--- PASS: TestAcc_dataSourcePackerIteration_Simple (29.29s)
--- PASS: TestAcc_dataSourcePackerImage_Simple (32.40s)
--- PASS: TestAccPackerChannelAssignment_SimpleSetUnset (42.60s)
--- PASS: TestAccPackerChannelAssignment_AssignLatest (48.44s)
--- PASS: TestAccPackerChannelAssignment_CreateFailsWhenPreassigned (27.24s)
--- PASS: TestAccPackerChannel (56.54s)
--- PASS: TestAccPackerChannel_HCPManaged (58.11s)
--- PASS: TestAccPackerChannel_RestrictionDrift (64.74s)
--- PASS: TestAccPackerChannel_RestrictionDriftHCPManaged (65.23s)
--- PASS: TestAccPackerChannelAssignment_EnforceNull (96.65s)
PASS

@AnPucel AnPucel changed the base branch from main to anpucel/HVSFeatures August 4, 2023 16:51
@AnPucel AnPucel changed the title [WIP] Update to use Terraform Multiplexer Update to use Terraform Multiplexer Aug 4, 2023
@AnPucel AnPucel marked this pull request as ready for review August 7, 2023 20:38
@AnPucel AnPucel requested a review from a team as a code owner August 7, 2023 20:38
@AnPucel AnPucel requested a review from a team August 7, 2023 20:38
@AnPucel AnPucel requested a review from a team as a code owner August 7, 2023 20:38
@AnPucel AnPucel requested review from codergs and hashiblaum and removed request for a team August 7, 2023 20:38
@AnPucel AnPucel changed the base branch from anpucel/HVSFeatures to main August 8, 2023 16:15
@AnPucel AnPucel requested a review from blueberry-pi August 30, 2023 23:26
Copy link
Contributor

@aidan-mundy aidan-mundy left a comment

Choose a reason for hiding this comment

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

Great stuff! Just a few minor nits regarding naming/style and duplicated code

@@ -9,7 +9,7 @@ import (
"io"
Copy link
Contributor

Choose a reason for hiding this comment

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

We can deduplicate this code by writing a method that converts the diagnostics. I would use this file as the default implementation, and have the conversion method take new diags, and convert them to old diags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Theoretically, this should be the statuspage that we end up using in the long run anyway. And the old one should go away. I think the duplication makes sense when all of the products convert and we can remove the old code. And I don't know if we gain a lot by having a method to convert diagnostics, if this is one of the only methods we have to do it for.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it will take a long time to convert all resources, so I would prioritize minimal duplication where possible. Converting diagnostics should be trivial, there may even be a method for it already in the mux package somewhere.

}

// getProjectFromCredentials uses the configured client credentials to
// fetch the associated organization and returns that organization's
// single project.
func getProjectFromCredentials(ctx context.Context, client *clients.Client) (project *models.HashicorpCloudResourcemanagerProject, diags diag.Diagnostics) {
// This differs from the provider.go implementation due to the diagnostics used
// by the plugin framework.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should deduplicate this code, similar to the approach described for statuspage.go

}

// getOldestProject retrieves the oldest project from a list based on its created_at time.
func GetOldestProject(projects []*models.HashicorpCloudResourcemanagerProject) (oldestProj *models.HashicorpCloudResourcemanagerProject) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Code is duplicated 1:1 in the framework provider. Can this be deduped?

Copy link
Contributor

@aidan-mundy aidan-mundy left a comment

Choose a reason for hiding this comment

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

Approving to unblock. We can follow up on some of the duplicated code in a future PR

@AnPucel AnPucel merged commit 99f6196 into main Sep 13, 2023
@AnPucel AnPucel deleted the anpucel/TFFrameworkMux branch September 13, 2023 16:37
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.

8 participants