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
Added WebhookURL to VCSRepo struct #413
Conversation
…k VCSRepo assert to multiple attribute asserts
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.
Code overall looks great 👍 🔥 , some minor things to change down below. ⬇️
policy_set_integration_test.go
Outdated
assert.Equal(t, ps.VCSRepo.OAuthTokenID, oc.ID) | ||
assert.Equal(t, ps.VCSRepo.RepositoryHTTPURL, fmt.Sprintf("https://github.com/%s", githubIdentifier)) | ||
assert.Equal(t, ps.VCSRepo.ServiceProvider, string(ServiceProviderGithub)) | ||
assert.Regexp(t, "^https://app\\.terraform\\.io/webhooks/vcs/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$", ps.VCSRepo.WebhookURL) |
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.
The only thing I might change here is the host, given that someone can test against a Terraform Enterprise installation where the host might not necessarily match with app...terraform...io
. The best choice here would be to stick the value of TFE_ADDRESS
into the regexp.
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.
Yeah I see the problem. Is the rest of the URL for the webhook standard or can the endpoint and/or the UUID part also change on TFE?
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.
I couldn't find a way to easily access the Config object used to create the test client, so I called DefaultConfig() myself for its Address field. DefaultConfig() function handles all cases with TFE_ADDRESS
and TFE_HOSTNAME
env variables (or lack thereof) so I thought it would be best to use it instead of just TFE_ADDRESS
. If there is a better/cleaner way, feel free to point me in the right direction
policy_set_integration_test.go
Outdated
assert.Equal(t, ps.VCSRepo.OAuthTokenID, oc.ID) | ||
assert.Equal(t, ps.VCSRepo.RepositoryHTTPURL, fmt.Sprintf("https://github.com/%s", githubIdentifier)) | ||
assert.Equal(t, ps.VCSRepo.ServiceProvider, string(ServiceProviderGithub)) | ||
assert.Regexp(t, "^https://app\\.terraform\\.io/webhooks/vcs/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$", ps.VCSRepo.WebhookURL) |
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.
Ditto, here as well!
closes #138 |
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.
👍 Awesome
Is there something wrong with the circleci tests? #422 also has some fails but the only change is an addition to the change log |
I'll start the tests again. We have a few flaky tests. |
Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes. |
Description
Terraform creates a webhook URL for every workspace that is attached to a VCS Provider, but for some reason, this generated URL is not exposed to the users of the go-tfe client. This PR tries to fix that. If this PR gets merged, will need to wait for a new release and then send another PR to https://github.com/hashicorp/terraform-provider-tfe which would also expose the same information to TFE provider users.
This will be useful for people (at least for me) who wants to add custom logic between GitHub (or any other VCS) and Terraform Cloud/Enterprise.
I had to skip the test for the Policy Sets as I currently do not have a paid membership on TF Cloud.
Output from tests