Skip to content

Commit

Permalink
Stricter data types
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Aug 31, 2020
1 parent ede91a6 commit 9a14409
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 25 deletions.
22 changes: 11 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
Variant[Stdlib::Absolutepath, Boolean] $client_body_temp_path = $nginx::params::client_body_temp_path,
Boolean $confd_only = false,
Boolean $confd_purge = false,
$conf_dir = $nginx::params::conf_dir,
Stdlib::Absolutepath $conf_dir = $nginx::params::conf_dir,
Optional[Enum['on', 'off']] $daemon = undef,
$daemon_user = $nginx::params::daemon_user,
$daemon_group = undef,
String[1] $daemon_user = $nginx::params::daemon_user,
Optional[String[1]] $daemon_group = undef,
Array[String] $dynamic_modules = [],
$global_owner = $nginx::params::global_owner,
$global_group = $nginx::params::global_group,
$global_mode = $nginx::params::global_mode,
String[1] $global_owner = $nginx::params::global_owner,
String[1] $global_group = $nginx::params::global_group,
Stdlib::Filemode $global_mode = $nginx::params::global_mode,
Optional[Variant[String[1], Array[String[1]]]] $limit_req_zone = undef,
Stdlib::Absolutepath $log_dir = $nginx::params::log_dir,
String[1] $log_user = $nginx::params::log_user,
Expand All @@ -66,20 +66,20 @@
$http_format_log = undef,
Variant[String, Array[String]] $nginx_error_log = "${log_dir}/${nginx::params::nginx_error_log_file}",
Nginx::ErrorLogSeverity $nginx_error_log_severity = 'error',
$pid = $nginx::params::pid,
Variant[Stdlib::Absolutepath, Boolean] $pid = $nginx::params::pid,
Variant[Stdlib::Absolutepath, Boolean] $proxy_temp_path = $nginx::params::proxy_temp_path,
$root_group = $nginx::params::root_group,
$run_dir = $nginx::params::run_dir,
String[1] $root_group = $nginx::params::root_group,
Stdlib::Absolutepath $run_dir = $nginx::params::run_dir,
$sites_available_owner = $nginx::params::sites_available_owner,
$sites_available_group = $nginx::params::sites_available_group,
$sites_available_mode = $nginx::params::sites_available_mode,
Boolean $super_user = $nginx::params::super_user,
$temp_dir = $nginx::params::temp_dir,
Stdlib::Absolutepath $temp_dir = $nginx::params::temp_dir,
Boolean $server_purge = false,
Boolean $include_modules_enabled = $nginx::params::include_modules_enabled,

# Primary Templates
$conf_template = 'nginx/conf.d/nginx.conf.erb',
String[1] $conf_template = 'nginx/conf.d/nginx.conf.erb',

### START Nginx Configuration ###
Optional[Enum['on', 'off']] $absolute_redirect = undef,
Expand Down
8 changes: 4 additions & 4 deletions manifests/resource/mailhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
define nginx::resource::mailhost (
Stdlib::Port $listen_port,
Enum['absent', 'present'] $ensure = 'present',
Variant[Array[String], String] $listen_ip = '*',
Nginx::Listen::V4 $listen_ip = '*',
Optional[String] $listen_options = undef,
Boolean $ipv6_enable = false,
Variant[Array[String], String] $ipv6_listen_ip = '::',
Nginx::Listen::V6 $ipv6_listen_ip = '::',
Stdlib::Port $ipv6_listen_port = 80,
String $ipv6_listen_options = 'default ipv6only=on',
Boolean $ssl = false,
Expand All @@ -102,10 +102,10 @@
Optional[String] $ssl_trusted_cert = undef,
Optional[Integer] $ssl_verify_depth = undef,
Enum['on', 'off', 'only'] $starttls = 'off',
$protocol = undef,
Optional[Enum['imap', 'pop3', 'smtp']] $protocol = undef,
Optional[String] $auth_http = undef,
Optional[String] $auth_http_header = undef,
String $xclient = 'on',
Enum['on', 'off'] $xclient = 'on',
Optional[String] $imap_auth = undef,
Optional[Array] $imap_capabilities = undef,
Optional[String] $imap_client_buffer = undef,
Expand Down
4 changes: 2 additions & 2 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
# }
define nginx::resource::server (
Enum['absent', 'present'] $ensure = 'present',
Variant[Array, String] $listen_ip = '*',
Nginx::Listen::V4 $listen_ip = '*',
Integer $listen_port = 80,
Optional[String] $listen_options = undef,
Boolean $listen_unix_socket_enable = false,
Expand All @@ -164,7 +164,7 @@
Array $location_allow = [],
Array $location_deny = [],
Boolean $ipv6_enable = false,
Variant[Array, String] $ipv6_listen_ip = '::',
Nginx::Listen::V6 $ipv6_listen_ip = '::',
Integer $ipv6_listen_port = 80,
String $ipv6_listen_options = 'default ipv6only=on',
Hash $add_header = {},
Expand Down
16 changes: 8 additions & 8 deletions spec/defines/resource_mailhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@
{
title: 'should set protocol',
attr: 'protocol',
value: 'test-protocol',
match: ' protocol test-protocol;'
value: 'imap',
match: ' protocol imap;'
},
{
title: 'should set xclient',
attr: 'xclient',
value: 'test-xclient',
match: ' xclient test-xclient;'
value: 'off',
match: ' xclient off;'
},
{
title: 'should set auth_http',
Expand Down Expand Up @@ -533,14 +533,14 @@
{
title: 'should set protocol',
attr: 'protocol',
value: 'test-protocol',
match: ' protocol test-protocol;'
value: 'imap',
match: ' protocol imap;'
},
{
title: 'should set xclient',
attr: 'xclient',
value: 'test-xclient',
match: ' xclient test-xclient;'
value: 'off',
match: ' xclient off;'
},
{
title: 'should set auth_http',
Expand Down
11 changes: 11 additions & 0 deletions spec/type_aliases/listen_v4_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe 'Nginx::Listen::V4' do
it { is_expected.to allow_value('*') }
it { is_expected.to allow_value('127.0.0.1') }
it { is_expected.to allow_value('192.0.2.1') }
it { is_expected.to allow_value(['198.51.100.1', '203.0.113.1']) }
it { is_expected.not_to allow_value('192.0.2.1/24') }
it { is_expected.not_to allow_value('::') }
it { is_expected.not_to allow_value('2001:db8::1') }
end
11 changes: 11 additions & 0 deletions spec/type_aliases/listen_v6_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

describe 'Nginx::Listen::V4' do
it { is_expected.to allow_value('::') }
it { is_expected.to allow_value('::1') }
it { is_expected.to allow_value('2001:db8::1') }
it { is_expected.to allow_value(['2001:db8::1', '2001:0db8:ffff:ffff:ffff:ffff:ffff:ffff']) }
it { is_expected.not_to allow_value('2001:db8::/64') }
it { is_expected.not_to allow_value('192.0.2.1') }
it { is_expected.not_to allow_value('*') }
end
2 changes: 2 additions & 0 deletions types/listen/v4.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Listen on IPv4 statement
type Nginx::Listen::V4 = Variant[Enum['*'], Array[Stdlib::IP::Address::V4::Nosubnet], Stdlib::IP::Address::V4::Nosubnet]
2 changes: 2 additions & 0 deletions types/listen/v6.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Listen on IPv6 statement
type Nginx::Listen::V6 = Variant[Array[Stdlib::IP::Address::V6::Nosubnet], Stdlib::IP::Address::V6::Nosubnet]

0 comments on commit 9a14409

Please sign in to comment.