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 new terraform plugin sdk #130

Merged
merged 3 commits into from
Feb 18, 2020
Merged

Conversation

nicsnet
Copy link
Member

@nicsnet nicsnet commented Feb 13, 2020

Description

This migrates the provider over to the plugin sdk using the migrator tool

Test plan output

Building the migrated provider and using it with this config, led to the following plan which executed successfully.

Terraform will perform the following actions:

  # tfe_policy_set.always_false will be created
  + resource "tfe_policy_set" "always_false" {
      + description            = "this policy is always false!"
      + global                 = false
      + id                     = (known after apply)
      + name                   = "always-false"
      + organization           = "stacy_provider_vartest"
      + policy_ids             = (known after apply)
      + workspace_external_ids = [
          + "ws-Dk8QeQWRFJSfaVZj",
        ]
    }

  # tfe_policy_set.always_true will be created
  + resource "tfe_policy_set" "always_true" {
      + description            = "this policy is always true!"
      + global                 = false
      + id                     = (known after apply)
      + name                   = "always-true"
      + organization           = "stacy_provider_vartest"
      + policy_ids             = (known after apply)
      + workspace_external_ids = [
          + "ws-zm1CSM86inpe2E6H",
        ]
    }

  # tfe_policy_set.maybe_maybe will be created
  + resource "tfe_policy_set" "maybe_maybe" {
      + description            = "this policy is dependent on a parameter"
      + global                 = false
      + id                     = (known after apply)
      + name                   = "maybe-maybe"
      + organization           = "stacy_provider_vartest"
      + workspace_external_ids = [
          + "ws-Dk8QeQWRFJSfaVZj",
        ]

      + vcs_repo {
          + branch             = "master"
          + identifier         = "acespacecase/terraform-multi"
          + ingress_submodules = false
          + oauth_token_id     = "ot-CNZfVntbzrBrnSfb"
        }
    }

  # tfe_policy_set_parameter.maybe will be created
  + resource "tfe_policy_set_parameter" "maybe" {
      + id            = (known after apply)
      + key           = "maybe"
      + policy_set_id = (known after apply)
      + sensitive     = false
      + value         = (sensitive value)
    }

  # tfe_sentinel_policy.always_false_policy will be created
  + resource "tfe_sentinel_policy" "always_false_policy" {
      + description  = (known after apply)
      + enforce_mode = "soft-mandatory"
      + id           = (known after apply)
      + name         = "always-false-policy"
      + organization = "stacy_provider_vartest"
      + policy       = "main = rule { false }"
    }

  # tfe_sentinel_policy.always_true_policy will be created
  + resource "tfe_sentinel_policy" "always_true_policy" {
      + description  = (known after apply)
      + enforce_mode = "hard-mandatory"
      + id           = (known after apply)
      + name         = "always-true-policy"
      + organization = "stacy_provider_vartest"
      + policy       = "main = rule { true }"
    }

  # tfe_ssh_key.test will be created
  + resource "tfe_ssh_key" "test" {
      + id           = (known after apply)
      + key          = (sensitive value)
      + name         = "my-ssh-key"
      + organization = "stacy_provider_vartest"
    }

  # tfe_team.pasta will be created
  + resource "tfe_team" "pasta" {
      + id           = (known after apply)
      + name         = "spaghetti"
      + organization = "stacy_provider_vartest"
    }

  # tfe_team.sushi will be created
  + resource "tfe_team" "sushi" {
      + id           = (known after apply)
      + name         = "nigiri"
      + organization = "stacy_provider_vartest"
    }

  # tfe_team_access.noodles will be created
  + resource "tfe_team_access" "noodles" {
      + access       = "admin"
      + id           = (known after apply)
      + team_id      = (known after apply)
      + workspace_id = "stacy_provider_vartest/higgins-the-cat"
    }

  # tfe_team_member.nsheldrick will be created
  + resource "tfe_team_member" "nsheldrick" {
      + id       = (known after apply)
      + team_id  = (known after apply)
      + username = "nsheldrick"
    }

  # tfe_team_members.pasta will be created
  + resource "tfe_team_members" "pasta" {
      + id        = (known after apply)
      + team_id   = (known after apply)
      + usernames = [
          + "nsheldrick",
        ]
    }

  # tfe_team_token.test will be created
  + resource "tfe_team_token" "test" {
      + id      = (known after apply)
      + team_id = (known after apply)
      + token   = (sensitive value)
    }

Plan: 13 to add, 0 to change, 0 to destroy.

External links

Migration documentation

Output from acceptance tests

$ make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v  -timeout 30m
?       github.com/terraform-providers/terraform-provider-tfe   [no test files]
=== RUN   TestAccTFESSHKeyDataSource_basic
--- PASS: TestAccTFESSHKeyDataSource_basic (20.84s)
=== RUN   TestAccTFETeamAccessDataSource_basic
--- PASS: TestAccTFETeamAccessDataSource_basic (33.46s)
=== RUN   TestAccTFETeamDataSource_basic
--- PASS: TestAccTFETeamDataSource_basic (20.54s)
=== RUN   TestAccTFEWorkspaceIDsDataSource_basic
--- PASS: TestAccTFEWorkspaceIDsDataSource_basic (21.09s)
=== RUN   TestAccTFEWorkspaceIDsDataSource_wildcard
--- PASS: TestAccTFEWorkspaceIDsDataSource_wildcard (25.52s)
=== RUN   TestAccTFEWorkspaceDataSource_basic
--- PASS: TestAccTFEWorkspaceDataSource_basic (22.66s)
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestProvider_versionConstraints
--- PASS: TestProvider_versionConstraints (0.00s)
=== RUN   TestAccTFENotificationConfiguration_basic
--- PASS: TestAccTFENotificationConfiguration_basic (20.32s)
=== RUN   TestAccTFENotificationConfiguration_update
--- PASS: TestAccTFENotificationConfiguration_update (33.73s)
=== RUN   TestAccTFENotificationConfiguration_slackWithToken
--- PASS: TestAccTFENotificationConfiguration_slackWithToken (11.66s)
=== RUN   TestAccTFENotificationConfiguration_duplicateTriggers
--- PASS: TestAccTFENotificationConfiguration_duplicateTriggers (22.84s)
=== RUN   TestAccTFENotificationConfigurationImport
--- PASS: TestAccTFENotificationConfigurationImport (26.24s)
=== RUN   TestAccTFEOAuthClient_basic
--- SKIP: TestAccTFEOAuthClient_basic (1.06s)
    resource_tfe_oauth_client_test.go:19: Please set GITHUB_TOKEN to run this test
=== RUN   TestAccTFEOrganization_basic
--- PASS: TestAccTFEOrganization_basic (14.58s)
=== RUN   TestAccTFEOrganization_update
--- PASS: TestAccTFEOrganization_update (28.39s)
=== RUN   TestAccTFEOrganization_import
--- PASS: TestAccTFEOrganization_import (14.77s)
=== RUN   TestAccTFEOrganizationToken_basic
--- PASS: TestAccTFEOrganizationToken_basic (16.26s)
=== RUN   TestAccTFEOrganizationToken_existsWithoutForce
--- PASS: TestAccTFEOrganizationToken_existsWithoutForce (23.71s)
=== RUN   TestAccTFEOrganizationToken_existsWithForce
--- PASS: TestAccTFEOrganizationToken_existsWithForce (28.86s)
=== RUN   TestAccTFEOrganizationToken_import
--- PASS: TestAccTFEOrganizationToken_import (21.63s)
=== RUN   TestAccTFEPolicySetParameter_basic
--- PASS: TestAccTFEPolicySetParameter_basic (23.07s)
=== RUN   TestAccTFEPolicySetParameter_update
--- PASS: TestAccTFEPolicySetParameter_update (38.60s)
=== RUN   TestAccTFEPolicySetParameter_import
--- PASS: TestAccTFEPolicySetParameter_import (24.82s)
=== RUN   TestAccTFEPolicySet_basic
--- PASS: TestAccTFEPolicySet_basic (29.37s)
=== RUN   TestAccTFEPolicySet_update
--- PASS: TestAccTFEPolicySet_update (46.57s)
=== RUN   TestAccTFEPolicySet_updateEmpty
--- PASS: TestAccTFEPolicySet_updateEmpty (39.14s)
=== RUN   TestAccTFEPolicySet_updatePopulated
--- PASS: TestAccTFEPolicySet_updatePopulated (60.28s)
=== RUN   TestAccTFEPolicySet_updateToGlobal
--- PASS: TestAccTFEPolicySet_updateToGlobal (45.08s)
=== RUN   TestAccTFEPolicySet_updateToWorkspace
--- PASS: TestAccTFEPolicySet_updateToWorkspace (42.39s)
=== RUN   TestAccTFEPolicySet_vcs
--- SKIP: TestAccTFEPolicySet_vcs (1.05s)
    resource_tfe_policy_set_test.go:255: Please set GITHUB_TOKEN to run this test
=== RUN   TestAccTFEPolicySetImport
--- PASS: TestAccTFEPolicySetImport (28.98s)
=== RUN   TestAccTFESentinelPolicy_basic
--- PASS: TestAccTFESentinelPolicy_basic (25.69s)
=== RUN   TestAccTFESentinelPolicy_update
--- PASS: TestAccTFESentinelPolicy_update (44.01s)
=== RUN   TestAccTFESentinelPolicy_import
--- PASS: TestAccTFESentinelPolicy_import (30.44s)
=== RUN   TestAccTFESSHKey_basic
--- PASS: TestAccTFESSHKey_basic (16.18s)
=== RUN   TestAccTFESSHKey_update
--- PASS: TestAccTFESSHKey_update (29.74s)
=== RUN   TestAccTFETeamAccess_basic
--- PASS: TestAccTFETeamAccess_basic (25.97s)
=== RUN   TestAccTFETeamAccess_import
--- PASS: TestAccTFETeamAccess_import (26.33s)
=== RUN   TestPackTeamMemberID
--- PASS: TestPackTeamMemberID (0.00s)
=== RUN   TestUnpackTeamMemberID
--- PASS: TestUnpackTeamMemberID (0.00s)
=== RUN   TestAccTFETeamMember_basic
--- FAIL: TestAccTFETeamMember_basic (13.25s)
    testing.go:569: Step 0 error: errors during apply:

        Error: Error adding user "admin" to team team-ZeoQyVdSUEWZZFw9: bad request

        admin is not a member of the organization

          on /var/folders/6v/x8trb33x0llf076d39ytgtlw0000gp/T/tf-test816567920/main.tf line 12:
          (source code not available)


=== RUN   TestAccTFETeamMember_import
--- FAIL: TestAccTFETeamMember_import (11.95s)
    testing.go:569: Step 0 error: errors during apply:

        Error: Error adding user "admin" to team team-vWBASofVUL5QJB7Q: bad request

        admin is not a member of the organization

          on /var/folders/6v/x8trb33x0llf076d39ytgtlw0000gp/T/tf-test575732002/main.tf line 12:
          (source code not available)


=== RUN   TestAccTFETeamMembers_basic
--- FAIL: TestAccTFETeamMembers_basic (10.75s)
    testing.go:569: Step 0 error: errors during apply:

        Error: Error adding users to team team-EaDHQNdqGazLFdeC: bad request

        tfe-provider-user1 is not a member of the organization

          on /var/folders/6v/x8trb33x0llf076d39ytgtlw0000gp/T/tf-test512181412/main.tf line 12:
          (source code not available)


=== RUN   TestAccTFETeamMembers_update
--- FAIL: TestAccTFETeamMembers_update (10.37s)
    testing.go:569: Step 0 error: errors during apply:

        Error: Error adding users to team team-nGTsFhnVXrf1FzD4: bad request

        tfe-provider-user1 is not a member of the organization

          on /var/folders/6v/x8trb33x0llf076d39ytgtlw0000gp/T/tf-test515251574/main.tf line 12:
          (source code not available)


=== RUN   TestAccTFETeamMembers_import
--- FAIL: TestAccTFETeamMembers_import (9.93s)
    testing.go:569: Step 0 error: errors during apply:

        Error: Error adding users to team team-uYkUXLyfzFroz4df: bad request

        tfe-provider-user1 is not a member of the organization

          on /var/folders/6v/x8trb33x0llf076d39ytgtlw0000gp/T/tf-test200279064/main.tf line 12:
          (source code not available)


=== RUN   TestAccTFETeam_basic
--- PASS: TestAccTFETeam_basic (16.11s)
=== RUN   TestAccTFETeam_import
--- PASS: TestAccTFETeam_import (19.30s)
=== RUN   TestAccTFETeamToken_basic
--- PASS: TestAccTFETeamToken_basic (21.50s)
=== RUN   TestAccTFETeamToken_existsWithoutForce
--- PASS: TestAccTFETeamToken_existsWithoutForce (33.19s)
=== RUN   TestAccTFETeamToken_existsWithForce
--- PASS: TestAccTFETeamToken_existsWithForce (38.10s)
=== RUN   TestAccTFETeamToken_import
--- PASS: TestAccTFETeamToken_import (22.15s)
=== RUN   TestAccTFEVariable_basic
--- PASS: TestAccTFEVariable_basic (23.75s)
=== RUN   TestAccTFEVariable_update
--- PASS: TestAccTFEVariable_update (47.78s)
=== RUN   TestAccTFEVariable_import
--- PASS: TestAccTFEVariable_import (29.07s)
=== RUN   TestPackWorkspaceID
--- PASS: TestPackWorkspaceID (0.00s)
=== RUN   TestUnpackWorkspaceID
--- PASS: TestUnpackWorkspaceID (0.00s)
=== RUN   TestAccTFEWorkspace_basic
--- PASS: TestAccTFEWorkspace_basic (26.08s)
=== RUN   TestAccTFEWorkspace_monorepo
--- PASS: TestAccTFEWorkspace_monorepo (17.58s)
=== RUN   TestAccTFEWorkspace_renamed
--- PASS: TestAccTFEWorkspace_renamed (29.83s)
=== RUN   TestAccTFEWorkspace_update
--- FAIL: TestAccTFEWorkspace_update (28.40s)
    testing.go:569: Step 1 error: Check failed: Check 2/12 error: Bad operations: true
=== RUN   TestAccTFEWorkspace_updateFileTriggers
--- PASS: TestAccTFEWorkspace_updateFileTriggers (33.63s)
=== RUN   TestAccTFEWorkspace_sshKey
--- PASS: TestAccTFEWorkspace_sshKey (46.04s)
=== RUN   TestAccTFEWorkspace_import
--- PASS: TestAccTFEWorkspace_import (19.22s)
FAIL
FAIL    github.com/terraform-providers/terraform-provider-tfe/tfe       1494.509s
?       github.com/terraform-providers/terraform-provider-tfe/version   [no test files]
make: *** [testacc] Error 1

...

@ghost ghost added the size/XXL label Feb 13, 2020
@nicsnet nicsnet requested a review from kmoe February 13, 2020 11:50
Copy link
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lafentres lafentres left a comment

Choose a reason for hiding this comment

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

This looks good to me. I tested this by creating resources with 0.12.1, then switching to a local build of this version, and running plan to ensure I still got no changes. I then made some changes, applied them, and checked that things worked as expected. I then destroyed everything and did a fresh apply. All of which worked.

@nicsnet nicsnet merged commit 0a722bc into master Feb 18, 2020
@nicsnet nicsnet deleted the nicsnet/migrate-to-terraform-sdk branch March 4, 2020 16:11
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