-
Notifications
You must be signed in to change notification settings - Fork 763
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
Bug Fix: Webhook secret stored incorrectly in state #251
Conversation
…rned from the api
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'd love to see a test that the secret actually ends up in state as we expect. Otherwise, this looks reasonable to me.
@@ -92,6 +92,11 @@ func resourceGithubOrganizationWebhookCreate(d *schema.ResourceData, meta interf | |||
} | |||
d.SetId(strconv.FormatInt(*hook.ID, 10)) | |||
|
|||
if hook.Config["secret"] != nil { | |||
hook.Config["secret"] = webhookObj.Config["secret"] |
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'm assuming the GitHub API doesn't return the secret, so we have to set it based on what's in the ResourceData? If so, can we add a comment saying as much, just to explain why we have to do this?
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.
Also, what does hook.Config
get set to, if not nil
? That looks like the GitHub response, but what does it actually get set to?
currentSecret := d.Get("configuration").([]interface{})[0].(map[string]interface{})["secret"] | ||
|
||
if hook.Config["secret"] != nil { | ||
hook.Config["secret"] = currentSecret |
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.
Likewise, a comment here just explaining the situation would be 💯
Ah, this explains why terraform screwed up all of our organizations hook secrets! Can we get this merged.... |
Hope this get reviewed and merged soon 🚀 |
Hope this get merged ASAP. we have to apply the patch manually currently, which is not very nice. |
…k-secret Bug Fix: Webhook secret stored incorrectly in state
Addressing #171 where the webhook secret set in Terraform makes signatures not match.
Before fix:
After fix: