-
Notifications
You must be signed in to change notification settings - Fork 459
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
Eliminate params.pp
and create_resources()
#1172
Conversation
kenyon
commented
Apr 9, 2024
- init: trim trailing whitespace
- init, source: improve hash formatting
- eliminate params.pp and create_resources()
- regenerate REFERENCE.md
The $auth_conf_tmp line should be multiple lines for readability and easier to read diffs when changes occur. Double-indented blocks look wrong. Placing the opening bracket on its own line fixes this.
3044a63
to
cb843a2
Compare
params.pp and create_resources() are obsolete. This module was converted to non-params.pp style puppetlabs#667, but was reverted in puppetlabs#680. Using Hiera in modules and no params.pp are the preferred styles these days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Not sure if we want to improve data types in the same PR, so feel free to mark suggestions as resolved if you think it is out-of-scope!
Hash $update_defaults = { | ||
'frequency' => 'reluctantly', | ||
'loglevel' => undef, | ||
'timeout' => undef, | ||
'tries' => undef, | ||
}, | ||
Hash $purge_defaults = { | ||
'sources.list' => false, | ||
'sources.list.d' => false, | ||
'preferences' => false, | ||
'preferences.d' => false, | ||
'apt.conf.d' => false, | ||
}, | ||
Hash $proxy_defaults = { | ||
'ensure' => undef, | ||
'host' => undef, | ||
'port' => 8080, | ||
'https' => false, | ||
'https_acng' => false, | ||
'direct' => false, | ||
}, | ||
Hash $include_defaults = { | ||
'deb' => true, | ||
'src' => false, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of Hash
maybe we can have custom types which Struct to validate both keys and values?
E.g. something like (untested):
# types/include.pp
type Apt::Include = Struct[
Optional[deb] => Boolean,
Optional[src] => Boolean,
]
# manifests/init.pp
Apt::Include $include_defaults = {
'deb' => true,
'src' => false,
},
'deb' => true, | ||
'src' => false, | ||
}, | ||
String $provider = '/usr/bin/apt-get', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stdlib::Absolutepath
might be more suitable (some more bellow)
String $provider = '/usr/bin/apt-get', | ||
String $keyserver = 'keyserver.ubuntu.com', | ||
Optional[String] $key_options = undef, | ||
Optional[Array[String]] $ppa_options = undef, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is generally more simple to have these parameters as:
Optional[Array[String]] $ppa_options = undef, | |
Array[String] $ppa_options = [], |
'src' => false, | ||
}, | ||
String $provider = '/usr/bin/apt-get', | ||
String $keyserver = 'keyserver.ubuntu.com', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty string is an error, so we can set a lower bound.
String $keyserver = 'keyserver.ubuntu.com', | |
String[1] $keyserver = 'keyserver.ubuntu.com', |