Skip to content

Commit e0835f8

Browse files
committed
(CONT-353) Syntax update
Code now compliant with the following rules: relative_classname_inclusion relative_classname_reference parameter_documentation parameter_types
1 parent 3f1be34 commit e0835f8

23 files changed

+156
-166
lines changed

.puppet-lint.rc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
--relative
2-
--no-top_scope_facts-check
3-
--no-parameter_types-check
4-
--no-relative_classname_inclusion-check
5-
--no-parameter_documentation-check
6-
--no-legacy_facts-check
72
--no-anchor_resource-check
8-
--no-topscope_variable-check

.sync.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Gemfile:
1313
- gem: github_changelog_generator
1414
Rakefile:
1515
changelog_user: puppetlabs
16+
extra_disabled_lint_checks:
17+
- anchor_resource
1618
spec/spec_helper.rb:
1719
mock_with: ":rspec"
1820
coverage_report: true
@@ -33,12 +35,3 @@ spec/spec_helper.rb:
3335
unmanaged: false
3436
.travis.yml:
3537
delete: true
36-
Rakefile:
37-
extra_disabled_lint_checks:
38-
- top_scope_facts
39-
- parameter_types
40-
- relative_classname_inclusion
41-
- parameter_documentation
42-
- legacy_facts
43-
- anchor_resource
44-
- topscope_variable

Rakefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ def changelog_future_release
4242
end
4343

4444
PuppetLint.configuration.send('disable_relative')
45-
PuppetLint.configuration.send('disable_top_scope_facts')
46-
PuppetLint.configuration.send('disable_parameter_types')
47-
PuppetLint.configuration.send('disable_relative_classname_inclusion')
48-
PuppetLint.configuration.send('disable_parameter_documentation')
49-
PuppetLint.configuration.send('disable_legacy_facts')
5045
PuppetLint.configuration.send('disable_anchor_resource')
51-
PuppetLint.configuration.send('disable_topscope_variable')
52-
5346

5447
if Bundler.rubygems.find_name('github_changelog_generator').any?
5548
GitHubChangelogGenerator::RakeTask.new :changelog do |config|

examples/init.pp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Declare haproxy base class with configuration options
2-
class { '::haproxy':
2+
class { 'haproxy':
33
enable => true,
44
global_options => {
5-
'log' => "${::ipaddress} local0",
5+
'log' => "${$facts['networking']['ip']} local0",
66
'chroot' => '/var/lib/haproxy',
77
'pidfile' => '/var/run/haproxy.pid',
88
'maxconn' => '4000',
@@ -33,8 +33,8 @@
3333
@@haproxy::balancermember { $fqdn:
3434
order => '21',
3535
listening_service => 'puppet00',
36-
server_name => $::hostname,
37-
balancer_ip => $::ipaddress,
36+
server_name => $facts['networking']['hostname'],
37+
balancer_ip => $facts['networking']['ip'],
3838
balancer_port => '8140',
3939
balancermember_options => 'check',
4040
}
@@ -45,7 +45,7 @@
4545
# Haproxy::Balancermember <<| listening_service == $name |>>
4646
haproxy::listen { 'puppet00':
4747
order => '20',
48-
ipaddress => $::ipaddress,
48+
ipaddress => $facts['networking']['ip'],
4949
ports => '18140',
5050
options => {
5151
'option' => [

manifests/backend.pp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@
7070
# Jeremy Kitchen <[email protected]>
7171
#
7272
define haproxy::backend (
73-
$mode = undef,
74-
$collect_exported = true,
75-
$options = {
73+
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
74+
Boolean $collect_exported = true,
75+
Variant[Hash, Array[Hash]] $options = {
7676
'balance' => 'roundrobin',
7777
},
78-
$instance = 'haproxy',
79-
$section_name = $name,
80-
$sort_options_alphabetic = undef,
81-
$description = undef,
82-
$defaults = undef,
78+
String $instance = 'haproxy',
79+
String[1] $section_name = $name,
80+
Boolean $sort_options_alphabetic = true,
81+
Optional[String] $description = undef,
82+
Optional[String] $defaults = undef,
8383
Optional[Stdlib::Absolutepath] $config_file = undef,
8484
) {
8585
if defined(Haproxy::Listen[$section_name]) {

manifests/balancermember.pp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,24 @@
135135
# (this resource can be declared anywhere)
136136
#
137137
define haproxy::balancermember (
138-
$listening_service,
139-
Enum['server', 'default-server', 'server-template'] $type = 'server',
140-
$ports = undef,
141-
$port = undef,
142-
$server_names = $::hostname,
143-
$ipaddresses = $::ipaddress,
144-
$prefix = 'server',
145-
$amount = '1',
146-
$fqdn = '',
147-
$options = '',
148-
$define_cookies = false,
149-
$instance = 'haproxy',
150-
$defaults = undef,
151-
Optional[Stdlib::Absolutepath] $config_file = undef,
152-
$verifyhost = false,
153-
$weight = undef,
138+
String $listening_service,
139+
Enum['server', 'default-server', 'server-template'] $type = 'server',
140+
Optional[Variant[Array, String]] $ports = undef,
141+
Optional[Variant[String]] $port = undef,
142+
Variant[String[1], Array] $server_names = $hostname,
143+
Variant[String, Array] $ipaddresses = $ipaddress,
144+
String $prefix = 'server',
145+
String $amount = '1',
146+
Optional[String] $fqdn = undef,
147+
Optional[Variant[String, Array]] $options = undef,
148+
Boolean $define_cookies = false,
149+
String $instance = 'haproxy',
150+
Optional[String] $defaults = undef,
151+
Optional[Stdlib::Absolutepath] $config_file = undef,
152+
Boolean $verifyhost = false,
153+
Optional[Variant[String, Integer]] $weight = undef,
154154
) {
155-
include ::haproxy::params
155+
include haproxy::params
156156

157157
if $instance == 'haproxy' {
158158
$instance_name = 'haproxy'

manifests/config.pp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
# @api private
44
define haproxy::config (
55
# lint:ignore:140chars
6-
$instance_name,
7-
$config_file,
8-
$global_options,
9-
$defaults_options,
10-
$package_ensure,
11-
$chroot_dir_manage,
12-
$config_dir = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
13-
$custom_fragment = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
14-
$merge_options = $haproxy::merge_options,
15-
$config_validate_cmd = $haproxy::config_validate_cmd,
6+
String $instance_name,
7+
Stdlib::Absolutepath $config_file,
8+
Hash $global_options,
9+
Hash $defaults_options,
10+
String[1] $package_ensure,
11+
Boolean $chroot_dir_manage,
12+
Stdlib::Absolutepath $config_dir = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
13+
Optional[String] $custom_fragment = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed. << Update 15/12/22 This still needs a default.
14+
Boolean $merge_options = $haproxy::merge_options,
15+
Variant[Stdlib::Absolutepath, String] $config_validate_cmd = $haproxy::config_validate_cmd,
1616
# lint:endignore
1717
) {
1818
if $caller_module_name != $module_name {
@@ -59,12 +59,8 @@
5959
mode => '0640',
6060
}
6161

62-
# validate_cmd introduced in Puppet 3.5
63-
if ((!defined('$::puppetversion') or (versioncmp($::puppetversion, '3.5') >= 0)) and
64-
(!defined('$::serverversion') or versioncmp($::serverversion, '3.5') >= 0)) {
65-
Concat[$_config_file] {
66-
validate_cmd => $config_validate_cmd,
67-
}
62+
Concat[$_config_file] {
63+
validate_cmd => $config_validate_cmd,
6864
}
6965

7066
# Simple Header

manifests/defaults.pp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
# Optional. Defaults to 'haproxy'.
2121
#
2222
define haproxy::defaults (
23-
$options = {},
24-
$sort_options_alphabetic = undef,
25-
$instance = 'haproxy',
23+
Hash $options = {},
24+
Boolean $sort_options_alphabetic = true,
25+
String $instance = 'haproxy',
2626
) {
2727
if $instance == 'haproxy' {
28-
include ::haproxy
28+
include haproxy
2929
$instance_name = 'haproxy'
3030
$config_file = $haproxy::config_file
3131
} else {
32-
include ::haproxy::params
32+
include haproxy::params
3333
$instance_name = "haproxy-${instance}"
3434
$config_file = inline_template($haproxy::params::config_file_tmpl)
3535
}
36-
include ::haproxy::globals
36+
include haproxy::globals
3737
$_sort_options_alphabetic = pick($sort_options_alphabetic, $haproxy::globals::sort_options_alphabetic)
3838

3939
concat::fragment { "${instance_name}-${name}_defaults_block":

manifests/frontend.pp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@
9191
# Gary Larizza <[email protected]>
9292
#
9393
define haproxy::frontend (
94-
$ports = undef,
95-
$ipaddress = undef,
96-
Optional[Hash] $bind = undef,
97-
$mode = undef,
98-
$collect_exported = true,
99-
$options = {
100-
'option' => [
94+
Optional[Variant[Array, String]] $ports = undef,
95+
Optional[Variant[String, Array]] $ipaddress = undef,
96+
Optional[Hash] $bind = undef,
97+
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
98+
Boolean $collect_exported = true,
99+
Variant[Hash, Array[Hash]] $options = {
100+
'option' => [
101101
'tcplog',
102102
],
103103
},
104-
$instance = 'haproxy',
105-
$section_name = $name,
106-
$sort_options_alphabetic = undef,
107-
$description = undef,
108-
$defaults = undef,
109-
$defaults_use_backend = true,
110-
Optional[Stdlib::Absolutepath] $config_file = undef,
104+
String $instance = 'haproxy',
105+
String[1] $section_name = $name,
106+
Boolean $sort_options_alphabetic = true,
107+
Optional[String] $description = undef,
108+
Optional[String] $defaults = undef,
109+
Boolean $defaults_use_backend = true,
110+
Optional[Stdlib::Absolutepath] $config_file = undef,
111111
# Deprecated
112-
$bind_options = '',
112+
Optional[Array] $bind_options = undef,
113113
) {
114114
if $ports and $bind {
115115
fail('The use of $ports and $bind is mutually exclusive, please choose either one')
@@ -121,7 +121,7 @@
121121
warning('The $bind_options parameter is deprecated; please use $bind instead')
122122
}
123123

124-
include ::haproxy::params
124+
include haproxy::params
125125

126126
if $instance == 'haproxy' {
127127
$instance_name = 'haproxy'

manifests/init.pp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,20 @@
127127
Boolean $chroot_dir_manage = true,
128128
String $service_name = $haproxy::params::service_name,
129129
String $service_options = $haproxy::params::service_options,
130-
$sysconfig_options = $haproxy::params::sysconfig_options,
130+
String $sysconfig_options = $haproxy::params::sysconfig_options,
131131
Hash $global_options = $haproxy::params::global_options,
132132
Hash $defaults_options = $haproxy::params::defaults_options,
133133
Boolean $merge_options = $haproxy::params::merge_options,
134-
$restart_command = undef,
135-
$custom_fragment = undef,
134+
Optional[String] $restart_command = undef,
135+
Optional[String] $custom_fragment = undef,
136136
Stdlib::Absolutepath $config_dir = $haproxy::params::config_dir,
137137
Optional[Stdlib::Absolutepath] $config_file = $haproxy::params::config_file,
138-
$manage_config_dir = $haproxy::params::manage_config_dir,
139-
$config_validate_cmd = $haproxy::params::config_validate_cmd,
138+
Boolean $manage_config_dir = $haproxy::params::manage_config_dir,
139+
Variant[Stdlib::Absolutepath, String] $config_validate_cmd = $haproxy::params::config_validate_cmd,
140140

141141
# Deprecated
142-
$manage_service = undef,
143-
$enable = undef,
142+
Optional[Boolean] $manage_service = undef,
143+
Optional[Boolean] $enable = undef,
144144
) inherits haproxy::params {
145145
# NOTE: These deprecating parameters are implemented in this class,
146146
# not in haproxy::instance. haproxy::instance is new and therefore

manifests/install.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# @api private
44
define haproxy::install (
55
# lint:ignore:140chars
6-
$package_ensure,
7-
$package_name = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
6+
String[1] $package_ensure,
7+
Optional[String] $package_name = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
88
# lint:endignore
99
) {
1010
if $caller_module_name != $module_name {

manifests/instance.pp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,18 @@
167167
Optional[String] $service_name = undef,
168168
Optional[Hash] $global_options = undef,
169169
Optional[Hash] $defaults_options = undef,
170-
$restart_command = undef,
171-
$custom_fragment = undef,
172-
$config_dir = undef,
170+
Optional[String] $restart_command = undef,
171+
Optional[String] $custom_fragment = undef,
172+
Optional[Stdlib::Absolutepath] $config_dir = undef,
173173
Optional[Stdlib::Absolutepath] $config_file = undef,
174-
$config_validate_cmd = $haproxy::params::config_validate_cmd,
175-
$merge_options = $haproxy::params::merge_options,
176-
$service_options = $haproxy::params::service_options,
177-
$sysconfig_options = $haproxy::params::sysconfig_options,
174+
Variant[Stdlib::Absolutepath, String] $config_validate_cmd = $haproxy::params::config_validate_cmd,
175+
Boolean $merge_options = $haproxy::params::merge_options,
176+
String $service_options = $haproxy::params::service_options,
177+
String $sysconfig_options = $haproxy::params::sysconfig_options,
178178
) {
179179
# Since this is a 'define', we can not use 'inherts haproxy::params'.
180180
# Therefore, we "include haproxy::params" for any parameters we need.
181-
include ::haproxy::params
181+
include haproxy::params
182182

183183
$_global_options = pick($global_options, $haproxy::params::global_options)
184184
$_defaults_options = pick($defaults_options, $haproxy::params::defaults_options)

manifests/instance_service.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
# @param haproxy_init_source
3838
# The init.d script that will start/restart/reload this instance.
3939
#
40+
# @param haproxy_unit_template
41+
# The template that will be used to create an unit file.
42+
#
4043
define haproxy::instance_service (
4144
Optional[String] $haproxy_init_source = undef,
4245
String $haproxy_unit_template = 'haproxy/instance_service_unit.erb',

manifests/listen.pp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,25 @@
9494
# Gary Larizza <[email protected]>
9595
#
9696
define haproxy::listen (
97-
$ports = undef,
98-
$ipaddress = undef,
99-
Optional[Hash] $bind = undef,
100-
$mode = undef,
101-
$collect_exported = true,
102-
$options = {
103-
'option' => [
97+
Optional[Variant[Array, String]] $ports = undef,
98+
Optional[Variant[String, Array]] $ipaddress = undef,
99+
Optional[Hash] $bind = undef,
100+
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
101+
Boolean $collect_exported = true,
102+
Variant[Hash, Array[Hash]] $options = {
103+
'option' => [
104104
'tcplog',
105105
],
106-
'balance' => 'roundrobin',
106+
'balance' => 'roundrobin',
107107
},
108-
$instance = 'haproxy',
109-
$section_name = $name,
110-
$sort_options_alphabetic = undef,
111-
$description = undef,
112-
$defaults = undef,
113-
Optional[Stdlib::Absolutepath] $config_file = undef,
108+
String $instance = 'haproxy',
109+
String[1] $section_name = $name,
110+
Boolean $sort_options_alphabetic = true,
111+
Optional[String] $description = undef,
112+
Optional[String] $defaults = undef,
113+
Optional[Stdlib::Absolutepath] $config_file = undef,
114114
# Deprecated
115-
$bind_options = '',
115+
Optional[Array] $bind_options = undef,
116116
) {
117117
if $ports and $bind {
118118
fail('The use of $ports and $bind is mutually exclusive, please choose either one')
@@ -131,7 +131,7 @@
131131
fail("An haproxy::backend resource was discovered with the same name (${section_name}) which is not supported")
132132
}
133133

134-
include ::haproxy::params
134+
include haproxy::params
135135

136136
if $instance == 'haproxy' {
137137
$instance_name = 'haproxy'

0 commit comments

Comments
 (0)