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 organization team permission resource and data source #8

Merged
merged 11 commits into from
Aug 28, 2024
120 changes: 119 additions & 1 deletion code_generator/provider_code_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"name": "role",
"string": {
"computed_optional_required": "required",
"description": "Team permission. Should be admin, creator, or member.",
"description": "Team role. Should be admin, creator, or member.",
"validators": [
{
"custom": {
Expand All @@ -182,6 +182,89 @@
]
}
},
{
"name": "organization_team_permission",
"schema": {
"attributes": [
{
"name": "orgname",
"string": {
"computed_optional_required": "required",
"description": "Organization name",
"plan_modifiers": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
}
],
"schema_definition": "stringplanmodifier.RequiresReplace()"
}
}
]
}
},
{
"name": "reponame",
"string": {
"computed_optional_required": "required",
"description": "Repository name",
"plan_modifiers": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
}
],
"schema_definition": "stringplanmodifier.RequiresReplace()"
}
}
]
}
},
{
"name": "teamname",
"string": {
"computed_optional_required": "required",
"description": "Team name",
"plan_modifiers": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
}
],
"schema_definition": "stringplanmodifier.RequiresReplace()"
}
}
]
}
},
{
"name": "permission",
"string": {
"computed_optional_required": "required",
"description": "Team permission. Should be read, write or admin.",
"validators": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
}
],
"schema_definition": "stringvalidator.OneOf([]string{\"read\", \"write\", \"admin\"}...)"
}
}
]
}
}
]
}
},
{
"name": "repository",
"schema": {
Expand Down Expand Up @@ -282,6 +365,41 @@
]
}
},
{
"name": "organization_team_permission",
"schema": {
"attributes": [
{
"name": "orgname",
"string": {
"computed_optional_required": "required",
"description": "Organization name"
}
},
{
"name": "reponame",
"string": {
"computed_optional_required": "required",
"description": "Repository name"
}
},
{
"name": "teamname",
"string": {
"computed_optional_required": "required",
"description": "Team name"
}
},
{
"name": "permission",
"string": {
"computed_optional_required": "computed",
"description": "Team permission"
}
}
]
}
},
{
"name": "repository",
"schema": {
Expand Down
50 changes: 50 additions & 0 deletions docs/data-sources/organization_team_permission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "quay_organization_team_permission Data Source - quay"
subcategory: ""
description: |-

---

# quay_organization_team_permission (Data Source)



## Example Usage

```terraform
resource "quay_organization" "org" {
name = "org"
email = "[email protected]"
}

resource "quay_repository" "repo" {
name = "repo"
namespace = quay_organization.org.name
}

resource "quay_organization_team" "team" {
name = "team"
orgname = quay_organization.org.name
role = "member"
}

data "quay_organization_team_permission" "permission" {
orgname = quay_organization.org.name
reponame = quay_repository.repo.name
teamname = quay_organization_team.team.name
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `orgname` (String) Organization name
- `reponame` (String) Repository name
- `teamname` (String) Team name

### Read-Only

- `permission` (String) Team permission
2 changes: 1 addition & 1 deletion docs/resources/organization_team.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ resource "quay_organization_team" "admin" {

- `name` (String) Team name
- `orgname` (String) Organization name
- `role` (String) Team permission. Should be admin, creator, or member.
- `role` (String) Team role. Should be admin, creator, or member.

### Optional

Expand Down
57 changes: 57 additions & 0 deletions docs/resources/organization_team_permission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "quay_organization_team_permission Resource - quay"
subcategory: ""
description: |-
---

# quay_organization_team_permission (Resource)



## Example Usage

```terraform
resource "quay_organization" "org" {
name = "org"
email = "[email protected]"
}
resource "quay_repository" "repo" {
name = "repo"
namespace = quay_organization.org.name
}
resource "quay_organization_team" "team" {
name = "team"
orgname = quay_organization.org.name
role = "member"
}
resource "quay_organization_team_permission" "permission" {
orgname = quay_organization.org.name
reponame = quay_repository.repo.name
teamname = quay_organization_team.team.name
permission = "read"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `orgname` (String) Organization name
- `permission` (String) Team permission. Should be read, write or admin.
- `reponame` (String) Repository name
- `teamname` (String) Team name

## Import

Import is supported using the following syntax:

```shell
# An organization team permission can be imported using the corresponding organization, repository and team name.
terraform import quay_organization_team_permission.permission org repo team
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "quay_organization" "org" {
name = "org"
email = "[email protected]"
}

resource "quay_repository" "repo" {
name = "repo"
namespace = quay_organization.org.name
}

resource "quay_organization_team" "team" {
name = "team"
orgname = quay_organization.org.name
role = "member"
}

data "quay_organization_team_permission" "permission" {
orgname = quay_organization.org.name
reponame = quay_repository.repo.name
teamname = quay_organization_team.team.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# An organization team permission can be imported using the corresponding organization, repository and team name.
terraform import quay_organization_team_permission.permission org repo team
22 changes: 22 additions & 0 deletions examples/resources/quay_organization_team_permission/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "quay_organization" "org" {
name = "org"
email = "[email protected]"
}

resource "quay_repository" "repo" {
name = "repo"
namespace = quay_organization.org.name
}

resource "quay_organization_team" "team" {
name = "team"
orgname = quay_organization.org.name
role = "member"
}

resource "quay_organization_team_permission" "permission" {
orgname = quay_organization.org.name
reponame = quay_repository.repo.name
teamname = quay_organization_team.team.name
permission = "read"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading