Skip to content

Commit 4415e16

Browse files
committed
(maint) Update optional parameters
As part of 404df9d all parameters in this module were assigned a data type. However, some required parameters were mistakenly classed as Optional and vice-versa. Puppet's documentation states "If a class parameter lacks a default value, the parameter is considered required."[1] This commit updates all parameters with default values to Optional (and whatever other relevant data type) and all parameters without default value as required. The REFERENCE.md has been updated to reflect these changes. Additionally, this commit updates all Optional parameters be set as undef, as suggested by the optional_default puppet-lint check. [1] https://www.puppet.com/docs/puppet/7/lang_classes#class-parameters-and-variables
1 parent ffc0575 commit 4415e16

File tree

7 files changed

+28
-25
lines changed

7 files changed

+28
-25
lines changed

REFERENCE.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ The following parameters are available in the `puppet_agent::install` class:
388388

389389
##### <a name="-puppet_agent--install--package_version"></a>`package_version`
390390

391-
Data type: `String`
391+
Data type: `Optional[String]`
392392

393393
The puppet-agent version to install.
394394

395-
Default value: `'present'`
395+
Default value: `undef`
396396

397397
##### <a name="-puppet_agent--install--install_dir"></a>`install_dir`
398398

399-
Data type: `Optional`
399+
Data type: `Optional[[Stdlib::Absolutepath]]`
400400

401401
The directory the puppet agent should be installed to. This is only applicable for
402402
windows operating systems.
@@ -405,7 +405,7 @@ Default value: `undef`
405405

406406
##### <a name="-puppet_agent--install--install_options"></a>`install_options`
407407

408-
Data type: `Array`
408+
Data type: `Optional[Array]`
409409

410410
An array of additional options to pass when installing puppet-agent. Each option in
411411
the array can either be a string or a hash. Each option will automatically be quoted
@@ -415,7 +415,7 @@ the installation command, forward slashes won't be automatically converted like
415415
are in `file` resources.) Note also that backslashes in double-quoted strings _must_
416416
be escaped and backslashes in single-quoted strings _can_ be escaped.
417417

418-
Default value: `[]`
418+
Default value: `undef`
419419

420420
### <a name="puppet_agent--install--darwin"></a>`puppet_agent::install::darwin`
421421

@@ -430,13 +430,13 @@ The following parameters are available in the `puppet_agent::install::darwin` cl
430430

431431
##### <a name="-puppet_agent--install--darwin--package_version"></a>`package_version`
432432

433-
Data type: `Optional`
433+
Data type: `String`
434434

435435
The puppet-agent version to install.
436436

437437
##### <a name="-puppet_agent--install--darwin--install_options"></a>`install_options`
438438

439-
Data type: `Array`
439+
Data type: `Optional[Array]`
440440

441441
An array of additional options to pass when installing puppet-agent. Each option in
442442
the array can either be a string or a hash. Each option will automatically be quoted
@@ -446,7 +446,7 @@ the installation command, forward slashes won't be automatically converted like
446446
are in `file` resources.) Note also that backslashes in double-quoted strings _must_
447447
be escaped and backslashes in single-quoted strings _can_ be escaped.
448448

449-
Default value: `[]`
449+
Default value: `undef`
450450

451451
### <a name="puppet_agent--install--solaris"></a>`puppet_agent::install::solaris`
452452

@@ -492,13 +492,13 @@ The following parameters are available in the `puppet_agent::install::suse` clas
492492

493493
##### <a name="-puppet_agent--install--suse--package_version"></a>`package_version`
494494

495-
Data type: `Optional`
495+
Data type: `String`
496496

497497
The puppet-agent version to install.
498498

499499
##### <a name="-puppet_agent--install--suse--install_options"></a>`install_options`
500500

501-
Data type: `Array`
501+
Data type: `Optional[Array]`
502502

503503
An array of additional options to pass when installing puppet-agent.
504504
Each option in the array can either be a string or a hash.
@@ -509,7 +509,7 @@ command, forward slashes won't be automatically converted like they are in
509509
`file` resources.) Note also that backslashes in double-quoted strings
510510
_must_ be escaped and backslashes in single-quoted strings _can_ be escaped.
511511

512-
Default value: `[]`
512+
Default value: `undef`
513513

514514
### <a name="puppet_agent--install--windows"></a>`puppet_agent::install::windows`
515515

@@ -608,9 +608,10 @@ The following parameters are available in the `puppet_agent::prepare::package` c
608608

609609
##### <a name="-puppet_agent--prepare--package--source"></a>`source`
610610

611-
Data type: `Optional`
612-
611+
Data type: `Variant[String, Array]`
613612

613+
The source file for the puppet-agent package. Can use any of the data types
614+
and protocols that the File resource's source attribute can.
614615

615616
### <a name="puppet_agent--prepare--puppet_config"></a>`puppet_agent::prepare::puppet_config`
616617

@@ -624,7 +625,7 @@ The following parameters are available in the `puppet_agent::prepare::puppet_con
624625

625626
##### <a name="-puppet_agent--prepare--puppet_config--package_version"></a>`package_version`
626627

627-
Data type: `Optional`
628+
Data type: `String`
628629

629630
The puppet-agent version to install.
630631

manifests/install.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# are in `file` resources.) Note also that backslashes in double-quoted strings _must_
1515
# be escaped and backslashes in single-quoted strings _can_ be escaped.
1616
class puppet_agent::install (
17-
String $package_version = 'present',
18-
Optional $install_dir = undef,
19-
Array $install_options = [],
17+
Optional[String] $package_version = undef,
18+
Optional[[Stdlib::Absolutepath]] $install_dir = undef,
19+
Optional[Array] $install_options = undef,
2020
) {
2121
assert_private()
2222

manifests/install/darwin.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# are in `file` resources.) Note also that backslashes in double-quoted strings _must_
1313
# be escaped and backslashes in single-quoted strings _can_ be escaped.
1414
class puppet_agent::install::darwin (
15-
Optional $package_version,
16-
Array $install_options = [],
15+
String $package_version,
16+
Optional[Array] $install_options = undef,
1717
) {
1818
assert_private()
1919
$install_script = 'osx_install.sh.erb'

manifests/install/solaris.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# are in `file` resources.) Note also that backslashes in double-quoted strings _must_
1313
# be escaped and backslashes in single-quoted strings _can_ be escaped.
1414
class puppet_agent::install::solaris (
15-
Optional $package_version,
16-
Array $install_options = [],
15+
String $package_version,
16+
Optional[Array] $install_options = undef,
1717
) {
1818
assert_private()
1919
if $facts['os']['release']['major'] == '10' {

manifests/install/suse.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# `file` resources.) Note also that backslashes in double-quoted strings
1414
# _must_ be escaped and backslashes in single-quoted strings _can_ be escaped.
1515
class puppet_agent::install::suse (
16-
Optional $package_version,
17-
Array $install_options = [],
16+
String $package_version,
17+
Optional[Array] $install_options = undef,
1818
) {
1919
assert_private()
2020

manifests/prepare/package.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# working with a remote https repository.
44
#
55
# @param source
6+
# The source file for the puppet-agent package. Can use any of the data types
7+
# and protocols that the File resource's source attribute can.
68
class puppet_agent::prepare::package (
7-
Optional $source,
9+
Variant[String, Array] $source,
810
) {
911
assert_private()
1012

manifests/prepare/puppet_config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @param package_version
44
# The puppet-agent version to install.
55
class puppet_agent::prepare::puppet_config (
6-
Optional $package_version,
6+
String $package_version,
77
) {
88
assert_private()
99
$puppetconf = $puppet_agent::params::config

0 commit comments

Comments
 (0)