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

Add Admin General Settings attr default-remote-state-access #205

Merged
merged 2 commits into from
Apr 19, 2021
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
2 changes: 2 additions & 0 deletions admin_setting_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type AdminGeneralSetting struct {
DefaultWorkspacesPerOrgCeiling int `jsonapi:"attr,default-workspaces-per-organization-ceiling"`
TerraformBuildWorkerApplyTimeout string `jsonapi:"attr,terraform-build-worker-apply-timeout"`
TerraformBuildWorkerPlanTimeout string `jsonapi:"attr,terraform-build-worker-plan-timeout"`
DefaultRemoteStateAccess bool `jsonapi:"attr,default-remote-state-access"`
}

// Read returns the general settings.
Expand Down Expand Up @@ -63,6 +64,7 @@ type AdminGeneralSettingsUpdateOptions struct {
APIRateLimit *int `jsonapi:"attr,api-rate-limit,omitempty"`
SendPassingStatusUntriggeredPlans *bool `jsonapi:"attr,send-passing-statuses-for-untriggered-speculative-plans,omitempty"`
AllowSpeculativePlansOnPR *bool `jsonapi:"attr,allow-speculative-plans-on-pull-requests-from-forks,omitempty"`
DefaultRemoteStateAccess *bool `jsonapi:"attr,default-remote-state-access,omitempty"`
}

// Update updates the general settings.
Expand Down
19 changes: 13 additions & 6 deletions admin_setting_general_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAdminSettings_General_Read(t *testing.T) {
assert.NotNil(t, generalSettings.DefaultWorkspacesPerOrgCeiling)
assert.NotNil(t, generalSettings.TerraformBuildWorkerApplyTimeout)
assert.NotNil(t, generalSettings.TerraformBuildWorkerPlanTimeout)
assert.NotNil(t, generalSettings.DefaultRemoteStateAccess)
}

func TestAdminSettings_General_Update(t *testing.T) {
Expand All @@ -45,29 +46,35 @@ func TestAdminSettings_General_Update(t *testing.T) {
origLimitOrgCreation := generalSettings.LimitUserOrganizationCreation
origAPIRateLimitEnabled := generalSettings.APIRateLimitingEnabled
origAPIRateLimit := generalSettings.APIRateLimit
origDefaultRemoteState := generalSettings.DefaultRemoteStateAccess

limitOrgCreation := true
apiRateLimitEnabled := true
apiRateLimit := 50
defaultRemoteStateAccess := false

generalSettings, err = client.Admin.Settings.General.Update(ctx, AdminGeneralSettingsUpdateOptions{
LimitUserOrgCreation: Bool(limitOrgCreation),
APIRateLimitingEnabled: Bool(apiRateLimitEnabled),
APIRateLimit: Int(apiRateLimit),
LimitUserOrgCreation: Bool(limitOrgCreation),
APIRateLimitingEnabled: Bool(apiRateLimitEnabled),
APIRateLimit: Int(apiRateLimit),
DefaultRemoteStateAccess: Bool(defaultRemoteStateAccess),
})
require.NoError(t, err)
assert.Equal(t, limitOrgCreation, generalSettings.LimitUserOrganizationCreation)
assert.Equal(t, apiRateLimitEnabled, generalSettings.APIRateLimitingEnabled)
assert.Equal(t, apiRateLimit, generalSettings.APIRateLimit)
assert.Equal(t, defaultRemoteStateAccess, generalSettings.DefaultRemoteStateAccess)

// Undo Updates, revert back to original
generalSettings, err = client.Admin.Settings.General.Update(ctx, AdminGeneralSettingsUpdateOptions{
LimitUserOrgCreation: Bool(origLimitOrgCreation),
APIRateLimitingEnabled: Bool(origAPIRateLimitEnabled),
APIRateLimit: Int(origAPIRateLimit),
LimitUserOrgCreation: Bool(origLimitOrgCreation),
APIRateLimitingEnabled: Bool(origAPIRateLimitEnabled),
APIRateLimit: Int(origAPIRateLimit),
DefaultRemoteStateAccess: Bool(origDefaultRemoteState),
})
require.NoError(t, err)
assert.Equal(t, origLimitOrgCreation, generalSettings.LimitUserOrganizationCreation)
assert.Equal(t, origAPIRateLimitEnabled, generalSettings.APIRateLimitingEnabled)
assert.Equal(t, origAPIRateLimit, generalSettings.APIRateLimit)
assert.Equal(t, origDefaultRemoteState, generalSettings.DefaultRemoteStateAccess)
}