Skip to content

Commit

Permalink
Add missing datatypes to all parameters
Browse files Browse the repository at this point in the history
It's a bit tricky to figure out valid datatypes for the existing
parameters. But by just setting them to `Optional`, it enables us to
enforce types via puppet-lint, which ensures that all new parameters
have datatypes.
  • Loading branch information
bastelfreak committed Oct 30, 2024
1 parent 697f2d5 commit 7081f2f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 57 deletions.
1 change: 0 additions & 1 deletion .puppet-lint.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

--fail-on-warnings
--no-parameter_types-check
1 change: 1 addition & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ spec/spec_helper.rb:
.puppet-lint.rc:
enabled_lint_checks:
- parameter_documentation
- parameter_types
56 changes: 28 additions & 28 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,47 +642,47 @@ The following parameters are available in the `consul::check` defined type:

##### <a name="-consul--check--ensure"></a>`ensure`

Data type: `Any`
Data type: `Enum['absent', 'present']`

Define availability of check. Use 'absent' to remove existing checks

Default value: `present`

##### <a name="-consul--check--http"></a>`http`

Data type: `Any`
Data type: `Optional`

HTTP endpoint for the service healthcheck

Default value: `undef`

##### <a name="-consul--check--id"></a>`id`

Data type: `Any`
Data type: `String[1]`

The id for the check (defaults to $title)

Default value: `$title`

##### <a name="-consul--check--interval"></a>`interval`

Data type: `Any`
Data type: `Optional`

Value in seconds for the interval between runs of the check

Default value: `undef`

##### <a name="-consul--check--notes"></a>`notes`

Data type: `Any`
Data type: `Optional`

Human readable description of the check

Default value: `undef`

##### <a name="-consul--check--script"></a>`script`

Data type: `Any`
Data type: `Optional`

Full path to the location of the healthcheck script. Must be nagios
compliant with regards to the return codes. This parameter is deprecated
Expand All @@ -692,79 +692,79 @@ Default value: `undef`

##### <a name="-consul--check--args"></a>`args`

Data type: `Any`
Data type: `Optional`

Arguments to be `exec`ed for the healthcheck script.

Default value: `undef`

##### <a name="-consul--check--service_id"></a>`service_id`

Data type: `Any`
Data type: `Optional`

An optional service_id to match this check against

Default value: `undef`

##### <a name="-consul--check--status"></a>`status`

Data type: `Any`
Data type: `Optional`

The default state of the check when it is registered against a consul agent. Should be either "critical" or "passing"

Default value: `undef`

##### <a name="-consul--check--tcp"></a>`tcp`

Data type: `Any`
Data type: `Optional`

The IP/hostname and port for the service healthcheck. Should be in 'hostname:port' format.

Default value: `undef`

##### <a name="-consul--check--grpc"></a>`grpc`

Data type: `Any`
Data type: `Optional`

GRPC endpoint for the service healthcheck

Default value: `undef`

##### <a name="-consul--check--timeout"></a>`timeout`

Data type: `Any`
Data type: `Optional`

A timeout value for HTTP request only

Default value: `undef`

##### <a name="-consul--check--token"></a>`token`

Data type: `Any`
Data type: `Optional`

ACL token for interacting with the catalog (must be 'management' type)

Default value: `undef`

##### <a name="-consul--check--ttl"></a>`ttl`

Data type: `Any`
Data type: `Optional`

Value in seconds before the http endpoint considers a failing healthcheck to be "HARD" down.

Default value: `undef`

##### <a name="-consul--check--success_before_passing"></a>`success_before_passing`

Data type: `Any`
Data type: `Optional`

Value may be set to become check passing only after a specified number of consecutive checks return passing

Default value: `undef`

##### <a name="-consul--check--failures_before_critical"></a>`failures_before_critical`

Data type: `Any`
Data type: `Optional`

Value may be set to become check critical only after a specified number of consecutive checks return critical

Expand Down Expand Up @@ -969,55 +969,55 @@ The following parameters are available in the `consul::watch` defined type:

##### <a name="-consul--watch--datacenter"></a>`datacenter`

Data type: `Any`
Data type: `Optional`

String overriding consul's default datacenter.

Default value: `undef`

##### <a name="-consul--watch--ensure"></a>`ensure`

Data type: `Any`
Data type: `Optional`

Define availability of watch. Use 'absent' to remove existing watches.

Default value: `present`

##### <a name="-consul--watch--event_name"></a>`event_name`

Data type: `Any`
Data type: `Optional`

Name of an event to watch for.

Default value: `undef`

##### <a name="-consul--watch--handler"></a>`handler`

Data type: `Any`
Data type: `Optional`

Full path to the script that will be excuted. This parameter is deprecated in Consul 1.0.0

Default value: `undef`

##### <a name="-consul--watch--args"></a>`args`

Data type: `Any`
Data type: `Optional`

Arguments to be `exec`ed for the watch.

Default value: `undef`

##### <a name="-consul--watch--key"></a>`key`

Data type: `Any`
Data type: `Optional`

Watch a specific key.

Default value: `undef`

##### <a name="-consul--watch--keyprefix"></a>`keyprefix`

Data type: `Any`
Data type: `Optional`

Watch a whole keyprefix

Expand All @@ -1033,39 +1033,39 @@ Default value: `undef`

##### <a name="-consul--watch--service"></a>`service`

Data type: `Any`
Data type: `Optional`

Watch a particular service

Default value: `undef`

##### <a name="-consul--watch--service_tag"></a>`service_tag`

Data type: `Any`
Data type: `Optional`

This actually maps to the "tag" param for service watches. (`tag` is a puppet builtin metaparameter)

Default value: `undef`

##### <a name="-consul--watch--state"></a>`state`

Data type: `Any`
Data type: `Optional`

Watch a state change on a service healthcheck.

Default value: `undef`

##### <a name="-consul--watch--token"></a>`token`

Data type: `Any`
Data type: `Optional`

String to override the default token.

Default value: `undef`

##### <a name="-consul--watch--type"></a>`type`

Data type: `Any`
Data type: `Optional`

Type of data to watch. (Like key, service, services, nodes)

Expand Down
32 changes: 16 additions & 16 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@
# @param failures_before_critical Value may be set to become check critical only after a specified number of consecutive checks return critical
#
define consul::check (
$ensure = present,
$http = undef,
$id = $title,
$interval = undef,
$notes = undef,
$script = undef,
$args = undef,
$service_id = undef,
$status = undef,
$tcp = undef,
$grpc = undef,
$timeout = undef,
$token = undef,
$ttl = undef,
$success_before_passing = undef,
$failures_before_critical = undef,
Enum['absent', 'present'] $ensure = present,
Optional $http = undef,
String[1] $id = $title,
Optional $interval = undef,
Optional $notes = undef,
Optional $script = undef,
Optional $args = undef,
Optional $service_id = undef,
Optional $status = undef,
Optional $tcp = undef,
Optional $grpc = undef,
Optional $timeout = undef,
Optional $token = undef,
Optional $ttl = undef,
Optional $success_before_passing = undef,
Optional $failures_before_critical = undef,
) {
include consul

Expand Down
24 changes: 12 additions & 12 deletions manifests/watch.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
# @param type Type of data to watch. (Like key, service, services, nodes)
#
define consul::watch (
$args = undef,
$datacenter = undef,
$ensure = present,
$event_name = undef,
$handler = undef,
$key = undef,
$keyprefix = undef,
Optional $args = undef,
Optional $datacenter = undef,
Optional $ensure = present,

Check warning on line 24 in manifests/watch.pp

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Optional parameter defaults to something other than undef (check: optional_default)
Optional $event_name = undef,
Optional $handler = undef,
Optional $key = undef,
Optional $keyprefix = undef,
Optional[Boolean] $passingonly = undef,
$service = undef,
$service_tag = undef,
$state = undef,
$token = undef,
$type = undef,
Optional $service = undef,
Optional $service_tag = undef,
Optional $state = undef,
Optional $token = undef,
Optional $type = undef,
) {
include consul
$id = $title
Expand Down

0 comments on commit 7081f2f

Please sign in to comment.