Skip to content

Commit 9d40da6

Browse files
committed
Lay down a file with the webhook url in it
Prior to this commit, if you did not set the gms_api_token and wanted to set the webhook manually you'd have to figure out the URL on your own. After this commit, there will be a file that contains the URL you should use for your webhook.
1 parent ed911e6 commit 9d40da6

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

manifests/code_manager.pp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,29 @@
126126
}
127127
}
128128

129-
if !empty($gms_api_token) {
130-
if $authenticate_webhook and !empty($rbac_token_file_contents) {
131129

132-
$rbac_token = parsejson($rbac_token_file_contents)['token']
130+
if $authenticate_webhook and !empty($rbac_token_file_contents) {
133131

134-
$token_info = "&token=${rbac_token}"
135-
}
136-
else {
137-
$token_info = ''
138-
}
132+
$rbac_token = parsejson($rbac_token_file_contents)['token']
133+
$token_info = "&token=${rbac_token}"
134+
}
135+
else {
136+
$token_info = ''
137+
}
139138

140-
$code_manager_webhook_type = $git_management_system ? {
141-
'gitlab' => 'github',
142-
default => $git_management_system,
143-
}
139+
$code_manager_webhook_type = $git_management_system ? {
140+
'gitlab' => 'github',
141+
default => $git_management_system,
142+
}
143+
144+
$webhook_url = "https://${::fqdn}:8170/code-manager/v1/webhook?type=${code_manager_webhook_type}${token_info}"
144145

146+
file { "${token_directory}/webhook_url.txt" :
147+
ensure => file,
148+
content => $webhook_url,
149+
}
150+
151+
if !empty($gms_api_token) {
145152
if $create_and_manage_git_deploy_key {
146153
git_deploy_key { "add_deploy_key_to_puppet_control-${::fqdn}":
147154
ensure => present,
@@ -157,7 +164,7 @@
157164
if $manage_git_webhook {
158165
git_webhook { "code_manager_post_receive_webhook-${::fqdn}" :
159166
ensure => present,
160-
webhook_url => "https://${::fqdn}:8170/code-manager/v1/webhook?type=${code_manager_webhook_type}${token_info}",
167+
webhook_url => $webhook_url,
161168
token => $gms_api_token,
162169
project_name => $control_repo_project_name,
163170
server_url => hiera('gms_server_url'),

0 commit comments

Comments
 (0)