Skip to content

Commit

Permalink
Add Diff Suppression Option To repository_collaborator (integration…
Browse files Browse the repository at this point in the history
…s#683)

* add diff suppression option to `repository_collaborator`

* fixup! remove comment

* remove hardcoded username from test
  • Loading branch information
Jeremy Udit authored Feb 5, 2021
1 parent 51bd499 commit be0b9a5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 381 deletions.
4 changes: 2 additions & 2 deletions examples/repository_collaborator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ This example will also create a repository in the specified `owner` organization
Alternatively, you may use variables passed via command line:

```console
export GITHUB_ORG=
export GITHUB_ORGANIZATION=
export GITHUB_TOKEN=
export COLLABORATOR_USERNAME=
export COLLABORATOR_PERMISSION=
```

```console
terraform apply \
-var "organization=${GITHUB_ORG}" \
-var "organization=${GITHUB_ORGANIZATION}" \
-var "github_token=${GITHUB_TOKEN}" \
-var "username=${COLLABORATOR_USERNAME}" \
-var "permission=${COLLABORATOR_PERMISSION}"
Expand Down
1 change: 0 additions & 1 deletion examples/repository_collaborator/providers.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
provider "github" {
version = "2.8.0"
organization = var.organization
token = var.github_token
}
18 changes: 18 additions & 0 deletions github/resource_github_repository_collaborator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func resourceGithubRepositoryCollaborator() *schema.Resource {
return &schema.Resource{
Create: resourceGithubRepositoryCollaboratorCreate,
Read: resourceGithubRepositoryCollaboratorRead,
Update: resourceGithubRepositoryCollaboratorUpdate,
Delete: resourceGithubRepositoryCollaboratorDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
Expand All @@ -39,6 +40,19 @@ func resourceGithubRepositoryCollaborator() *schema.Resource {
ForceNew: true,
Default: "push",
ValidateFunc: validateValueFunc([]string{"pull", "triage", "push", "maintain", "admin"}),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
if d.Get("permission_diff_suppression").(bool) {
if new == "triage" || new == "maintain" {
return true
}
}
return false
},
},
"permission_diff_suppression": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"invitation_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -158,6 +172,10 @@ func resourceGithubRepositoryCollaboratorRead(d *schema.ResourceData, meta inter
return nil
}

func resourceGithubRepositoryCollaboratorUpdate(d *schema.ResourceData, meta interface{}) error {
return resourceGithubRepositoryCollaboratorRead(d, meta)
}

func resourceGithubRepositoryCollaboratorDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Owner).v3client

Expand Down
Loading

0 comments on commit be0b9a5

Please sign in to comment.