Skip to content

Conversation

@towo
Copy link
Member

@towo towo commented Dec 22, 2021

Pull Request (PR) description

Introduces type aliases for all the classes.

Will remove type checking from the provider.

This Pull Request (PR) fixes the following issues

n/a

@towo towo force-pushed the master branch 2 times, most recently from 81df1fb to e9ef7f8 Compare December 23, 2021 19:39
@bastelfreak bastelfreak added the enhancement New feature or request label Dec 23, 2021
* Introduces type aliases for (most) variables to do some error checking.
* Fix examples given by the unit test helper to match expected values.
@towo towo marked this pull request as ready for review December 28, 2021 12:14
Copy link
Member

@smortex smortex left a comment

Choose a reason for hiding this comment

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

That looks gorgeous!

@kenyon
Copy link
Member

kenyon commented Dec 28, 2021

What about tests for the types?

@towo
Copy link
Member Author

towo commented Dec 28, 2021

What about tests for the types?

Good idea, I'll write up a couple tomorrow.

@towo towo marked this pull request as draft December 28, 2021 22:12
String $service_name = $bareos::client_service_name,
String $service_ensure = $bareos::service_ensure,
Boolean $service_enable = $bareos::service_enable,
String $config_dir = "${bareos::config_dir}/bareos-fd.d"
Copy link
Member

Choose a reason for hiding this comment

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

You probably want Stdlib::Absolutepath if this will also be an absolute path.

Boolean $manage_package = $bareos::manage_package,
Variant[String, Array[String]] $package_name = $bareos::client_package_name,
String $package_ensure = $bareos::package_ensure,
String $service_name = $bareos::client_service_name,
Copy link
Member

Choose a reason for hiding this comment

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

You probably want String[1] unless the code specifically is meant to handle empty strings ''

# @summary Size definition
# @author Tobias @towo Wolter <[email protected]>
# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatypesize
type Bareos::Size = Pattern[/(?i:^(\d+(\.\d+)?)\W*(k|kb|m|mb|g|gb)$)/]
Copy link
Member

Choose a reason for hiding this comment

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

These regular expressions should have comments that explain what they are attempting to match.

Copy link
Member

Choose a reason for hiding this comment

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

And for this you can borrow some tests in the bacula module 😉 :
https://github.com/xaque208/puppet-bacula/blob/master/spec/type_aliases/size_spec.rb

@bastelfreak
Copy link
Member

@towo can you please rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants