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 Manage Policy Overrides permission #285

Merged
merged 2 commits into from
Apr 21, 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
26 changes: 17 additions & 9 deletions tfe/resource_tfe_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func resourceTFETeam() *schema.Resource {
Optional: true,
Default: false,
},
"manage_policy_overrides": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"manage_workspaces": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -86,9 +91,10 @@ func resourceTFETeamCreate(d *schema.ResourceData, meta interface{}) error {
organizationAccess := v.([]interface{})[0].(map[string]interface{})

options.OrganizationAccess = &tfe.OrganizationAccessOptions{
ManagePolicies: tfe.Bool(organizationAccess["manage_policies"].(bool)),
ManageWorkspaces: tfe.Bool(organizationAccess["manage_workspaces"].(bool)),
ManageVCSSettings: tfe.Bool(organizationAccess["manage_vcs_settings"].(bool)),
ManagePolicies: tfe.Bool(organizationAccess["manage_policies"].(bool)),
ManagePolicyOverrides: tfe.Bool(organizationAccess["manage_policy_overrides"].(bool)),
ManageWorkspaces: tfe.Bool(organizationAccess["manage_workspaces"].(bool)),
ManageVCSSettings: tfe.Bool(organizationAccess["manage_vcs_settings"].(bool)),
}
}

Expand Down Expand Up @@ -126,9 +132,10 @@ func resourceTFETeamRead(d *schema.ResourceData, meta interface{}) error {
d.Set("name", team.Name)
if team.OrganizationAccess != nil {
organizationAccess := []map[string]bool{{
"manage_policies": team.OrganizationAccess.ManagePolicies,
"manage_workspaces": team.OrganizationAccess.ManageWorkspaces,
"manage_vcs_settings": team.OrganizationAccess.ManageVCSSettings,
"manage_policies": team.OrganizationAccess.ManagePolicies,
"manage_policy_overrides": team.OrganizationAccess.ManagePolicyOverrides,
"manage_workspaces": team.OrganizationAccess.ManageWorkspaces,
"manage_vcs_settings": team.OrganizationAccess.ManageVCSSettings,
}}
if err := d.Set("organization_access", organizationAccess); err != nil {
return fmt.Errorf("error setting organization access for team %s: %s", d.Id(), err)
Expand All @@ -154,9 +161,10 @@ func resourceTFETeamUpdate(d *schema.ResourceData, meta interface{}) error {
organizationAccess := v.([]interface{})[0].(map[string]interface{})

options.OrganizationAccess = &tfe.OrganizationAccessOptions{
ManagePolicies: tfe.Bool(organizationAccess["manage_policies"].(bool)),
ManageWorkspaces: tfe.Bool(organizationAccess["manage_workspaces"].(bool)),
ManageVCSSettings: tfe.Bool(organizationAccess["manage_vcs_settings"].(bool)),
ManagePolicies: tfe.Bool(organizationAccess["manage_policies"].(bool)),
ManagePolicyOverrides: tfe.Bool(organizationAccess["manage_policy_overrides"].(bool)),
ManageWorkspaces: tfe.Bool(organizationAccess["manage_workspaces"].(bool)),
ManageVCSSettings: tfe.Bool(organizationAccess["manage_vcs_settings"].(bool)),
}
}

Expand Down
8 changes: 8 additions & 0 deletions tfe/resource_tfe_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func TestAccTFETeam_full(t *testing.T) {
"tfe_team.foobar", "visibility", "organization"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_policies", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_policy_overrides", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_workspaces", "true"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -86,6 +88,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
"tfe_team.foobar", "visibility", "organization"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_policies", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_policy_overrides", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_workspaces", "true"),
resource.TestCheckResourceAttr(
Expand All @@ -104,6 +108,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
"tfe_team.foobar", "visibility", "secret"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_policies", "false"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_policy_overrides", "false"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_workspaces", "false"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -274,6 +280,7 @@ resource "tfe_team" "foobar" {

organization_access {
manage_policies = true
manage_policy_overrides = true
manage_workspaces = true
manage_vcs_settings = true
}
Expand All @@ -295,6 +302,7 @@ resource "tfe_team" "foobar" {

organization_access {
manage_policies = false
manage_policy_overrides = false
manage_workspaces = false
manage_vcs_settings = false
}
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/team.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ The following arguments are supported:

The `organization_access` block supports:

* `manage_policies` - (Optional) Allows members to create, edit, and delete the organization's Sentinel policies and override soft-mandatory policy checks.
* `manage_policies` - (Optional) Allows members to create, edit, and delete the organization's Sentinel policies.
* `manage_policy_overrides` - (Optional) Allows members to override soft-mandatory policy checks.
* `manage_workspaces` - (Optional) Allows members to create and administrate all workspaces within the organization.
* `manage_vcs_settings` - (Optional) Allows members to manage the organization's VCS Providers and SSH keys.

Expand Down