-
Notifications
You must be signed in to change notification settings - Fork 769
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
Refactor out branches attribute to new data source #1117
Conversation
orgName := meta.(*Owner).name | ||
repoName := d.Get("repository").(string) | ||
|
||
branches, _, err := client.Repositories.ListBranches(context.TODO(), orgName, repoName, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, this data source will only display the first 30 branches of a repository, this is the default setting of the Github API endpoint
This mimics the previous behavior introduced in #892: https://github.com/kzhaotest/branches_test1 (see in this repo although there are 50+ branches, only 30+ are shown in the README (tf located here)).
We can introduce pagination in a future PR, but for now just replicate the previous behavior
Hi @kfcampbell, I'm curious if there's any thoughts on this/best ways to roll this out |
…ata_source_github_repository to data_source_github_repository_branches
@kfcampbell friendly bump |
@k24dizzle apologies for the slow response time. I'll shoot to get this into the next release! |
Co-authored-by: mareksapota-lyft <msapota@lyft.com>
…tions#1162) This will allow to retrieve only the protected branches instead of the first 30. Co-authored-by: Keegan Campbell <me@kfcampbell.com>
@kfcampbell Any update on getting this into a release? It looks like the 4.27.0 milestone was missed by the release. |
@kfcampbell it would be great to get this out ASAP if you can squeeze it in. Thanks. |
@k24dizzle Apologies for the delay. Integration tests on this aren't passing for me:
The error seems to be a result of this snippet:testing.go:654: Step 0 error: After applying this step, the plan was not empty:
Are the tests passing for you locally? |
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccGithubBranchesDataSource(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func TestAccGithubBranchesDataSource(t *testing.T) { | |
func TestAccGithubRepositoryBranchesDataSource(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty :)
@kfcampbell The
|
|
@kfcampbell went ahead and updated the branch with the upstream ^ the tests work for me locally as well:
If I'm interpreting the failure correctly, it seems like the provider thinks the repository resource needs to be updated.
This seems like the only field the plan wants to change in the repo resource. |
If dependabot is enabled on the organization by default tests will fail. Tests pass with this setting off: https://github.com/organizations/ORGNAME/settings/security_analysis |
…itory_branches Remove leftover code and doc after integrations#1117 Reintroduce the feature from integrations#1162 with integration tests
…itory_branches Remove leftover code and doc after integrations#1117 Reintroduce the feature from integrations#1162 with integration tests
…itory_branches Remove leftover code and doc after integrations#1117 Reintroduce the feature from integrations#1162 with integration tests
…itory_branches (#1296) * Allow to get only protected on non protected branch with github_repository_branches Remove leftover code and doc after #1117 Reintroduce the feature from #1162 with integration tests * Add ConflicsWith * Implement pagination Co-authored-by: Keegan Campbell <me@kfcampbell.com>
* Refactor out branches attribute from resource_github_repository and data_source_github_repository to data_source_github_repository_branches * Add link to docs * Update github/data_source_github_repository_branches.go Co-authored-by: mareksapota-lyft <msapota@lyft.com> * Add only_protected_branches in data source github_repository (integrations#1162) This will allow to retrieve only the protected branches instead of the first 30. Co-authored-by: Keegan Campbell <me@kfcampbell.com> * Remove mistakenly committed binary (integrations#1223) * Revert PR integrations#1162 (integrations#1224) * marek's suggestion + use v47 Co-authored-by: mareksapota-lyft <msapota@lyft.com> Co-authored-by: Bertrand Paquet <bertrand.paquet@gmail.com> Co-authored-by: Keegan Campbell <me@kfcampbell.com>
…itory_branches (integrations#1296) * Allow to get only protected on non protected branch with github_repository_branches Remove leftover code and doc after integrations#1117 Reintroduce the feature from integrations#1162 with integration tests * Add ConflicsWith * Implement pagination Co-authored-by: Keegan Campbell <me@kfcampbell.com>
…-github#1117) (#479) Co-authored-by: rorybryett <rory.bryett@dwp.gov.uk>
* Refactor out branches attribute from resource_github_repository and data_source_github_repository to data_source_github_repository_branches * Add link to docs * Update github/data_source_github_repository_branches.go Co-authored-by: mareksapota-lyft <msapota@lyft.com> * Add only_protected_branches in data source github_repository (integrations#1162) This will allow to retrieve only the protected branches instead of the first 30. Co-authored-by: Keegan Campbell <me@kfcampbell.com> * Remove mistakenly committed binary (integrations#1223) * Revert PR integrations#1162 (integrations#1224) * marek's suggestion + use v47 Co-authored-by: mareksapota-lyft <msapota@lyft.com> Co-authored-by: Bertrand Paquet <bertrand.paquet@gmail.com> Co-authored-by: Keegan Campbell <me@kfcampbell.com>
…itory_branches (integrations#1296) * Allow to get only protected on non protected branch with github_repository_branches Remove leftover code and doc after integrations#1117 Reintroduce the feature from integrations#1162 with integration tests * Add ConflicsWith * Implement pagination Co-authored-by: Keegan Campbell <me@kfcampbell.com>
resource_github_repository
anddata_source_github_repository
data_source_github_repository_branches
that returns branches instead.Rationale:
I believe branches shouldn't belong to the attributes of the
github_repository
resource/data source. These fields should be relevant to the repository itself, not other auxiliary resources (like teams, collaborators, branches, etc.)Similar to github_collaborators, github_repository_pull_requests, and other data sources, it would be better to create a new data source to contain this information instead.
If a developer wants to interact with the branches of a repo, they can use
data_source_github_repository_branches
instead. This helps prevent some of the problems described in the issues below.Testing done in this repo:
https://github.com/kzhaotest/branches
Fixes:
#1037
#1010
While still supporting the functionality of:
#748