Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace validate deprecated functions with data types #24

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

class winlogbeat (
$major_version = undef,
$package_ensure = $winlogbeat::params::package_ensure,
String $package_ensure = $winlogbeat::params::package_ensure,
$service_ensure = $winlogbeat::params::service_ensure,
$service_enable = $winlogbeat::params::service_enable,
$service_provider = $winlogbeat::params::service_provider,
$registry_file = $winlogbeat::params::registry_file,
String $registry_file = $winlogbeat::params::registry_file,
$config_file = $winlogbeat::params::config_file,
$outputs = $winlogbeat::params::outputs,
Hash $outputs = $winlogbeat::params::outputs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you enforce the structure of the hash?

$shipper = $winlogbeat::params::shipper,
$logging = $winlogbeat::params::logging,
Hash $logging = $winlogbeat::params::logging,
$run_options = $winlogbeat::params::run_options,
$conf_template = undef,
$download_url = undef,
Expand All @@ -52,13 +52,11 @@
$fields_under_root = $winlogbeat::params::fields_under_root,
$metrics = undef,
#### End v5 only ####
$event_logs = {},
$event_logs_merge = false,
Hash $event_logs = {},
Boolean $event_logs_merge = false,
$proxy_address = undef,
) inherits winlogbeat::params {

validate_bool($event_logs_merge)

if $major_version == undef and getvar('::winlogbeat_version') == undef {
$real_version = '5'
} elsif $major_version == undef and versioncmp($::winlogbeat_version, '5.0.0') >= 0 {
Expand Down Expand Up @@ -100,10 +98,7 @@
warning('You\'ve specified a non-standard config_file location - winlogbeat may fail to start unless you\'re doing something to fix this')
}

validate_hash($outputs, $logging, $event_logs_final)
validate_string($registry_file, $package_ensure)

if(!empty($proxy_address)){
if(!empty($proxy_address)){
validate_re($proxy_address, ['^(http(?:s)?\:\/\/[a-zA-Z0-9]+(?:(?:\.|\-)[a-zA-Z0-9]+)+(?:\:\d+)?(?:\/[\w\-]+)*(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$'], 'ERROR: You must enter a proxy url in a valid format i.e. http://proxy.net:3128')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we save this regex as a custom datatype? the validate_re() method is deprecated as well.

}

Expand Down