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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Enhancements

* Add support for reading a no-code module's variables by @paladin-devops [#979](https://github.com/hashicorp/go-tfe/pull/979)
* Add Waypoint entitlements (the `waypoint-actions` and `waypoint-templates-and-addons` attributes) to `Entitlements` by @ignatius-j [#984](https://github.com/hashicorp/go-tfe/pull/984)

# v1.67.1

Expand Down
28 changes: 15 additions & 13 deletions organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,21 @@ type Capacity struct {

// Entitlements represents the entitlements of an organization.
type Entitlements struct {
ID string `jsonapi:"primary,entitlement-sets"`
Agents bool `jsonapi:"attr,agents"`
AuditLogging bool `jsonapi:"attr,audit-logging"`
CostEstimation bool `jsonapi:"attr,cost-estimation"`
GlobalRunTasks bool `jsonapi:"attr,global-run-tasks"`
Operations bool `jsonapi:"attr,operations"`
PrivateModuleRegistry bool `jsonapi:"attr,private-module-registry"`
RunTasks bool `jsonapi:"attr,run-tasks"`
SSO bool `jsonapi:"attr,sso"`
Sentinel bool `jsonapi:"attr,sentinel"`
StateStorage bool `jsonapi:"attr,state-storage"`
Teams bool `jsonapi:"attr,teams"`
VCSIntegrations bool `jsonapi:"attr,vcs-integrations"`
ID string `jsonapi:"primary,entitlement-sets"`
Agents bool `jsonapi:"attr,agents"`
AuditLogging bool `jsonapi:"attr,audit-logging"`
CostEstimation bool `jsonapi:"attr,cost-estimation"`
GlobalRunTasks bool `jsonapi:"attr,global-run-tasks"`
Operations bool `jsonapi:"attr,operations"`
PrivateModuleRegistry bool `jsonapi:"attr,private-module-registry"`
RunTasks bool `jsonapi:"attr,run-tasks"`
SSO bool `jsonapi:"attr,sso"`
Sentinel bool `jsonapi:"attr,sentinel"`
StateStorage bool `jsonapi:"attr,state-storage"`
Teams bool `jsonapi:"attr,teams"`
VCSIntegrations bool `jsonapi:"attr,vcs-integrations"`
WaypointActions bool `jsonapi:"attr,waypoint-actions"`
WaypointTemplatesAndAddons bool `jsonapi:"attr,waypoint-templates-and-addons"`
}

// RunQueue represents the current run queue of an organization.
Expand Down
4 changes: 4 additions & 0 deletions organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ func TestOrganizationsReadEntitlements(t *testing.T) {
orgTest, orgTestCleanup := createOrganization(t, client)
t.Cleanup(orgTestCleanup)

newSubscriptionUpdater(orgTest).WithPlusEntitlementPlan().Update(t)

t.Run("when the org exists", func(t *testing.T) {
entitlements, err := client.Organizations.ReadEntitlements(ctx, orgTest.Name)
require.NoError(t, err)
Expand All @@ -473,6 +475,8 @@ func TestOrganizationsReadEntitlements(t *testing.T) {
assert.True(t, entitlements.StateStorage)
assert.True(t, entitlements.Teams)
assert.True(t, entitlements.VCSIntegrations)
assert.True(t, entitlements.WaypointActions)
assert.True(t, entitlements.WaypointTemplatesAndAddons)
})

t.Run("with invalid name", func(t *testing.T) {
Expand Down
24 changes: 19 additions & 5 deletions subscription_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ type featureSetListOptions struct {
type retryableFn func() (interface{}, error)

type updateFeatureSetOptions struct {
Type string `jsonapi:"primary,subscription"`
RunsCeiling *int `jsonapi:"attr,runs-ceiling,omitempty"`
ContractStartAt *time.Time `jsonapi:"attr,contract-start-at,iso8601,omitempty"`
ContractUserLimit *int `jsonapi:"attr,contract-user-limit,omitempty"`
ContractApplyLimit *int `jsonapi:"attr,contract-apply-limit,omitempty"`
Type string `jsonapi:"primary,subscription"`
RunsCeiling *int `jsonapi:"attr,runs-ceiling,omitempty"`
ContractStartAt *time.Time `jsonapi:"attr,contract-start-at,iso8601,omitempty"`
ContractUserLimit *int `jsonapi:"attr,contract-user-limit,omitempty"`
ContractApplyLimit *int `jsonapi:"attr,contract-apply-limit,omitempty"`
ContractManagedResourcesLimit *int `jsonapi:"attr,contract-managed-resources-limit,omitempty"`

FeatureSet *featureSet `jsonapi:"relation,feature-set"`
}
Expand Down Expand Up @@ -71,6 +72,19 @@ func (b *organizationSubscriptionUpdater) WithTrialPlan() *organizationSubscript
return b
}

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
}
Comment on lines +75 to +86
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️


// Attempts to change an organization's subscription to a different plan. Requires a user token with admin access.
func (b *organizationSubscriptionUpdater) Update(t *testing.T) {
if enterpriseEnabled() {
Expand Down
Loading