Skip to content

Commit 1f68053

Browse files
committed
Change validation to use data type annotations
This requires more work to add depreciations to the current hodge-podge, to tighten down what is allowed. Many of the unchecked edge-cases will result in a broken ntp config anyways, but just fixing it would elevate issues in this area from broken ntp service to broken catalog.
1 parent 41915a0 commit 1f68053

File tree

2 files changed

+49
-47
lines changed

2 files changed

+49
-47
lines changed

.fixtures.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
fixtures:
22
repositories:
3-
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
3+
stdlib:
4+
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
5+
ref: 'experiments/validate-compat-type-aliases'
46
symlinks:
57
"ntp": "#{source_dir}"
68
"my_ntp": "#{source_dir}/spec/fixtures/my_ntp"

manifests/init.pp

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
class ntp (
22
$autoupdate,
3-
$broadcastclient,
4-
$config,
5-
$config_dir,
3+
Stdlib::Compat::Bool $broadcastclient,
4+
Stdlib::Compat::Absolute_path $config,
5+
Variant[Any, Undef, Stdlib::Compat::Absolute_path] $config_dir,
66
$config_file_mode,
7-
$config_template,
8-
$disable_auth,
9-
$disable_dhclient,
10-
$disable_kernel,
11-
$disable_monitor,
12-
$fudge,
13-
$driftfile,
14-
$leapfile,
15-
$logfile,
16-
$iburst_enable,
17-
$keys,
18-
$keys_enable,
7+
Stdlib::Compat::String $config_template,
8+
Stdlib::Compat::Bool $disable_auth,
9+
Stdlib::Compat::Bool $disable_dhclient,
10+
Stdlib::Compat::Bool $disable_kernel,
11+
Stdlib::Compat::Bool $disable_monitor,
12+
Stdlib::Compat::Array $fudge,
13+
Stdlib::Compat::Absolute_path $driftfile,
14+
Variant[Boolean, Undef, Stdlib::Compat::Absolute_path] $leapfile,
15+
Variant[Boolean, Undef, Stdlib::Compat::Absolute_path] $logfile,
16+
Stdlib::Compat::Bool $iburst_enable,
17+
Stdlib::Compat::Array $keys,
18+
Stdlib::Compat::Bool $keys_enable,
1919
$keys_file,
20-
$keys_controlkey,
21-
$keys_requestkey,
22-
$keys_trusted,
23-
$minpoll,
24-
$maxpoll,
25-
$package_ensure,
26-
$package_manage,
27-
$package_name,
28-
$panic = $ntp::params::panic,
29-
$peers,
30-
$preferred_servers,
31-
$restrict,
32-
$interfaces,
20+
Variant[Pattern['^\d+$'], Pattern['']] $keys_controlkey,
21+
Variant[Pattern['^\d+$'], Pattern['']] $keys_requestkey,
22+
Stdlib::Compat::Array $keys_trusted,
23+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $minpoll,
24+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $maxpoll,
25+
Stdlib::Compat::String $package_ensure,
26+
Stdlib::Compat::Bool $package_manage,
27+
Stdlib::Compat::Array $package_name,
28+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $panic = $ntp::params::panic,
29+
Stdlib::Compat::Array $peers,
30+
Stdlib::Compat::Array $preferred_servers,
31+
Stdlib::Compat::Array $restrict,
32+
Stdlib::Compat::Array $interfaces,
3333
$interfaces_ignore,
34-
$servers,
35-
$service_enable,
36-
$service_ensure,
37-
$service_manage,
38-
$service_name,
34+
Stdlib::Compat::Array $servers,
35+
Stdlib::Compat::Bool $service_enable,
36+
Stdlib::Compat::String $service_ensure,
37+
Stdlib::Compat::Bool $service_manage,
38+
Stdlib::Compat::String $service_name,
3939
$service_provider,
40-
$stepout,
41-
$step_tickers_file,
42-
$step_tickers_template,
43-
$tinker = $ntp::params::tinker,
44-
$tos,
45-
$tos_minclock,
46-
$tos_minsane,
47-
$tos_floor,
48-
$tos_ceiling,
49-
$tos_cohort,
50-
$udlc,
40+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $stepout,
41+
Variant[Boolean, Undef, Stdlib::Compat::String] $step_tickers_file,
42+
Variant[Any, Undef, Stdlib::Compat::String] $step_tickers_template,
43+
Stdlib::Compat::Bool $tinker = $ntp::params::tinker,
44+
Stdlib::Compat::Bool $tos,
45+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_minclock,
46+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_minsane,
47+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_floor,
48+
Variant[Boolean, Undef, Stdlib::Compat::Numeric] $tos_ceiling,
49+
Variant[Boolean, Undef, Pattern['^[0|1]$']] $tos_cohort,
50+
Stdlib::Compat::Bool $udlc,
5151
$udlc_stratum,
52-
$ntpsigndsocket,
53-
$authprov,
52+
Variant[Boolean, Undef, Stdlib::Compat::Absolute_path] $ntpsigndsocket,
53+
Variant[Any, Undef, Stdlib::Compat::String] $authprov,
5454
) inherits ntp::params {
5555

5656
validate_bool($broadcastclient)

0 commit comments

Comments
 (0)