Recreate team resource on change to list of members. This allows a user to be deleted along with team membership(s). #35

Closed
tobiasbp wants to merge 2 commits from tobiasbp/terraform-provider-gitea:recreate-team-on-membership-change into main
2 changed files with 31 additions and 36 deletions

View File

@ -13,46 +13,40 @@ description: |-
## Example Usage
```terraform
resource "gitea_org" "test_org" {
name = "test-org"
provider "gitea" {
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" {
username = "test"
login_name = "test"
password = "Geheim1!"
email = "test@user.dev"
must_change_password = false
admin = true
resource "gitea_org" "example_org" {
name = "example_org"
}
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_team" "test_team" {
name = "Devs"
organisation = gitea_org.test_org.name
description = "Devs of Test Org"
}
resource "gitea_user" "example_users" {
count = 5
username = "example_user_${count.index}"
login_name = "example_user__${count.index}"
password = "Geheim1!"
email = "example_user_${count.index}@user.dev"
}
resource "gitea_team" "example_team" {
name = "example_team"
organisation = gitea_org.example_org.name
description = "An example team with mebers and access to specific repositories."
permission = "write"
members = [gitea_user.test.username]
}
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]
members = [for user in gitea_user.example_users : user.username]
repositories = [for repo in gitea_repository.example_repos : repo.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
- `description` (String) Description of the Team
- `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
Can be `none`, `read`, `write`, `admin` or `owner`
- `repositories` (List of String) List of Repositories that should be part of this team

View File

@ -312,7 +312,8 @@ func resourceGiteaTeam() *schema.Resource {
Optional: true,
Required: false,
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": {
Type: schema.TypeList,