Skip to content

Commit

Permalink
Use stdlib::ensure
Browse files Browse the repository at this point in the history
  • Loading branch information
baurmatt committed Mar 7, 2024
1 parent 5f60418 commit 7f63dfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,9 @@
}

if $_target {
$_ensure = $ensure ? {
'absent' => 'absent',
default => 'link',
}
$_ensure = stdlib::ensure($ensure, 'link')
} else {
$_ensure = $ensure ? {
'present' => 'file',
default => $ensure,
}
$_ensure = stdlib::ensure($ensure, 'file')
}

file { "${path}/${name}":
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 10.0.0"
"version_requirement": ">= 6.6.0 < 10.0.0"
},
{
"name": "puppetlabs/inifile",
Expand Down

3 comments on commit 7f63dfa

@cocker-cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baurmatt:

$ensure accepts file:

define systemd::unit_file (
  Enum['present', 'absent', 'file']        $ensure    = 'present',
…
    $_ensure = stdlib::ensure($ensure, 'link')

but stdlib::ensure() does not accept file!

@baurmatt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocker-cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You referenced Line 6.
But in Line 5 there is

Variant[Boolean, Enum['present', 'absent']] $ensure,

and that means, $ensure does not accept file.

Please sign in to comment.