-
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
feat: Add a data source for custom GET requests to REST API. #1119
Conversation
I like the idea! What are your thoughts on allowing query parameters and request bodies as well? |
Oh, sorry, I missed that comment before. Thank you so much for all the reviews and merges ❤️ I thought that for a data source, all we want to do is GET requests, so I don't think "body" would be that useful. At least, I'm not aware of any GitHub API GET endpoints that make use of it. As for query params, in this iteration, they can be provided inline as part of the endpoint string. Making them a separate input could be nice though. Pagination support could be another useful extension here. |
No worries! Agreed about query params as a separate input and pagination support. Should you feel motivated to open a PR to add them, I would gladly review it. Otherwise, I'm planning on cutting a new version of the provider later today that will ship with this feature. |
…1119) Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Description
I wanted to use https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/repository_file to check if a specific file exists or not. I realised it was not possible because
terraform apply
would fail if a file does not exist because the underlying API call receives 404.That's how I got an idea to introduce a general purpose API call data source which issues a GET request to a GitHub API endpoint and returns a response.
Example
Testing
TF_ACC=1 go test -v ./... -run ^TestAccGithubRestApiDataSource
go install
), added it to my project and successfully used the newly added data source