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

Eliminate params.pp and create_resources() #1172

Merged
merged 4 commits into from
Jun 14, 2024

Conversation

kenyon
Copy link

@kenyon 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.
@kenyon kenyon requested review from bastelfreak, smortex and a team as code owners April 9, 2024 06:13
@kenyon kenyon mentioned this pull request Apr 9, 2024
@kenyon kenyon marked this pull request as draft April 9, 2024 06:22
@kenyon kenyon force-pushed the modernization branch 3 times, most recently from 3044a63 to cb843a2 Compare April 9, 2024 06:43
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.
@kenyon kenyon marked this pull request as ready for review April 9, 2024 07:07
Copy link
Collaborator

@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.

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!

Comment on lines +152 to +176
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,
},
Copy link
Collaborator

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',
Copy link
Collaborator

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,
Copy link
Collaborator

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:

Suggested change
Optional[Array[String]] $ppa_options = undef,
Array[String] $ppa_options = [],

'src' => false,
},
String $provider = '/usr/bin/apt-get',
String $keyserver = 'keyserver.ubuntu.com',
Copy link
Collaborator

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.

Suggested change
String $keyserver = 'keyserver.ubuntu.com',
String[1] $keyserver = 'keyserver.ubuntu.com',

@kenyon
Copy link
Author

kenyon commented Apr 9, 2024

@smortex thanks for the review! Working on data types in #1174.

@Ramesh7 Ramesh7 merged commit 5a709c9 into puppetlabs:main Jun 14, 2024
16 of 18 checks passed
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.

4 participants