Skip to content

Commit

Permalink
Merge pull request #341 from bastelfreak/puppet4
Browse files Browse the repository at this point in the history
replace all validate functions with datatypes
  • Loading branch information
yastupin authored Mar 3, 2017
2 parents 345adaf + 01866b8 commit 4bf5b6c
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fixtures:
repositories:
stdlib:
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
ref: "4.6.0"
ref: "4.13.1"
ruby: "git://github.com/puppetlabs/puppetlabs-ruby.git"
gcc: "git://github.com/puppetlabs/puppetlabs-gcc.git"
pe_gem: "git://github.com/puppetlabs/puppetlabs-pe_gem.git"
Expand Down
41 changes: 12 additions & 29 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,23 @@
class r10k::config (
$configfile,
$cachedir,
$manage_modulepath,
Boolean $manage_modulepath,
$root_user,
$root_group,
$modulepath = undef,
$remote = '',
$sources = 'UNSET',
$postrun = undef,
$puppetconf_path = $r10k::params::puppetconf_path,
$r10k_basedir = $r10k::params::r10k_basedir,
$manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
$configfile_symlink = '/etc/r10k.yaml',
$r10k_yaml_template = 'r10k/r10k.yaml.erb',
$git_settings = {},
$forge_settings = {},
$deploy_settings = {},
Variant[String, Hash ] $sources = 'UNSET',
Optional[Array] $postrun = undef,
Stdlib::Absolutepath $puppetconf_path = $r10k::params::puppetconf_path,
Stdlib::Absolutepath $r10k_basedir = $r10k::params::r10k_basedir,
Boolean $manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
Stdlib::Absolutepath $configfile_symlink = '/etc/r10k.yaml',
String $r10k_yaml_template = 'r10k/r10k.yaml.erb',
Hash $git_settings = {},
Hash $forge_settings = {},
Hash $deploy_settings = {},
) inherits r10k::params {

validate_bool($manage_modulepath)

if is_string($manage_configfile_symlink) {
$manage_configfile_symlink_real = str2bool($manage_configfile_symlink)
} else {
$manage_configfile_symlink_real = $manage_configfile_symlink
}
validate_bool($manage_configfile_symlink_real)

validate_absolute_path($configfile_symlink)

if $sources == 'UNSET' {
$r10k_sources = {
'puppet' => {
Expand All @@ -85,16 +74,10 @@
}
$source_keys = keys($r10k_sources)
} else {
validate_hash($sources)

$r10k_sources = $sources
$source_keys = keys($r10k_sources)
}

if $postrun != undef {
validate_array($postrun)
}

if $configfile == '/etc/puppetlabs/r10k/r10k.yaml' {
file {'/etc/puppetlabs/r10k':
ensure => 'directory',
Expand All @@ -113,7 +96,7 @@
content => template($r10k_yaml_template),
}

if $manage_configfile_symlink_real == true {
if $manage_configfile_symlink {
file { 'symlink_r10k.yaml':
ensure => 'link',
path => $configfile_symlink,
Expand Down
62 changes: 28 additions & 34 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# This class configures r10k
class r10k (
$remote = $r10k::params::remote,
$sources = $r10k::params::sources,
$cachedir = $r10k::params::r10k_cache_dir,
$configfile = $r10k::params::r10k_config_file,
$version = $r10k::params::version,
$puppet_master = $r10k::params::puppet_master,
$modulepath = $r10k::params::modulepath,
$manage_modulepath = $r10k::params::manage_modulepath,
$manage_ruby_dependency = $r10k::params::manage_ruby_dependency,
$r10k_basedir = $r10k::params::r10k_basedir,
$package_name = $r10k::params::package_name,
$provider = $r10k::params::provider,
$gentoo_keywords = $r10k::params::gentoo_keywords,
$install_options = $r10k::params::install_options,
$mcollective = $r10k::params::mcollective,
$manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
$configfile_symlink = $r10k::params::configfile_symlink,
$git_settings = $r10k::params::git_settings,
$forge_settings = $r10k::params::forge_settings,
$deploy_settings = $r10k::params::deploy_settings,
$root_user = $r10k::params::root_user,
$root_group = $r10k::params::root_group,
$postrun = undef,
$include_prerun_command = false,
$include_postrun_command = false,
$install_gcc = false,
$remote = $r10k::params::remote,
$sources = $r10k::params::sources,
$cachedir = $r10k::params::r10k_cache_dir,
$configfile = $r10k::params::r10k_config_file,
$version = $r10k::params::version,
$puppet_master = $r10k::params::puppet_master,
$modulepath = $r10k::params::modulepath,
$manage_modulepath = $r10k::params::manage_modulepath,
Enum['include','declare','ignore'] $manage_ruby_dependency = $r10k::params::manage_ruby_dependency,
$r10k_basedir = $r10k::params::r10k_basedir,
$package_name = $r10k::params::package_name,
$provider = $r10k::params::provider,
$gentoo_keywords = $r10k::params::gentoo_keywords,
$install_options = $r10k::params::install_options,
$mcollective = $r10k::params::mcollective,
$manage_configfile_symlink = $r10k::params::manage_configfile_symlink,
$configfile_symlink = $r10k::params::configfile_symlink,
Hash $git_settings = $r10k::params::git_settings,
Hash $forge_settings = $r10k::params::forge_settings,
Hash $deploy_settings = $r10k::params::deploy_settings,
$root_user = $r10k::params::root_user,
$root_group = $r10k::params::root_group,
$postrun = undef,
Boolean $include_prerun_command = false,
Boolean $include_postrun_command = false,
Boolean $install_gcc = false,
) inherits r10k::params {

# Check if user is declaring both classes
Expand All @@ -36,20 +36,14 @@
fail('This module does not support being declared with pe_r10k')
}

$ruby_dependency_options=['include','declare','ignore']
validate_re($manage_ruby_dependency,$ruby_dependency_options)
validate_hash($git_settings, $forge_settings, $deploy_settings)

# TODO: Clean this up when 4.0 to require a boolean
if $include_prerun_command == true or $include_prerun_command == 'true'{
if $include_prerun_command {
include ::r10k::prerun_command
}

if $include_postrun_command == true or $include_postrun_command == 'true'{
if $include_postrun_command {
include ::r10k::postrun_command
}


class { '::r10k::install':
install_options => $install_options,
keywords => $gentoo_keywords,
Expand Down
7 changes: 2 additions & 5 deletions manifests/postrun_command.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# This class will configure r10k to run as part of the masters agent run
class r10k::postrun_command (
$command = $r10k::params::pre_postrun_command,
$ensure = 'present',
$command = $r10k::params::pre_postrun_command,
Enum['present', 'absent'] $ensure = 'present',
) inherits r10k::params {

validate_re($ensure, [ '^present', '^absent' ],
'ensure must be either present or absent')

ini_setting { 'r10k_postrun_command':
ensure => $ensure,
path => "${r10k::params::puppetconf_path}/puppet.conf",
Expand Down
7 changes: 2 additions & 5 deletions manifests/prerun_command.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# This class will configure r10k to run as part of the masters agent run
class r10k::prerun_command (
$command = $r10k::params::pre_postrun_command,
$ensure = 'present',
$command = $r10k::params::pre_postrun_command,
Enum['present', 'absent'] $ensure = 'present',
) inherits r10k::params {

validate_re($ensure, [ '^present', '^absent' ],
'ensure must be either present or absent')

ini_setting { 'r10k_prerun_command':
ensure => $ensure,
path => "${r10k::params::puppetconf_path}/puppet.conf",
Expand Down
75 changes: 37 additions & 38 deletions manifests/webhook/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@
#
# Zack Smith <zack@puppetlabs.com>
class r10k::webhook::config (
$ensure = true,
$hash = 'UNSET',
$certname = $r10k::params::webhook_certname,
$certpath = $r10k::params::webhook_certpath,
$user = $r10k::params::webhook_user,
$pass = $r10k::params::webhook_pass,
$bind_address = $r10k::params::webhook_bind_address,
$port = $r10k::params::webhook_port,
$access_logfile = $r10k::params::webhook_access_logfile,
$client_cfg = $r10k::params::webhook_client_cfg,
$use_mco_ruby = $r10k::params::webhook_use_mco_ruby,
$protected = $r10k::params::webhook_protected,
$github_secret = $r10k::params::webhook_github_secret,
$discovery_timeout = $r10k::params::webhook_discovery_timeout,
$client_timeout = $r10k::params::webhook_client_timeout,
$prefix = $r10k::params::webhook_prefix,
$prefix_command = $r10k::params::webhook_prefix_command,
$server_software = $r10k::params::webhook_server_software,
$enable_ssl = $r10k::params::webhook_enable_ssl,
$use_mcollective = $r10k::params::webhook_use_mcollective,
$r10k_deploy_arguments = $r10k::params::webhook_r10k_deploy_arguments,
$public_key_path = $r10k::params::webhook_public_key_path,
$private_key_path = $r10k::params::webhook_private_key_path,
$yaml_template = $r10k::params::webhook_yaml_template,
$command_prefix = $r10k::params::webhook_r10k_command_prefix,
$repository_events = $r10k::params::webhook_repository_events,
$allow_uppercase = $r10k::params::webhook_allow_uppercase,
$slack_webhook = $r10k::params::webhook_slack_webhook,
$slack_channel = $r10k::params::webhook_slack_channel,
$slack_username = $r10k::params::webhook_slack_username,
$configfile_owner = $r10k::params::webhook_configfile_owner,
$configfile_group = $r10k::params::webhook_configfile_group,
$configfile_mode = $r10k::params::webhook_configfile_mode,
$configfile = '/etc/webhook.yaml',
$manage_symlink = false,
$configfile_symlink = '/etc/webhook.yaml',
$enable_mutex_lock = $r10k::params::webhook_enable_mutex_lock,
$ensure = true,
Variant[String, Hash] $hash = 'UNSET',
$certname = $r10k::params::webhook_certname,
$certpath = $r10k::params::webhook_certpath,
$user = $r10k::params::webhook_user,
$pass = $r10k::params::webhook_pass,
$bind_address = $r10k::params::webhook_bind_address,
$port = $r10k::params::webhook_port,
$access_logfile = $r10k::params::webhook_access_logfile,
$client_cfg = $r10k::params::webhook_client_cfg,
$use_mco_ruby = $r10k::params::webhook_use_mco_ruby,
$protected = $r10k::params::webhook_protected,
$github_secret = $r10k::params::webhook_github_secret,
$discovery_timeout = $r10k::params::webhook_discovery_timeout,
$client_timeout = $r10k::params::webhook_client_timeout,
$prefix = $r10k::params::webhook_prefix,
$prefix_command = $r10k::params::webhook_prefix_command,
$server_software = $r10k::params::webhook_server_software,
$enable_ssl = $r10k::params::webhook_enable_ssl,
$use_mcollective = $r10k::params::webhook_use_mcollective,
$r10k_deploy_arguments = $r10k::params::webhook_r10k_deploy_arguments,
$public_key_path = $r10k::params::webhook_public_key_path,
$private_key_path = $r10k::params::webhook_private_key_path,
$yaml_template = $r10k::params::webhook_yaml_template,
$command_prefix = $r10k::params::webhook_r10k_command_prefix,
$repository_events = $r10k::params::webhook_repository_events,
$allow_uppercase = $r10k::params::webhook_allow_uppercase,
$slack_webhook = $r10k::params::webhook_slack_webhook,
$slack_channel = $r10k::params::webhook_slack_channel,
$slack_username = $r10k::params::webhook_slack_username,
$configfile_owner = $r10k::params::webhook_configfile_owner,
$configfile_group = $r10k::params::webhook_configfile_group,
$configfile_mode = $r10k::params::webhook_configfile_mode,
$configfile = '/etc/webhook.yaml',
$manage_symlink = false,
$configfile_symlink = '/etc/webhook.yaml',
$enable_mutex_lock = $r10k::params::webhook_enable_mutex_lock,
) inherits r10k::params {

if $hash == 'UNSET' {
Expand Down Expand Up @@ -77,7 +77,6 @@
'slack_username' => $slack_username,
}
} else {
validate_hash($hash)
$webhook_hash = $hash
}

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.6.0 < 5.0.0"
"version_requirement": ">= 4.13.1 < 5.0.0"
},
{
"name": "puppetlabs/ruby",
Expand Down
Loading

0 comments on commit 4bf5b6c

Please sign in to comment.