voxpupuli / webhook-go

Puppet Webhook port in Golang
Apache License 2.0
16 stars 12 forks source link

make module_name option optional #149

Closed tmu-sprd closed 5 months ago

tmu-sprd commented 6 months ago

With PR #139 an option module_name was introduced to override the module name. This option is now mandatory, which I assume wasn't intended. This PR makes it optional.

Description: Deploy module my_module without ?module_name:

echo -e $(curl -s -u"r10kdeploy:DeployPass" -d '{ "project": { "name": "my_module" } }' -H 'Accept: application/json' -H 'X-Gitlab-Event: Push Hook' 'http://localhost:4000/api/v1/r10k/module')

Expected result:

"INFO    -> Using Puppetfile '/etc/puppetlabs/code/environments/production/Puppetfile'
INFO     -> Deploying module to /etc/puppetlabs/code/environments/production/modules/my_module
"

Actual result:

{"message":"Invalid module name"}

Explanation: Matching for an invalid module name should only be done, when the option is given. Not giving the option, the variable overrideModule is an empty string, which does not match the RegEx, throwing the error.

genebean commented 5 months ago

I tested this fix in my local copy of the code and it seems to solve the issue for me.