Skip to content

(CONT-361) Syntax update #1397

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 2 commits into from
Feb 24, 2023
Merged

(CONT-361) Syntax update #1397

merged 2 commits into from
Feb 24, 2023

Conversation

LukasAud
Copy link
Contributor

@LukasAud LukasAud commented Feb 8, 2023

Code is now compliant with rules regarding:

parameter datatypes
parameter documentation

@LukasAud LukasAud self-assigned this Feb 8, 2023
@LukasAud LukasAud force-pushed the CONT-361-Syntax_update branch from 399cfd7 to 5ae2e79 Compare February 8, 2023 15:56
@LukasAud LukasAud marked this pull request as ready for review February 8, 2023 15:56
@LukasAud LukasAud requested a review from a team as a code owner February 8, 2023 15:56
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.

This looks great!

I tested these changes with onceover with our control-repo configuration to check for regressions and found a backward incompatible changes with the new validation.

The puppetlabs-puppetdb module setup a postgresql::server::db with grant => 'all' (sic):

https://github.com/puppetlabs/puppetlabs-puppetdb/blob/437e1c60c62113865c1b8f340fcbf325fa147a6f/manifests/database/postgresql.pp#L74-L78

The puppetlabs-postgresql module copy the value of the grant parameter to the privilege parameter of a postgresql::server::database_grant defined type:

postgresql::server::database_grant { "GRANT ${user} - ${grant} - ${dbname}":
privilege => $grant,
db => $dbname,
role => $user,
} -> Postgresql_conn_validator<| db_name == $dbname |>

The new code validates that privilege parameter against the type Enum['ALL', 'CREATE', 'CONNECT', 'TEMPORARY', 'TEMP']. The case does not match (Enum is case sensitive) and an error is reported:

  errors:
    Evaluation Error: Error while evaluating a Resource Statement, Postgresql::Server::Database_grant[GRANT puppetdb - all - puppetdb]: parameter 'privilege' expects a match for Enum['ALL', 'CONNECT', 'CREATE', 'TEMP', 'TEMPORARY'], got 'all'
      file: modules/postgresql/manifests/server/db.pp
      line: 47
      factsets: Ubuntu-18.4-64
    Evaluation Error: Error while evaluating a Resource Statement, Postgresql::Server::Database_grant[GRANT puppetdb - all - puppetdb]: parameter 'privilege' expects a match for Enum['ALL', 'CONNECT', 'CREATE', 'TEMP', 'TEMPORARY'], got 'all'
      file: modules/postgresql/manifests/server/db.pp
      line: 47
      factsets: Debian-11-64
    Evaluation Error: Error while evaluating a Resource Statement, Postgresql::Server::Database_grant[GRANT puppetdb - all - puppetdb]: parameter 'privilege' expects a match for Enum['ALL', 'CONNECT', 'CREATE', 'TEMP', 'TEMPORARY'], got 'all'
      file: modules/postgresql/manifests/server/db.pp
      line: 47
      factsets: Debian-10-64
    Evaluation Error: Error while evaluating a Resource Statement, Postgresql::Server::Database_grant[GRANT puppetdb - all - puppetdb]: parameter 'privilege' expects a match for Enum['ALL', 'CONNECT', 'CREATE', 'TEMP', 'TEMPORARY'], got 'all'
      file: modules/postgresql/manifests/server/db.pp
      line: 47
      factsets: CentOS-7.6-64

@SimonHoenscheid
Copy link
Collaborator

Great work, this module has been missing data types for a long time! I added a few review comments.

@LukasAud
Copy link
Contributor Author

New commit. Have adjusted the PR to implement some suggestions.

Optional[String[1]] $package_name = undef,
Optional[String[1]] $post_script = undef,
Optional[String[1]] $pre_script = undef,
String[1] $dir,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll note I hate alignment on data types since it creates so much noise in the git log. The old style was much better IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understandable. However, we are currently favouring a more 'readable' and structured style.

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't help code readability much, but it makes diffs harder to read and review. +1 for not doing alignment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd even argue it's less readable if you have a long type (like the version you wrote for the package ensure) there is a lot of whitespace, so it becomes hard to see which data types belong to which variables.

Copy link
Member

Choose a reason for hiding this comment

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

Personally I find it best for when I have to search out a specific variable in the list, especially for larger modules that have upwards of a dozen.
I've always found it easier to track down that one that I'm looking for.

@LukasAud LukasAud force-pushed the CONT-361-Syntax_update branch from 7e2f6ba to 621f337 Compare February 15, 2023 16:48
Code is now compliant with rules regarding:

parameter datatypes
@LukasAud LukasAud force-pushed the CONT-361-Syntax_update branch from 9278196 to e522f51 Compare February 16, 2023 17:30
@david22swan david22swan merged commit a809d9b into main Feb 24, 2023
@david22swan david22swan deleted the CONT-361-Syntax_update branch February 24, 2023 14:35
jordanbreen28 pushed a commit that referenced this pull request May 2, 2023
This commit adds functionality to allow an array of $listen_addresses to
be specified as a string containing a comma-seperated list of addresses,
which was removed unintentioanlly in #1397.

Fixes #1426.
jordanbreen28 pushed a commit that referenced this pull request May 2, 2023
This commit adds functionality to allow an array of $listen_addresses to
be specified as a string containing a comma-seperated list of addresses,
which was removed unintentioanlly in #1397.

Fixes #1426.
vaol pushed a commit to vaol/puppetlabs-postgresql that referenced this pull request Oct 13, 2024
This commit adds functionality to allow an array of $listen_addresses to
be specified as a string containing a comma-seperated list of addresses,
which was removed unintentioanlly in puppetlabs#1397.

Fixes puppetlabs#1426.
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.

6 participants