-
Notifications
You must be signed in to change notification settings - Fork 741
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
Update data source for repository file: prevent tf panic on non-existent file and make the branch default consistent with GitHub API #1129
Conversation
This would solve a lot of issues! |
@galargh do you have any interest in resolving this merge conflicts? I can do a pass at it if you'd prefer as well. |
Sure, no problem. All conflicts should be resolved now. |
Hmm, tests for
Can you reproduce this? |
I've just realised I was only running I now fixed I also ran |
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.
@galargh thank you so much for contributing and following up! I'll get this merged and released shortly.
…ent file and make the branch default consistent with GitHub API (integrations#1129) * Update data source for repository file. * Create randomID variable for use in tests * fix: TestDataSourceGithubRepositoryFileRead --------- Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Resolves #1132
Resolves #1131
Description
This PR updates the data source for repository files.
It prevents terraform from panicking when trying to retrieve info about a non-existent file. With this change, in such a case, an empty data source will get returned - similarly to how
ref
data source behaves.It also changes the default value for
branch
argument frommain
to the name of the default branch of the requested repository. The new behaviour is how GitHub API itself behaves.I also added a new attribute
ref
which, after apply, holds the name of the branch the file is associated with. In practice, if a branch was explicitly provided, thenref
=branch
. Otherwise,ref
= the name of the default branch of the requested repository.Finally, it simplified the commit info retrieval. It was possible because I noticed that
commit_sha
is never set on the data source - I suspect it was copied over from the resource and just left in place.I updated the markdown entry which describes how to configure the resource.
Testing
TF_ACC=1 go test -v ./... -run ^TestAccGithubRepositoryFileDataSource