Skip to content

Commit 916e4a2

Browse files
committed
Stricter data types
1 parent 2cf1d8a commit 916e4a2

File tree

9 files changed

+55
-29
lines changed

9 files changed

+55
-29
lines changed

manifests/init.pp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@
4949
Variant[Stdlib::Absolutepath, Boolean] $client_body_temp_path = $nginx::params::client_body_temp_path,
5050
Boolean $confd_only = false,
5151
Boolean $confd_purge = false,
52-
$conf_dir = $nginx::params::conf_dir,
52+
Stdlib::Absolutepath $conf_dir = $nginx::params::conf_dir,
5353
Optional[Enum['on', 'off']] $daemon = undef,
54-
$daemon_user = $nginx::params::daemon_user,
55-
$daemon_group = undef,
54+
String[1] $daemon_user = $nginx::params::daemon_user,
55+
Optional[String[1]] $daemon_group = undef,
5656
Array[String] $dynamic_modules = [],
57-
$global_owner = $nginx::params::global_owner,
58-
$global_group = $nginx::params::global_group,
59-
$global_mode = $nginx::params::global_mode,
57+
String[1] $global_owner = $nginx::params::global_owner,
58+
String[1] $global_group = $nginx::params::global_group,
59+
Stdlib::Filemode $global_mode = $nginx::params::global_mode,
6060
Optional[Variant[String[1], Array[String[1]]]] $limit_req_zone = undef,
6161
Stdlib::Absolutepath $log_dir = $nginx::params::log_dir,
6262
String[1] $log_user = $nginx::params::log_user,
@@ -66,20 +66,20 @@
6666
$http_format_log = undef,
6767
Variant[String, Array[String]] $nginx_error_log = "${log_dir}/${nginx::params::nginx_error_log_file}",
6868
Nginx::ErrorLogSeverity $nginx_error_log_severity = 'error',
69-
$pid = $nginx::params::pid,
69+
Variant[Stdlib::Absolutepath, Boolean] $pid = $nginx::params::pid,
7070
Variant[Stdlib::Absolutepath, Boolean] $proxy_temp_path = $nginx::params::proxy_temp_path,
71-
$root_group = $nginx::params::root_group,
72-
$run_dir = $nginx::params::run_dir,
71+
String[1] $root_group = $nginx::params::root_group,
72+
Stdlib::Absolutepath $run_dir = $nginx::params::run_dir,
7373
$sites_available_owner = $nginx::params::sites_available_owner,
7474
$sites_available_group = $nginx::params::sites_available_group,
7575
$sites_available_mode = $nginx::params::sites_available_mode,
7676
Boolean $super_user = $nginx::params::super_user,
77-
$temp_dir = $nginx::params::temp_dir,
77+
Stdlib::Absolutepath $temp_dir = $nginx::params::temp_dir,
7878
Boolean $server_purge = false,
7979
Boolean $include_modules_enabled = $nginx::params::include_modules_enabled,
8080

8181
# Primary Templates
82-
$conf_template = 'nginx/conf.d/nginx.conf.erb',
82+
String[1] $conf_template = 'nginx/conf.d/nginx.conf.erb',
8383

8484
### START Nginx Configuration ###
8585
Optional[Enum['on', 'off']] $absolute_redirect = undef,

manifests/resource/mailhost.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@
7777
define nginx::resource::mailhost (
7878
Stdlib::Port $listen_port,
7979
Enum['absent', 'present'] $ensure = 'present',
80-
Variant[Array[String], String] $listen_ip = '*',
80+
Nginx::Listen::V4 $listen_ip = '*',
8181
Optional[String] $listen_options = undef,
8282
Boolean $ipv6_enable = false,
83-
Variant[Array[String], String] $ipv6_listen_ip = '::',
83+
Nginx::Listen::V6 $ipv6_listen_ip = '::',
8484
Stdlib::Port $ipv6_listen_port = 80,
8585
String $ipv6_listen_options = 'default ipv6only=on',
8686
Boolean $ssl = false,
@@ -102,10 +102,10 @@
102102
Optional[String] $ssl_trusted_cert = undef,
103103
Optional[Integer] $ssl_verify_depth = undef,
104104
Enum['on', 'off', 'only'] $starttls = 'off',
105-
$protocol = undef,
105+
Optional[Enum['imap', 'pop3', 'smtp']] $protocol = undef,
106106
Optional[String] $auth_http = undef,
107107
Optional[String] $auth_http_header = undef,
108-
String $xclient = 'on',
108+
Enum['on', 'off'] $xclient = 'on',
109109
Optional[String] $imap_auth = undef,
110110
Optional[Array] $imap_capabilities = undef,
111111
Optional[String] $imap_client_buffer = undef,

manifests/resource/server.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
# }
155155
define nginx::resource::server (
156156
Enum['absent', 'present'] $ensure = 'present',
157-
Variant[Array, String] $listen_ip = '*',
157+
Nginx::Listen::V4 $listen_ip = '*',
158158
Integer $listen_port = 80,
159159
Optional[String] $listen_options = undef,
160160
Boolean $listen_unix_socket_enable = false,
@@ -164,7 +164,7 @@
164164
Array $location_allow = [],
165165
Array $location_deny = [],
166166
Boolean $ipv6_enable = false,
167-
Variant[Array, String] $ipv6_listen_ip = '::',
167+
Nginx::Listen::V6 $ipv6_listen_ip = '::',
168168
Integer $ipv6_listen_port = 80,
169169
String $ipv6_listen_options = 'default ipv6only=on',
170170
Hash $add_header = {},

manifests/resource/streamhost.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
# }
4949
define nginx::resource::streamhost (
5050
Enum['absent', 'present'] $ensure = 'present',
51-
Variant[Array, String] $listen_ip = '*',
52-
Integer $listen_port = 80,
51+
Nginx::Listen::V4 $listen_ip = '*',
52+
Stdlib::Port $listen_port = 80,
5353
Optional[String] $listen_options = undef,
5454
Boolean $ipv6_enable = false,
55-
Variant[Array, String] $ipv6_listen_ip = '::',
56-
Integer $ipv6_listen_port = 80,
55+
Nginx::Listen::V6 $ipv6_listen_ip = '::',
56+
Stdlib::Port $ipv6_listen_port = 80,
5757
String $ipv6_listen_options = 'default ipv6only=on',
5858
$proxy = undef,
5959
String $proxy_read_timeout = $nginx::proxy_read_timeout,

spec/defines/resource_mailhost_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@
9696
{
9797
title: 'should set protocol',
9898
attr: 'protocol',
99-
value: 'test-protocol',
100-
match: ' protocol test-protocol;'
99+
value: 'imap',
100+
match: ' protocol imap;'
101101
},
102102
{
103103
title: 'should set xclient',
104104
attr: 'xclient',
105-
value: 'test-xclient',
106-
match: ' xclient test-xclient;'
105+
value: 'off',
106+
match: ' xclient off;'
107107
},
108108
{
109109
title: 'should set auth_http',
@@ -533,14 +533,14 @@
533533
{
534534
title: 'should set protocol',
535535
attr: 'protocol',
536-
value: 'test-protocol',
537-
match: ' protocol test-protocol;'
536+
value: 'imap',
537+
match: ' protocol imap;'
538538
},
539539
{
540540
title: 'should set xclient',
541541
attr: 'xclient',
542-
value: 'test-xclient',
543-
match: ' xclient test-xclient;'
542+
value: 'off',
543+
match: ' xclient off;'
544544
},
545545
{
546546
title: 'should set auth_http',

spec/type_aliases/listen_v4_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
3+
describe 'Nginx::Listen::V4' do
4+
it { is_expected.to allow_value('*') }
5+
it { is_expected.to allow_value('127.0.0.1') }
6+
it { is_expected.to allow_value('192.0.2.1') }
7+
it { is_expected.to allow_value(['198.51.100.1', '203.0.113.1']) }
8+
it { is_expected.not_to allow_value('192.0.2.1/24') }
9+
it { is_expected.not_to allow_value('::') }
10+
it { is_expected.not_to allow_value('2001:db8::1') }
11+
end

spec/type_aliases/listen_v6_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
3+
describe 'Nginx::Listen::V4' do
4+
it { is_expected.to allow_value('::') }
5+
it { is_expected.to allow_value('::1') }
6+
it { is_expected.to allow_value('2001:db8::1') }
7+
it { is_expected.to allow_value(['2001:db8::1', '2001:0db8:ffff:ffff:ffff:ffff:ffff:ffff']) }
8+
it { is_expected.not_to allow_value('2001:db8::/64') }
9+
it { is_expected.not_to allow_value('192.0.2.1') }
10+
it { is_expected.not_to allow_value('*') }
11+
end

types/listen/v4.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Listen on IPv4 statement
2+
type Nginx::Listen::V4 = Variant[Enum['*'], Array[Stdlib::IP::Address::V4::Nosubnet], Stdlib::IP::Address::V4::Nosubnet]

types/listen/v6.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Listen on IPv6 statement
2+
type Nginx::Listen::V6 = Variant[Array[Stdlib::IP::Address::V6::Nosubnet], Stdlib::IP::Address::V6::Nosubnet]

0 commit comments

Comments
 (0)