diff --git a/CHANGELOG.md b/CHANGELOG.md index e8081936e..e337ad59d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/organization.go b/organization.go index 78813a387..fb4d397a4 100644 --- a/organization.go +++ b/organization.go @@ -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. diff --git a/organization_integration_test.go b/organization_integration_test.go index 0c57f4c90..5649278e1 100644 --- a/organization_integration_test.go +++ b/organization_integration_test.go @@ -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) @@ -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) { diff --git a/subscription_updater_test.go b/subscription_updater_test.go index 6fae179a2..25554fc1f 100644 --- a/subscription_updater_test.go +++ b/subscription_updater_test.go @@ -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"` } @@ -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 +} + // 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() {