Skip to content

Commit 7bfda16

Browse files
committed
(CONT-1028) Remove usage of legacy validate_re()
This deprecated function was removed from Puppet. The Puppet 4 type system can be used to ensure the validity of parameters with better error reporting.
1 parent bb59581 commit 7bfda16

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

manifests/compose.pp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@
3737
Optional[String] $version = $docker::params::compose_version,
3838
Optional[String] $install_path = $docker::params::compose_install_path,
3939
Optional[String] $symlink_name = $docker::params::compose_symlink_name,
40-
Optional[String] $proxy = undef,
40+
Optional[Pattern['^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$']] $proxy = undef,
4141
Optional[String] $base_url = $docker::params::compose_base_url,
4242
Optional[String] $raw_url = undef,
4343
Optional[Boolean] $curl_ensure = $docker::params::curl_ensure,
4444
) inherits docker::params {
45-
if $proxy != undef {
46-
validate_re($proxy, '^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$')
47-
}
48-
4945
if $facts['os']['family'] == 'windows' {
5046
$file_extension = '.exe'
5147
$file_owner = 'Administrator'

manifests/machine.pp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@
2424
Enum[present,absent] $ensure = 'present',
2525
Optional[String] $version = $docker::params::machine_version,
2626
Optional[String] $install_path = $docker::params::machine_install_path,
27-
Optional[String] $proxy = undef,
27+
Optional[Pattern['^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$']] $proxy = undef,
2828
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $url = undef,
2929
Optional[Boolean] $curl_ensure = $docker::params::curl_ensure,
3030
) inherits docker::params {
31-
if $proxy != undef {
32-
validate_re($proxy, '^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$')
33-
}
34-
3531
if $facts['os']['family'] == 'windows' {
3632
$file_extension = '.exe'
3733
$file_owner = 'Administrator'

spec/classes/compose_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
if params['proxy'] != :undef && !%r{^((https?)?://)?([^:^@]+:[^:^@]+@|)([\da-z.-]+)\.([\da-z.]{2,6})(:\d)?([/\w .-]*)*/?$}.match?(params['proxy'])
7777
it {
78-
expect(subject).to compile.and_raise_error(%r{does not match})
78+
expect(subject).to compile.and_raise_error(%r{parameter 'proxy' expects an undef value or a match for Pattern})
7979
}
8080

8181
next

0 commit comments

Comments
 (0)