Skip to content

Commit

Permalink
Merge pull request #984 from hashicorp/ignatius-j/TF-20627_waypoint_e…
Browse files Browse the repository at this point in the history
…ntitlement

TF-20627: Add Waypoint entitlements for organizations
  • Loading branch information
ignatius-j authored Oct 1, 2024
2 parents f3328da + 1593b8e commit e518ccd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
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
}

// 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

0 comments on commit e518ccd

Please sign in to comment.