Skip to content

Commit 21f85f9

Browse files
author
Jeremy Udit
authored
Add Diff Suppression Option To repository_collaborator (#683)
* add diff suppression option to `repository_collaborator` * fixup! remove comment * remove hardcoded username from test
1 parent ddfb742 commit 21f85f9

File tree

5 files changed

+67
-381
lines changed

5 files changed

+67
-381
lines changed

examples/repository_collaborator/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ This example will also create a repository in the specified `owner` organization
77
Alternatively, you may use variables passed via command line:
88

99
```console
10-
export GITHUB_ORG=
10+
export GITHUB_ORGANIZATION=
1111
export GITHUB_TOKEN=
1212
export COLLABORATOR_USERNAME=
1313
export COLLABORATOR_PERMISSION=
1414
```
1515

1616
```console
1717
terraform apply \
18-
-var "organization=${GITHUB_ORG}" \
18+
-var "organization=${GITHUB_ORGANIZATION}" \
1919
-var "github_token=${GITHUB_TOKEN}" \
2020
-var "username=${COLLABORATOR_USERNAME}" \
2121
-var "permission=${COLLABORATOR_PERMISSION}"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
provider "github" {
2-
version = "2.8.0"
32
organization = var.organization
43
token = var.github_token
54
}

github/resource_github_repository_collaborator.go

+18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func resourceGithubRepositoryCollaborator() *schema.Resource {
1515
return &schema.Resource{
1616
Create: resourceGithubRepositoryCollaboratorCreate,
1717
Read: resourceGithubRepositoryCollaboratorRead,
18+
Update: resourceGithubRepositoryCollaboratorUpdate,
1819
Delete: resourceGithubRepositoryCollaboratorDelete,
1920
Importer: &schema.ResourceImporter{
2021
State: schema.ImportStatePassthrough,
@@ -39,6 +40,19 @@ func resourceGithubRepositoryCollaborator() *schema.Resource {
3940
ForceNew: true,
4041
Default: "push",
4142
ValidateFunc: validateValueFunc([]string{"pull", "triage", "push", "maintain", "admin"}),
43+
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
44+
if d.Get("permission_diff_suppression").(bool) {
45+
if new == "triage" || new == "maintain" {
46+
return true
47+
}
48+
}
49+
return false
50+
},
51+
},
52+
"permission_diff_suppression": {
53+
Type: schema.TypeBool,
54+
Optional: true,
55+
Default: false,
4256
},
4357
"invitation_id": {
4458
Type: schema.TypeString,
@@ -158,6 +172,10 @@ func resourceGithubRepositoryCollaboratorRead(d *schema.ResourceData, meta inter
158172
return nil
159173
}
160174

175+
func resourceGithubRepositoryCollaboratorUpdate(d *schema.ResourceData, meta interface{}) error {
176+
return resourceGithubRepositoryCollaboratorRead(d, meta)
177+
}
178+
161179
func resourceGithubRepositoryCollaboratorDelete(d *schema.ResourceData, meta interface{}) error {
162180
client := meta.(*Owner).v3client
163181

0 commit comments

Comments
 (0)