Skip to content

Commit 74e022d

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 74e022d

File tree

8 files changed

+36
-32
lines changed

8 files changed

+36
-32
lines changed

REFERENCE.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@
6464

6565
### <a name="puppet_agent"></a>`puppet_agent`
6666

67-
example for clients in dmz:s that need to use proxy to reach the repo
68-
provided by puppetserver.
67+
Upgrades Puppet 4 and newer to the requested version.
6968

7069
#### Parameters
7170

@@ -343,6 +342,8 @@ Default value: `[]`
343342
Data type: `Optional`
344343

345344
This is to be able to configure yum-repo with proxy, needed for
345+
example for clients in DMZs that need to use proxy to reach the repo
346+
provided by puppetserver.
346347

347348
Default value: `undef`
348349

@@ -388,15 +389,15 @@ The following parameters are available in the `puppet_agent::install` class:
388389

389390
##### <a name="-puppet_agent--install--package_version"></a>`package_version`
390391

391-
Data type: `String`
392+
Data type: `Optional[String]`
392393

393394
The puppet-agent version to install.
394395

395-
Default value: `'present'`
396+
Default value: `undef`
396397

397398
##### <a name="-puppet_agent--install--install_dir"></a>`install_dir`
398399

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

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

406407
##### <a name="-puppet_agent--install--install_options"></a>`install_options`
407408

408-
Data type: `Array`
409+
Data type: `Optional[Array]`
409410

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

418-
Default value: `[]`
419+
Default value: `undef`
419420

420421
### <a name="puppet_agent--install--darwin"></a>`puppet_agent::install::darwin`
421422

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

431432
##### <a name="-puppet_agent--install--darwin--package_version"></a>`package_version`
432433

433-
Data type: `Optional`
434+
Data type: `String`
434435

435436
The puppet-agent version to install.
436437

437438
##### <a name="-puppet_agent--install--darwin--install_options"></a>`install_options`
438439

439-
Data type: `Array`
440+
Data type: `Optional[Array]`
440441

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

449-
Default value: `[]`
450+
Default value: `undef`
450451

451452
### <a name="puppet_agent--install--solaris"></a>`puppet_agent::install::solaris`
452453

@@ -461,13 +462,13 @@ The following parameters are available in the `puppet_agent::install::solaris` c
461462

462463
##### <a name="-puppet_agent--install--solaris--package_version"></a>`package_version`
463464

464-
Data type: `Optional`
465+
Data type: `String`
465466

466467
The puppet-agent version to install.
467468

468469
##### <a name="-puppet_agent--install--solaris--install_options"></a>`install_options`
469470

470-
Data type: `Array`
471+
Data type: `Optional[Array]`
471472

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

480-
Default value: `[]`
481+
Default value: `undef`
481482

482483
### <a name="puppet_agent--install--suse"></a>`puppet_agent::install::suse`
483484

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

493494
##### <a name="-puppet_agent--install--suse--package_version"></a>`package_version`
494495

495-
Data type: `Optional`
496+
Data type: `String`
496497

497498
The puppet-agent version to install.
498499

499500
##### <a name="-puppet_agent--install--suse--install_options"></a>`install_options`
500501

501-
Data type: `Array`
502+
Data type: `Optional[Array]`
502503

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

512-
Default value: `[]`
513+
Default value: `undef`
513514

514515
### <a name="puppet_agent--install--windows"></a>`puppet_agent::install::windows`
515516

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

609610
##### <a name="-puppet_agent--prepare--package--source"></a>`source`
610611

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

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

615617
### <a name="puppet_agent--prepare--puppet_config"></a>`puppet_agent::prepare::puppet_config`
616618

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

625627
##### <a name="-puppet_agent--prepare--puppet_config--package_version"></a>`package_version`
626628

627-
Data type: `Optional`
629+
Data type: `String`
628630

629631
The puppet-agent version to install.
630632

manifests/init.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@
9595
# This parameter is constrained to managing only a predetermined set of configuration
9696
# settings, e.g. runinterval.
9797
# @param proxy
98-
# This is to be able to configure yum-repo with proxy, needed for
99-
# example for clients in dmz:s that need to use proxy to reach the repo
98+
# This is to be able to configure yum-repo with proxy, needed for
99+
# example for clients in DMZs that need to use proxy to reach the repo
100100
# provided by puppetserver.
101101
# @param version_file_path
102102
# The default install path for the VERSION file

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)