Recreate team resource on change to list of members. This allows a user to be deleted along with team membership(s). #35
@ -13,46 +13,40 @@ description: |-
|
|||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
```terraform
|
```terraform
|
||||||
resource "gitea_org" "test_org" {
|
provider "gitea" {
|
||||||
name = "test-org"
|
base_url = var.gitea_url
|
||||||
|
# Token Auth can not be used with this resource
|
||||||
|
username = var.gitea_username
|
||||||
|
password = var.gitea_password
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "gitea_user" "test" {
|
resource "gitea_org" "example_org" {
|
||||||
username = "test"
|
name = "example_org"
|
||||||
login_name = "test"
|
}
|
||||||
|
|
||||||
|
resource "gitea_repository" "example_repos" {
|
||||||
|
count = 4
|
||||||
|
name = "example_repo_${count.index}"
|
||||||
|
# The repo will belong to this organisation.
|
||||||
|
username = gitea_org.example_org.name
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "gitea_user" "example_users" {
|
||||||
|
count = 5
|
||||||
|
username = "example_user_${count.index}"
|
||||||
|
login_name = "example_user__${count.index}"
|
||||||
password = "Geheim1!"
|
password = "Geheim1!"
|
||||||
email = "test@user.dev"
|
email = "example_user_${count.index}@user.dev"
|
||||||
must_change_password = false
|
|
||||||
admin = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "gitea_team" "example_team" {
|
||||||
resource "gitea_team" "test_team" {
|
name = "example_team"
|
||||||
name = "Devs"
|
organisation = gitea_org.example_org.name
|
||||||
organisation = gitea_org.test_org.name
|
description = "An example team with mebers and access to specific repositories."
|
||||||
description = "Devs of Test Org"
|
|
||||||
permission = "write"
|
permission = "write"
|
||||||
members = [gitea_user.test.username]
|
members = [for user in gitea_user.example_users : user.username]
|
||||||
}
|
repositories = [for repo in gitea_repository.example_repos : repo.name]
|
||||||
|
|
||||||
|
|
||||||
resource "gitea_repository" "test" {
|
|
||||||
username = gitea_org.test_org.name
|
|
||||||
name = "test"
|
|
||||||
private = true
|
|
||||||
issue_labels = "Default"
|
|
||||||
license = "MIT"
|
|
||||||
gitignores = "Go"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "gitea_team" "test_team_restricted" {
|
|
||||||
name = "Restricted Devs"
|
|
||||||
organisation = gitea_org.test_org.name
|
|
||||||
description = "Restricted Devs of Test Org"
|
|
||||||
permission = "write"
|
|
||||||
members = [gitea_user.test.username]
|
|
||||||
include_all_repositories = false
|
|
||||||
repositories = [gitea_repository.test.name]
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -69,7 +63,7 @@ resource "gitea_team" "test_team_restricted" {
|
|||||||
- `can_create_repos` (Boolean) Flag if the Teams members should be able to create Rpositories in the Organisation
|
- `can_create_repos` (Boolean) Flag if the Teams members should be able to create Rpositories in the Organisation
|
||||||
- `description` (String) Description of the Team
|
- `description` (String) Description of the Team
|
||||||
- `include_all_repositories` (Boolean) Flag if the Teams members should have access to all Repositories in the Organisation
|
- `include_all_repositories` (Boolean) Flag if the Teams members should have access to all Repositories in the Organisation
|
||||||
- `members` (List of String) List of Users that should be part of this team
|
- `members` (List of String) Usernames of members of the team. The team resource will be recreated when this list changes.
|
||||||
- `permission` (String) Permissions associated with this Team
|
- `permission` (String) Permissions associated with this Team
|
||||||
Can be `none`, `read`, `write`, `admin` or `owner`
|
Can be `none`, `read`, `write`, `admin` or `owner`
|
||||||
- `repositories` (List of String) List of Repositories that should be part of this team
|
- `repositories` (List of String) List of Repositories that should be part of this team
|
||||||
|
@ -312,7 +312,8 @@ func resourceGiteaTeam() *schema.Resource {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Required: false,
|
Required: false,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Description: "List of Users that should be part of this team",
|
ForceNew: true,
|
||||||
|
Description: "Usernames of members of the team. The team resource will be recreated when this list changes.",
|
||||||
},
|
},
|
||||||
"repositories": {
|
"repositories": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
|
Loading…
Reference in New Issue
Block a user