summaryrefslogtreecommitdiff
path: root/source_control/github_hooks.py
diff options
context:
space:
mode:
authorBen Mather <bwhmather@bwhmather.com>2014-09-29 14:35:04 +0100
committerBen Mather <bwhmather@bwhmather.com>2014-09-29 14:35:04 +0100
commitf6cd2d931ee192afefd3d7798c91b94a946a2d45 (patch)
treee7743c3db84d209a8071e71cb2a0caa44aac57ba /source_control/github_hooks.py
parentd95d8c9d988436b7c8256e02d80016dcf5db2b06 (diff)
downloadansible-modules-extras-f6cd2d931ee192afefd3d7798c91b94a946a2d45.tar.gz
make it possible to configure the content type of a github webhook
Diffstat (limited to 'source_control/github_hooks.py')
-rw-r--r--source_control/github_hooks.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/source_control/github_hooks.py b/source_control/github_hooks.py
index c448231f..0ca58796 100644
--- a/source_control/github_hooks.py
+++ b/source_control/github_hooks.py
@@ -57,6 +57,12 @@ options:
required: false
default: 'yes'
choices: ['yes', 'no']
+ content_type:
+ description:
+ - Content type to use for requests made to the webhook
+ required: false
+ default: 'json'
+ choices: ['json', 'form']
author: Phillip Gentry, CX Inc
'''
@@ -105,14 +111,14 @@ def cleanall(module, hookurl, oauthkey, repo, user):
return 0, current_hooks
-def create(module, hookurl, oauthkey, repo, user):
+def create(module, hookurl, oauthkey, repo, user, content_type):
url = "%s/hooks" % repo
values = {
"active": True,
"name": "web",
"config": {
"url": "%s" % hookurl,
- "content_type": "json"
+ "content_type": "%s" % content_type
}
}
data = json.dumps(values)
@@ -144,6 +150,7 @@ def main():
repo=dict(required=True),
user=dict(required=True),
validate_certs=dict(default='yes', type='bool'),
+ content_type=dict(default='json', choices=['json', 'form']),
)
)
@@ -152,6 +159,7 @@ def main():
oauthkey = module.params['oauthkey']
repo = module.params['repo']
user = module.params['user']
+ content_type = module.params['content_type']
if action == "list":
(rc, out) = list_(module, hookurl, oauthkey, repo, user)
@@ -163,7 +171,7 @@ def main():
(rc, out) = cleanall(module, hookurl, oauthkey, repo, user)
if action == "create":
- (rc, out) = create(module, hookurl, oauthkey, repo, user)
+ (rc, out) = create(module, hookurl, oauthkey, repo, user, content_type)
if rc != 0:
module.fail_json(msg="failed", result=out)