Skip to content

Commit

Permalink
chore: add manage-agent-pools to team organization access
Browse files Browse the repository at this point in the history
  • Loading branch information
emlanctot committed May 14, 2024
1 parent 9b21183 commit a55118c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/provider/resource_tfe_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func resourceTFETeam() *schema.Resource {
Optional: true,
Default: false,
},
"manage_agent_pools": {
Type: schema.TypeBool,
Optional: true,
Default: false,
}

Check failure on line 127 in internal/provider/resource_tfe_team.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in composite literal

Check failure on line 127 in internal/provider/resource_tfe_team.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: unexpected newline in composite literal; possibly missing comma or }
},
},
},
Expand Down Expand Up @@ -173,6 +178,7 @@ func resourceTFETeamCreate(d *schema.ResourceData, meta interface{}) error {
ManageTeams: tfe.Bool(organizationAccess["manage_teams"].(bool)),
ManageOrganizationAccess: tfe.Bool(organizationAccess["manage_organization_access"].(bool)),
AccessSecretTeams: tfe.Bool(organizationAccess["access_secret_teams"].(bool)),
ManageAgentPools: tfe.Bool(organizationAccess["manage_agent_pools"].(bool)),
}
}

Expand Down Expand Up @@ -236,6 +242,7 @@ func resourceTFETeamRead(d *schema.ResourceData, meta interface{}) error {
"manage_teams": team.OrganizationAccess.ManageTeams,
"manage_organization_access": team.OrganizationAccess.ManageOrganizationAccess,
"access_secret_teams": team.OrganizationAccess.AccessSecretTeams,
"manage_agent_pools": team.OrganizationAccess.ManageAgentPools,
}}
if err := d.Set("organization_access", organizationAccess); err != nil {
return fmt.Errorf("error setting organization access for team %s: %w", d.Id(), err)
Expand Down Expand Up @@ -276,6 +283,7 @@ func resourceTFETeamUpdate(d *schema.ResourceData, meta interface{}) error {
ManageTeams: tfe.Bool(organizationAccess["manage_teams"].(bool)),
ManageOrganizationAccess: tfe.Bool(organizationAccess["manage_organization_access"].(bool)),
AccessSecretTeams: tfe.Bool(organizationAccess["access_secret_teams"].(bool)),
ManageAgentPools: tfe.Bool(organizationAccess["manage_agent_pools"].(bool)),
}
}

Expand Down
16 changes: 16 additions & 0 deletions internal/provider/resource_tfe_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func TestAccTFETeam_full(t *testing.T) {
"tfe_team.foobar", "organization_access.0.manage_organization_access", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.access_secret_teams", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_agent_pools", "true"),
),
},
},
Expand Down Expand Up @@ -138,6 +140,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
"tfe_team.foobar", "organization_access.0.manage_organization_access", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.access_secret_teams", "true"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_agent_pools", "true"),
),
},
{
Expand Down Expand Up @@ -178,6 +182,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
"tfe_team.foobar", "organization_access.0.manage_organization_access", "false"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.access_secret_teams", "false"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_agent_pools", "false"),
),
},
{
Expand Down Expand Up @@ -219,6 +225,8 @@ func TestAccTFETeam_full_update(t *testing.T) {
"tfe_team.foobar", "organization_access.0.manage_organization_access", "false"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.access_secret_teams", "false"),
resource.TestCheckResourceAttr(
"tfe_team.foobar", "organization_access.0.manage_agent_pools", "false"),
),
},
},
Expand Down Expand Up @@ -480,6 +488,9 @@ func testAccCheckTFETeamAttributes_full(
if !team.OrganizationAccess.AccessSecretTeams {
return fmt.Errorf("OrganizationAccess.AccessSecretTeams should be true")
}
if !team.OrganizationAccess.ManageAgentPools {
return fmt.Errorf("OrganizationAccess.ManageAgentPools should be true")
}

if team.SSOTeamID != "team-test-sso-id" {
return fmt.Errorf("Bad SSO Team ID: %s", team.SSOTeamID)
Expand Down Expand Up @@ -527,6 +538,9 @@ func testAccCheckTFETeamAttributes_full_update(
if team.OrganizationAccess.AccessSecretTeams {
return fmt.Errorf("OrganizationAccess.AccessSecretTeams should be false")
}
if team.OrganizationAccess.ManageAgentPools {
return fmt.Errorf("OrganizationAccess.ManageAgentPools should be false")
}

if team.SSOTeamID != "changed-sso-id" {
return fmt.Errorf("Bad SSO Team ID: %s", team.SSOTeamID)
Expand Down Expand Up @@ -598,6 +612,7 @@ resource "tfe_team" "foobar" {
manage_teams = true
manage_organization_access = true
access_secret_teams = true
manage_agent_pools = true
}
sso_team_id = "team-test-sso-id"
}`, rInt)
Expand Down Expand Up @@ -631,6 +646,7 @@ resource "tfe_team" "foobar" {
manage_teams = false
manage_organization_access = false
access_secret_teams = false
manage_agent_pools = false
}
sso_team_id = "changed-sso-id"
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/team.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The `organization_access` block supports:
* `manage_teams` - (Optional) Allow members to create, update, and delete teams.
* `manage_organization_access` - (Optional) Allow members to update the organization access settings of teams.
* `access_secret_teams` - (Optional) Allow members access to secret teams up to the level of permissions granted by their team permissions setting.
* `manage_secret_teams` - (Optional) Allows members to create, edit, and delete agent pools within their organization.

## Attributes Reference

Expand Down

0 comments on commit a55118c

Please sign in to comment.