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

TF-20627: Add Waypoint entitlements for organizations #984

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

ignatius-j
Copy link
Contributor

@ignatius-j ignatius-j commented Sep 30, 2024

Description

These changes add to the organizational entitlement struct to be able to
utilize the new Waypoint-based entitlements granted with HCP Terraform
feature sets:

  • waypoint-actions
  • waypoint-templates-and-addons

Testing plan

  1. Create an admin user token for an admin user with role PROVISION_LICENSES
  2. Copy the token value
  3. Set the environment variable TFE_ADMIN_PROVISION_LICENSES_TOKEN to be that token value.
  4. Run go test -run TestOrganizationsReadEntitlements -v ./..., with the other necessary testing environment variables.

External links

Output from tests

$ TFE_ADDRESS="..." TFE_TOKEN="..." TFE_ADMIN_PROVISION_LICENSES_TOKEN="..." go test ./ -v -run TestOrganizationsReadEntitlements

=== RUN   TestOrganizationsReadEntitlements
=== RUN   TestOrganizationsReadEntitlements/when_the_org_exists
=== RUN   TestOrganizationsReadEntitlements/with_invalid_name
=== RUN   TestOrganizationsReadEntitlements/when_the_org_does_not_exist
--- PASS: TestOrganizationsReadEntitlements (4.51s)
    --- PASS: TestOrganizationsReadEntitlements/when_the_org_exists (0.34s)
    --- PASS: TestOrganizationsReadEntitlements/with_invalid_name (0.00s)
    --- PASS: TestOrganizationsReadEntitlements/when_the_org_does_not_exist (0.30s)
PASS
ok  	github.com/hashicorp/go-tfe	5.408s

@ignatius-j ignatius-j requested a review from a team September 30, 2024 17:41
Copy link

hashicorp-cla-app bot commented Sep 30, 2024

CLA assistant check
All committers have signed the CLA.

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.

It looks like our CI instance does not support these entitlements; or we need an organization with the Plus feature set, which to my knowledge can't be upgraded via the feature set API. In the meantime could you put these assertions under a new subtest t.Run("with HCP entitlements", func(t *testing.T) {}) and subsequently skip the substep with a skipUnlessAfterDate() until we investigate this. If you can also paste the test results from your own local testing that would be great ❤️

@sebasslash
Copy link
Contributor

Let's also add a changelog entry, please 🙏

@ignatius-j ignatius-j force-pushed the ignatius-j/TF-20627_waypoint_entitlement branch from bc01550 to efb6dc2 Compare October 1, 2024 18:53
haydengomes
haydengomes previously approved these changes Oct 1, 2024
@@ -456,7 +456,9 @@ func TestOrganizationsReadEntitlements(t *testing.T) {
ctx := context.Background()

orgTest, orgTestCleanup := createOrganization(t, client)
t.Cleanup(orgTestCleanup)
defer orgTestCleanup()

Choose a reason for hiding this comment

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

For my understanding, are we trying to move from t.Cleanup(callback) to defer callback in general? I see examples of both in go-tfe

Copy link
Contributor

@sebasslash sebasslash Oct 1, 2024

Choose a reason for hiding this comment

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

Generally I prefer t.Cleanup() for tests since there are subsequent helpers that receive a testing.T object

Copy link
Collaborator

@brandonc brandonc Oct 1, 2024

Choose a reason for hiding this comment

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

t.Cleanup works better in two situations: using t.Run() (they clean up after the Test function finishes), and after panics

Copy link
Collaborator

Choose a reason for hiding this comment

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

(so we should just use it all the time)

@haydengomes haydengomes requested review from sebasslash and a team October 1, 2024 19:16
These changes add to the organizational entitlement struct to be able to
utilize the new Waypoint-based entitlements granted with HCP Terraform
feature sets:

- waypoint-actions
- waypoint-templates-and-addons
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.

The tests are passing:

PASS TestOrganizationsReadEntitlements/when_the_org_exists (0.09s)
PASS TestOrganizationsReadEntitlements/with_invalid_name (0.00s)
PASS TestOrganizationsReadEntitlements/when_the_org_does_not_exist (0.08s)

Comment on lines +75 to +86
func (b *organizationSubscriptionUpdater) WithPlusEntitlementPlan() *organizationSubscriptionUpdater {
b.planName = "Plus (entitlement)"

start := time.Now()
ceiling := 1
managedResourcesLimit := 1000

b.updateOpts.ContractStartAt = &start
b.updateOpts.RunsCeiling = &ceiling
b.updateOpts.ContractManagedResourcesLimit = &managedResourcesLimit
return b
}
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@ignatius-j ignatius-j merged commit e518ccd into main Oct 1, 2024
7 checks passed
@ignatius-j ignatius-j deleted the ignatius-j/TF-20627_waypoint_entitlement branch October 1, 2024 20:41
Copy link

github-actions bot commented Oct 1, 2024

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

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.

4 participants