Skip to content

stdlib::ensure: update function to support the generic case#1286

Merged
LukasAud merged 1 commit intopuppetlabs:mainfrom
b4ldr:ensure_generic
Dec 19, 2022
Merged

stdlib::ensure: update function to support the generic case#1286
LukasAud merged 1 commit intopuppetlabs:mainfrom
b4ldr:ensure_generic

Conversation

@b4ldr
Copy link
Copy Markdown
Collaborator

@b4ldr b4ldr commented Dec 9, 2022

Often custom resources only support present/absent for the ensure parameter and often the inclusion of theses resources are enabled via some boolean value as such i often find my self using the following pattern

$ensure_feature = $enable_feature.bool2str('ensure', 'present')

This patch updates the stdlib::ensure function so we can simplify this to

$ensure_feature = $enable_feature.stdlib::ensure   # or ...
$ensure_feature = stdlib::ensure($enable_feature) 

@b4ldr b4ldr requested a review from a team as a code owner December 9, 2022 12:12
Comment thread spec/functions/stdlib_ensure_spec.rb Outdated
Comment thread functions/ensure.pp Outdated
ekohl
ekohl previously approved these changes Dec 14, 2022
Copy link
Copy Markdown
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Would you mind squashing the commits?

I'd also appreciate if someone else took a look since I suggested the implementation.

Comment thread spec/functions/stdlib_ensure_spec.rb Outdated
@b4ldr
Copy link
Copy Markdown
Collaborator Author

b4ldr commented Dec 14, 2022

Would you mind squashing the commits?

done

I'd also appreciate if someone else took a look since I suggested the implementation.

sure no rush my end

Copy link
Copy Markdown
Contributor

@kenyon kenyon left a comment

Choose a reason for hiding this comment

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

Would be good to fix the typo in the PR title and commit message, spport :)

@b4ldr b4ldr changed the title stdlib::ensure: update function to spport the generic case stdlib::ensure: update function to support the generic case Dec 15, 2022
Often custom resources only support present/absent for the ensure
parameter and often the inclusion of theses resources are enabled via
some boolean value as such i often find my self using the following
pattern

 $ensure_feature = $enable_feature.bool2str('ensure', 'present')

This patch updates the stdlib::ensure function so we can simplify this to

 $ensure_feature = $enable_feature.stdlib::ensure   # or ...
 $ensure_feature = stdlib::ensure($enable_feature)

Update spec/functions/stdlib_ensure_spec.rb

Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>

Update spec/functions/stdlib_ensure_spec.rb

Co-authored-by: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
@b4ldr
Copy link
Copy Markdown
Collaborator Author

b4ldr commented Dec 15, 2022

Would be good to fix the typo in the PR title and commit message, spport :)

done

@b4ldr b4ldr requested a review from kenyon December 15, 2022 13:18
Copy link
Copy Markdown
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

In this repository Puppet's module team needs to approve before it can be merged.

Copy link
Copy Markdown
Contributor

@LukasAud LukasAud left a comment

Choose a reason for hiding this comment

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

LGTM

@LukasAud LukasAud merged commit a5ef0c9 into puppetlabs:main Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants