Skip to content

Commit

Permalink
github_webhook: Don't include secret in the config if it's absent (#5994
Browse files Browse the repository at this point in the history
)

* github_webhook: Don't include secret in the config if it's absent

* Add changelogs

* Fix indentation

* Apply suggestion to simplify the check

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: dima1206 <�32818228+dima1206@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 1877ef1)
  • Loading branch information
dima1206 authored and patchback[bot] committed Feb 25, 2023
1 parent 04df03f commit 04c47d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/5994-github-webhook-secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- github_webhook - fix always changed state when no secret is provided (https://github.com/ansible-collections/community.general/pull/5994).
9 changes: 7 additions & 2 deletions plugins/modules/source_control/github/github_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,18 @@


def _create_hook_config(module):
return {
hook_config = {
"url": module.params["url"],
"content_type": module.params["content_type"],
"secret": module.params.get("secret"),
"insecure_ssl": "1" if module.params["insecure_ssl"] else "0"
}

secret = module.params.get("secret")
if secret:
hook_config["secret"] = secret

return hook_config


def create_hook(repo, module):
config = _create_hook_config(module)
Expand Down

0 comments on commit 04c47d1

Please sign in to comment.