Skip to content

Commit

Permalink
Replace validate_apache_loglevel() with data type
Browse files Browse the repository at this point in the history
The function was introduced before Puppet 4 was released.  It was
originally created to reduce duplicated use of stdlib's `validate_re`.

See #1097
  • Loading branch information
alexjfisher committed May 2, 2020
1 parent e8465d2 commit ce072b1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 117 deletions.
28 changes: 0 additions & 28 deletions lib/puppet/functions/apache/validate_apache_log_level.rb

This file was deleted.

31 changes: 0 additions & 31 deletions lib/puppet/parser/functions/validate_apache_log_level.rb

This file was deleted.

4 changes: 1 addition & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@
$limitreqfields = '100',
$logroot = $::apache::params::logroot,
$logroot_mode = $::apache::params::logroot_mode,
$log_level = $::apache::params::log_level,
Apache::LogLevel $log_level = $::apache::params::log_level,
$log_formats = {},
$ssl_file = undef,
$ports_file = $::apache::params::ports_file,
Expand Down Expand Up @@ -602,8 +602,6 @@
}
}

apache::validate_apache_log_level($log_level)

class { '::apache::service':
service_name => $service_name,
service_enable => $service_enable,
Expand Down
6 changes: 1 addition & 5 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@
$logroot_mode = undef,
$logroot_owner = undef,
$logroot_group = undef,
$log_level = undef,
Optional[Apache::LogLevel] $log_level = undef,
Boolean $access_log = true,
$access_log_file = false,
$access_log_pipe = false,
Expand Down Expand Up @@ -1940,10 +1940,6 @@

# Input validation begins

if $log_level {
apache::validate_apache_log_level($log_level)
}

if $access_log_file and $access_log_pipe {
fail("Apache::Vhost[${name}]: 'access_log_file' and 'access_log_pipe' cannot be defined at the same time")
}
Expand Down
12 changes: 0 additions & 12 deletions spec/functions/validate_apache_log_level_spec.rb

This file was deleted.

23 changes: 23 additions & 0 deletions spec/type_aliases/loglevel_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'

describe 'Apache::LogLevel' do
[
'info',
'warn ssl:info',
'warn mod_ssl.c:info',
'warn mod_ssl.c:info',
'warn ssl_module:info',
'trace4',
].each do |allowed_value|
it { is_expected.to allow_value(allowed_value) }
end

[
'garbage',
'',
[],
['info'],
].each do |invalid_value|
it { is_expected.not_to allow_value(invalid_value) }
end
end
38 changes: 0 additions & 38 deletions spec/unit/puppet/parser/functions/validate_apache_log_level.rb

This file was deleted.

2 changes: 2 additions & 0 deletions types/loglevel.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @summary As per http://httpd.apache.org/docs/current/mod/core.html#loglevel
type Apache::LogLevel = Pattern[/(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])/]

0 comments on commit ce072b1

Please sign in to comment.