Skip to content

Commit f274e51

Browse files
authored
Merge pull request #443 from syseleven/fix/validate_function_deprecation
Replace deprecated validate_* functions
2 parents 81e3715 + 13b725d commit f274e51

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

manifests/gunicorn.pp

+20-28
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,27 @@
3434
# }
3535
#
3636
define python::gunicorn (
37-
Enum['present', 'absent'] $ensure = present,
38-
$config_dir = '/etc/gunicorn.d',
39-
$manage_config_dir = false,
40-
$virtualenv = false,
41-
Enum['wsgi', 'django'] $mode = 'wsgi',
42-
$dir = false,
43-
$bind = false,
44-
$environment = false,
45-
$owner = 'www-data',
46-
$group = 'www-data',
47-
$appmodule = 'app:app',
48-
$osenv = false,
49-
$timeout = 30,
50-
$workers = false,
51-
$access_log_format = false,
52-
$accesslog = false,
53-
$errorlog = false,
54-
$log_level = 'error',
55-
$template = 'python/gunicorn.erb',
56-
$args = [],
37+
Stdlib::Absolutepath $dir,
38+
Enum['present', 'absent'] $ensure = present,
39+
$config_dir = '/etc/gunicorn.d',
40+
$manage_config_dir = false,
41+
$virtualenv = false,
42+
Enum['wsgi', 'django'] $mode = 'wsgi',
43+
$bind = false,
44+
$environment = false,
45+
$owner = 'www-data',
46+
$group = 'www-data',
47+
$appmodule = 'app:app',
48+
$osenv = false,
49+
$timeout = 30,
50+
$workers = false,
51+
$access_log_format = false,
52+
$accesslog = false,
53+
$errorlog = false,
54+
Enum['debug', 'info', 'warning', 'error', 'critical'] $log_level = 'error',
55+
$template = 'python/gunicorn.erb',
56+
$args = [],
5757
) {
58-
59-
# Parameter validation
60-
if ! $dir {
61-
fail('python::gunicorn: dir parameter must not be empty')
62-
}
63-
64-
validate_re($log_level, 'debug|info|warning|error|critical', "Invalid \$log_level value ${log_level}")
65-
6658
if $manage_config_dir {
6759
file { $config_dir:
6860
ensure => directory,

manifests/init.pp

+4-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@
6161
default => '',
6262
}
6363

64-
#$allowed_versions = concat(['system', 'pypy'], $valid_versions)
65-
#unless $version =~ Enum[allowed_versions] {
66-
#fail("version needs to be within${allowed_versions}")
67-
#}
68-
validate_re($version, concat(['system', 'pypy'], $valid_versions))
64+
$allowed_versions = concat(['system', 'pypy'], $valid_versions)
65+
unless $version =~ Enum[$allowed_versions] {
66+
fail("version needs to be within${allowed_versions}")
67+
}
6968

7069
# Module compatibility check
7170
$compatible = [ 'Debian', 'RedHat', 'Suse', 'Gentoo' ]

manifests/pip.pp

+1-7
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
define python::pip (
5353
String $pkgname = $name,
5454
Variant[Enum[present, absent, latest], String[1]] $ensure = present,
55-
String $virtualenv = 'system',
55+
Variant[Enum['system'], Stdlib::Absolutepath] $virtualenv = 'system',
5656
Enum['pip', 'pip3'] $pip_provider = 'pip',
5757
Variant[Boolean, String] $url = false,
5858
String[1] $owner = 'root',
@@ -87,10 +87,6 @@
8787
}
8888

8989
# Parameter validation
90-
if ! $virtualenv {
91-
fail('python::pip: virtualenv parameter must not be empty')
92-
}
93-
9490
if $virtualenv == 'system' and $owner != 'root' {
9591
fail('python::pip: root user must be used when virtualenv is system')
9692
}
@@ -100,8 +96,6 @@
10096
default => $virtualenv,
10197
}
10298

103-
validate_absolute_path($cwd)
104-
10599
$log = $virtualenv ? {
106100
'system' => $log_dir,
107101
default => $virtualenv,

metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"dependencies": [
5757
{
5858
"name": "puppetlabs/stdlib",
59-
"version_requirement": ">= 4.6.0 < 6.0.0"
59+
"version_requirement": ">= 4.13.1 < 6.0.0"
6060
},
6161
{
6262
"name": "stahnma/epel",

spec/defines/pip_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
context 'fails with non qualified path' do
2525
let(:params) { { virtualenv: 'venv' } }
2626

27-
it { is_expected.to raise_error(%r{"venv" is not an absolute path.}) }
27+
it { is_expected.to raise_error(%r{expects a match for Variant\[Enum\['system'\].*Stdlib::Windowspath = Pattern\[\/.*\/\], Stdlib::Unixpath = Pattern\[\/.*\/\]\]}) }
2828
end
2929
context 'suceeds with qualified path' do
3030
let(:params) { { virtualenv: '/opt/venv' } }

0 commit comments

Comments
 (0)