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

policy_set data and resource change to include attributes from PPRV #1234

Merged
merged 4 commits into from
Feb 1, 2024

Conversation

mrinalirao
Copy link
Contributor

@mrinalirao mrinalirao commented Jan 31, 2024

Description

Now that pinned policy runtime version is in GA, we have two new attributes in the policy set : agent_enabled and policy_tool_version. This PR updates the policy_set resource and data to reflect the same.

Note: This is tested against an unreleased commit of the go-tfe library: hashicorp/go-tfe#752
Once go-tfe version is released, this PR needs to updated with the latest version

Remember to:

Output from acceptance tests

Needs the following env vars:
TFE_HOSTNAME=tfcdev-1dfef877.au.ngrok.io;
TFE_TOKEN=
ENABLE_BETA=1
TF_ACC=1;

Data source tests:

/usr/local/go/bin/go tool test2json -t /private/var/folders/dw/g3nt1z3d5sl4ll_r8f27ytwc0000gq/T/GoLand/___24TestAccTFEPolicySetDataSource_basic_in_github_com_hashicorp_terraform_provider_tfe_internal_provider.test -test.v -test.paniconexit0 -test.run ^\QTestAccTFEPolicySetDataSource_basic\E$
=== RUN   TestAccTFEPolicySetDataSource_basic
--- PASS: TestAccTFEPolicySetDataSource_basic (28.57s)
PASS

=== RUN   TestAccTFEPolicySetDataSource_pinnedPolicyRuntimeVersion
--- PASS: TestAccTFEPolicySetDataSource_pinnedPolicyRuntimeVersion (34.84s)
PASS


=== RUN   TestAccTFEPolicySetDataSourceOPA_basic
--- PASS: TestAccTFEPolicySetDataSourceOPA_basic (31.35s)
PASS

=== RUN   TestAccTFEPolicySetDataSource_vcs
--- SKIP: TestAccTFEPolicySetDataSource_vcs (7.74s)

=== RUN   TestAccTFEPolicySetDataSource_notFound
--- PASS: TestAccTFEPolicySetDataSource_notFound (7.51s)
PASS

Resource Tests:

=== RUN   TestAccTFEPolicySet_basic
--- PASS: TestAccTFEPolicySet_basic (19.89s)
PASS

=== RUN   TestAccTFEPolicySet_pinnedPolicyRuntimeVersion
--- PASS: TestAccTFEPolicySet_pinnedPolicyRuntimeVersion (19.09s)
PASS

=== RUN   TestAccTFEPolicySetOPA_basic
--- PASS: TestAccTFEPolicySetOPA_basic (12.79s)
PASS

=== RUN   TestAccTFEPolicySet_updateOverridable
--- PASS: TestAccTFEPolicySet_updateOverridable (49.19s)
PASS

=== RUN   TestAccTFEPolicySet_update
--- PASS: TestAccTFEPolicySet_update (35.17s)
PASS

=== RUN   TestAccTFEPolicySet_updateEmpty
--- PASS: TestAccTFEPolicySet_updateEmpty (26.25s)
PASS

=== RUN   TestAccTFEPolicySet_updatePopulated
--- PASS: TestAccTFEPolicySet_updatePopulated (41.61s)
PASS

=== RUN   TestAccTFEPolicySet_updateToGlobal
--- PASS: TestAccTFEPolicySet_updateToGlobal (35.42s)
PASS

=== RUN   TestAccTFEPolicySet_updateToWorkspace
--- PASS: TestAccTFEPolicySet_updateToWorkspace (28.90s)
PASS

=== RUN   TestAccTFEPolicySet_vcs
--- SKIP: TestAccTFEPolicySet_vcs (8.18s)

=== RUN   TestAccTFEPolicySet_GithubApp
--- SKIP: TestAccTFEPolicySet_GithubApp (5.67s)

=== RUN   TestAccTFEPolicySet_updateVCSBranch
--- SKIP: TestAccTFEPolicySet_updateVCSBranch (5.98s)

=== RUN   TestAccTFEPolicySet_versionedSlug
--- PASS: TestAccTFEPolicySet_versionedSlug (13.15s)
PASS

=== RUN   TestAccTFEPolicySet_versionedSlugUpdate
--- PASS: TestAccTFEPolicySet_versionedSlugUpdate (21.13s)
PASS

=== RUN   TestAccTFEPolicySet_versionedNoConflicts
--- PASS: TestAccTFEPolicySet_versionedNoConflicts (6.04s)
PASS

=== RUN   TestAccTFEPolicySet_invalidName
--- PASS: TestAccTFEPolicySet_invalidName (9.69s)
PASS

=== RUN   TestAccTFEPolicySetImport
--- PASS: TestAccTFEPolicySetImport (20.76s)
PASS

Documentation Screenshots:
Screenshot 2024-01-31 at 2 50 31 pm
Screenshot 2024-01-31 at 2 50 40 pm
Screenshot 2024-01-31 at 2 50 47 pm

Screenshot 2024-01-31 at 2 51 16 pm

@mrinalirao mrinalirao marked this pull request as ready for review January 31, 2024 03:53
@mrinalirao mrinalirao requested a review from a team as a code owner January 31, 2024 03:53
Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

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

Great work! Some preliminary feedback below ⬇️

go.mod Outdated Show resolved Hide resolved
internal/provider/data_source_policy_set.go Outdated Show resolved Hide resolved
internal/provider/data_source_policy_set_test.go Outdated Show resolved Hide resolved
org, orgCleanup := createBusinessOrganization(t, tfeClient)
t.Cleanup(orgCleanup)
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is available in TFE, we should add a check here to only upgrade the subscription if it is not enterpriseEnabled()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't that check already included inside the createBusinessOrg function here? https://github.com/hashicorp/terraform-provider-tfe/blob/main/internal/provider/testing.go#L76

Copy link
Contributor

Choose a reason for hiding this comment

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

createBusinessOrg skips the test for TFE since there are no feature sets in TFE. So it should look something along these lines:

var org *tfe.Organization
var cleanup func()

if enterpriseEnabled(t) {
  org, cleanup = createOrganization()
} else {
  // we are in TFC so we have a subscription to upgrade, otherwise nothing to upgrade
  org, cleanup = createBusinessOrganization()
}

internal/provider/resource_tfe_policy_set.go Outdated Show resolved Hide resolved
Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@mrinalirao mrinalirao merged commit b6edd1b into main Feb 1, 2024
9 checks passed
@mrinalirao mrinalirao deleted the mr/pprv_policy_set_api branch February 1, 2024 22: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.

2 participants