Skip to content

stdlib::ensure: new fuction to cast ensure values #1150

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

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

b4ldr
Copy link
Collaborator

@b4ldr b4ldr commented Dec 16, 2020

This PR adds a new function to cast the ensureable property to a resource

specific value. e.g.

  • stdlib::ensure('present', 'service') == 'running'
  • stdlib::ensure('present', 'directory') == 'directory'

This is useful when you want to pass ensure to a custom class and
ensure all the resource get the correct value e.g.

class foo(
  Enum['present', 'absent'] $ensure = 'present'
) {
  file {'/some/dir':
    ensure => stdlib::ensure($ensure, 'directory')
  }
  file {'/some/file':
    ensure => stdlib::ensure($ensure, 'file')
  }
  file {'/some/link':
    ensure => stdlib::ensure($ensure, 'link')
  }
  service {'some-service':
    ensure => stdlib::ensure($ensure, 'service')
  }
}

something similar to this was discussed in #869

@b4ldr b4ldr requested a review from a team as a code owner December 16, 2020 16:04
@b4ldr
Copy link
Collaborator Author

b4ldr commented Dec 16, 2020

The travis-ci failures seem unrelated to this change

This CR adds a new function to case the ensureable property to a resource
specific value. e.g.
  * stdlib::ensure('present', 'service') == 'running'
  * stdlib::ensure('present', 'directory') == 'directory'
This is usefull when you want to pass ensure to a custome class and
ensure all the resource get the correct value e.g.

```
class foo(
  Enum['present', 'absent'] $ensure = 'present'
) {
  file {'/some/dir':
    ensure => stdlib::ensure($ensure, 'directory')
  }
  file {'/some/file':
    ensure => stdlib::ensure($ensure, 'file')
  }
  file {'/some/link':
    ensure => stdlib::ensure($ensure, 'link')
  }
  service {'some-service':
    ensure => stdlib::ensure($ensure, 'service')
  }
```

something similar to this was discussed in puppetlabs#869
Copy link
Contributor

@pmcmaw pmcmaw left a comment

Choose a reason for hiding this comment

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

I firstly want to congratulate you on writing our first ever function in Puppet language for this module!

And I then want to thank you for taking the time. We always love to see community contributions and this function is pretty cool.

:-)

@pmcmaw pmcmaw merged commit 4afec18 into puppetlabs:main Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants