Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

b4ldr
Copy link
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
spec/functions/stdlib_ensure_spec.rb Outdated Show resolved Hide resolved
functions/ensure.pp Outdated Show resolved Hide resolved
ekohl
ekohl previously approved these changes Dec 14, 2022
Copy link
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.

spec/functions/stdlib_ensure_spec.rb Outdated Show resolved Hide resolved
@b4ldr
Copy link
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
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
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
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
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