From 8b0f09797b69b098b4ba5e81fced858297f1a2c7 Mon Sep 17 00:00:00 2001 From: Tim 'bastelfreak' Meusel Date: Tue, 29 Aug 2023 16:55:48 +0200 Subject: [PATCH] webhook-go: Move static data from params to webhook class --- REFERENCE.md | 50 ++++++++++++++++++++++---------------------- manifests/params.pp | 27 ------------------------ manifests/webhook.pp | 50 ++++++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 77 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 64a7ee7e..0d1b4c55 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -584,7 +584,7 @@ Data type: `Boolean` -Default value: `$r10k::params::webhook_ensure` +Default value: `false` ##### `version` @@ -592,7 +592,7 @@ Data type: `String` -Default value: `$r10k::params::webhook_version` +Default value: `'2.1.0'` ##### `service_ensure` @@ -607,7 +607,7 @@ Variant[ -Default value: `$r10k::params::webhook_service_ensure` +Default value: `'running'` ##### `service_enabled` @@ -615,7 +615,7 @@ Data type: `Boolean` -Default value: `$r10k::params::webhook_service_enabled` +Default value: `true` ##### `config_ensure` @@ -643,12 +643,12 @@ Default value: ```puppet { - enabled => $r10k::params::webhook_chatops_enabled, - service => $r10k::params::webhook_chatops_service, - channel => $r10k::params::webhook_chatops_channel, - user => $r10k::params::webhook_chatops_user, - auth_token => $r10k::params::webhook_chatops_token, - server_uri => $r10k::params::webhook_chatops_uri, + enabled => false, + service => '', + channel => '', + user => '', + auth_token => '', + server_uri => '', } ``` @@ -662,9 +662,9 @@ Default value: ```puppet { - enabled => $r10k::params::webhook_tls_enabled, - certificate => $r10k::params::webhook_tls_cert_path, - key => $r10k::params::webhook_tls_key_path, + enabled => false, + certificate => undef, + key => undef, } ``` @@ -678,10 +678,10 @@ Default value: ```puppet { - protected => $r10k::params::webhook_protected, - user => $r10k::params::webhook_user, - password => $r10k::params::webhook_password, - port => $r10k::params::webhook_port, + protected => true, + user => 'puppet', + password => 'puppet', + port => 4000, tls => $tls, } ``` @@ -696,14 +696,14 @@ Default value: ```puppet { - command_path => $r10k::params::webhook_r10k_command_path, - config_path => $r10k::params::webhook_r10k_config_path, - default_branch => $r10k::params::webhook_r10k_default_branch, - prefix => $r10k::params::webhook_r10k_branch_prefix, - allow_uppercase => $r10k::params::webhook_r10k_allow_uppercase, - verbose => $r10k::params::webhook_r10k_verbose, - deploy_modules => $r10k::params::webhook_r10k_deploy_modules, - generate_types => $r10k::params::webhook_r10k_generate_types, + command_path => '/opt/puppetlabs/puppet/bin/r10k', + config_path => '/etc/puppetlabs/r10k/r10k.yaml', + default_branch => 'production', + prefix => '', + allow_uppercase => false, + verbose => true, + deploy_modules => true, + generate_types => true, } ``` diff --git a/manifests/params.pp b/manifests/params.pp index b02600b6..cb31fccb 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -60,31 +60,4 @@ $is_pe_server = false $modulepath = "${r10k_basedir}/\$environment/modules" } - - # Webhook Go parameters - $webhook_ensure = false - $webhook_protected = true - $webhook_version = '2.1.0' - $webhook_user = 'puppet' - $webhook_password = 'puppet' - $webhook_port = 4000 - $webhook_tls_enabled = false - $webhook_tls_cert_path = undef - $webhook_tls_key_path = undef - $webhook_chatops_enabled = false - $webhook_chatops_service = '' - $webhook_chatops_channel = '' - $webhook_chatops_user = '' - $webhook_chatops_token = '' - $webhook_chatops_uri = '' - $webhook_r10k_command_path = "/opt/puppetlabs/puppet/bin/${r10k_binary}" - $webhook_r10k_config_path = '/etc/puppetlabs/r10k/r10k.yaml' - $webhook_r10k_default_branch = 'production' - $webhook_r10k_branch_prefix = '' - $webhook_r10k_allow_uppercase = false - $webhook_r10k_verbose = true - $webhook_r10k_deploy_modules = true - $webhook_r10k_generate_types = true - $webhook_service_ensure = 'running' - $webhook_service_enabled = true } diff --git a/manifests/webhook.pp b/manifests/webhook.pp index 52fd14d2..1f2ecd82 100644 --- a/manifests/webhook.pp +++ b/manifests/webhook.pp @@ -5,44 +5,44 @@ # class r10k::webhook ( Enum['package', 'repo', 'none'] $install_method = 'package', - Boolean $ensure = $r10k::params::webhook_ensure, - String $version = $r10k::params::webhook_version, + Boolean $ensure = false, + String $version = '2.1.0', Variant[ Enum['running', 'stopped'], Boolean - ] $service_ensure = $r10k::params::webhook_service_ensure, - Boolean $service_enabled = $r10k::params::webhook_service_enabled, + ] $service_ensure = 'running', + Boolean $service_enabled = true, String $config_ensure = 'file', String $config_path = '/etc/voxpupuli/webhook.yml', R10k::Webhook::Config::ChatOps $chatops = { - enabled => $r10k::params::webhook_chatops_enabled, - service => $r10k::params::webhook_chatops_service, - channel => $r10k::params::webhook_chatops_channel, - user => $r10k::params::webhook_chatops_user, - auth_token => $r10k::params::webhook_chatops_token, - server_uri => $r10k::params::webhook_chatops_uri, + enabled => false, + service => '', + channel => '', + user => '', + auth_token => '', + server_uri => '', }, R10k::Webhook::Config::Server::Tls $tls = { - enabled => $r10k::params::webhook_tls_enabled, - certificate => $r10k::params::webhook_tls_cert_path, - key => $r10k::params::webhook_tls_key_path, + enabled => false, + certificate => undef, + key => undef, }, R10k::Webhook::Config::Server $server = { - protected => $r10k::params::webhook_protected, - user => $r10k::params::webhook_user, - password => $r10k::params::webhook_password, - port => $r10k::params::webhook_port, + protected => true, + user => 'puppet', + password => 'puppet', + port => 4000, tls => $tls, }, R10k::Webhook::Config::R10k $r10k = { - command_path => $r10k::params::webhook_r10k_command_path, - config_path => $r10k::params::webhook_r10k_config_path, - default_branch => $r10k::params::webhook_r10k_default_branch, - prefix => $r10k::params::webhook_r10k_branch_prefix, - allow_uppercase => $r10k::params::webhook_r10k_allow_uppercase, - verbose => $r10k::params::webhook_r10k_verbose, - deploy_modules => $r10k::params::webhook_r10k_deploy_modules, - generate_types => $r10k::params::webhook_r10k_generate_types, + command_path => '/opt/puppetlabs/puppet/bin/r10k', + config_path => '/etc/puppetlabs/r10k/r10k.yaml', + default_branch => 'production', + prefix => '', + allow_uppercase => false, + verbose => true, + deploy_modules => true, + generate_types => true, }, R10k::Webhook::Config $config = { server => $server,