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

feat(github_team_repository): allow for custom repository roles #1113

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion github/resource_github_team_repository.go
Expand Up @@ -36,7 +36,6 @@ func resourceGithubTeamRepository() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Default: "pull",
ValidateFunc: validateValueFunc([]string{"pull", "triage", "push", "maintain", "admin"}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to pull all possible roles from GitHub and then validate against that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure we could use this API for that.

Do you know of an example where something similar is done before? Or could you suggest where I should create the function. First time contributor :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we do some other validation in utils.go (e.g. validateValueFunc and validateTeamIDFunc) but I don't see anyone calling back to github api here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably need to wait for this: google/go-github#2336? But I am also a little out of my depth here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The go-github functionality for merged a little while ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's merged but unfortunately has not been released yet; the last release of the library was March 1st. We'll have to wait for their next official release to use the functionality in go-github#2336.

@joshuahancox is correct and thus far we've chosen to hard-code those validation functions rather than use extra API calls. I'm a little hesitant to change that approach here, especially as we tend to see API overuse on more intensive Terraform runs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1138 will bump go-github to include the necessary functionality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just updated and merged #1138!

},
"etag": {
Type: schema.TypeString,
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/team_repository.html.markdown
Expand Up @@ -44,7 +44,7 @@ The following arguments are supported:
* `team_id` - (Required) The GitHub team id or the GitHub team slug
* `repository` - (Required) The repository to add to the team.
* `permission` - (Optional) The permissions of team members regarding the repository.
Must be one of `pull`, `triage`, `push`, `maintain`, or `admin`. Defaults to `pull`.
Must be one of `pull`, `triage`, `push`, `maintain`, `admin` or the name of an existing [custom repository role](https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization) within the organisation. Defaults to `pull`.


## Import
Expand Down