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

Onceover show Puppetfile - Add versionomy support for DSC module version format #328

Merged

Conversation

chambersmp
Copy link
Contributor

@chambersmp chambersmp commented Jun 9, 2023

Addresses the issue of #324 and includes error handling from #325.

When checking comparing version numbers of current and latest modules, the DSC modules have extra characters which are unhandled by the standard version format in Versionomy.

Error while running: #<Versionomy::Errors::ParseError: Extra characters: "-2">

Summary:
The DSC modules on Puppet forge use a version number that is currently unsupported by the standard version format in Versionomy.
When Versionomy parses the version format 8.5.0-0-2, the -2 suffix is considered extra_character which results in stderr. This PR proposes using a custom format to add support for the field patchlevel_minor via the delimiter -.

The standard version format supports [major, minor, tiny, patchlevel] [8, 5, 0, 0] (e.g. 8.5.0-0)
The proposed custom_format supports [major, minor, tiny, patchlevel, patchlevel_minor] [8, 5, 0, 0, 2] (e.g. 8.5.0-0-2)

The custom format uses - as the delimiter for the patchlevel_minor field. Additional support could be added later for . or other varieties. Simply updating the regex_delimiter from (-) to (-|.) will add this support.

This PR also includes the error handling from PR #325 to handle and flag any other version exceptions that may be unsupported by Versionomy default formats.

Testing:
The sample puppetfile and onceover show puppetfileoutput demonstrates the benefits of the custom_format and error handling.

  • DSC modules are now supported
  • Outdated Patchlevel and patchlevel_minor versions are now checked
  • Errors are handled and presented in a table format without terminating the command.
  • onceover update puppetfile can now auto correct the badly formatted versions
# sample puppetfile
forge 'https://forge.puppet.com'

# Added Puppet Forge DSC Version Format
mod 'dsc-activedirectorydsc', '6.2.0-0-2' 

# Examples of unsupported formats
mod 'dsc-securitypolicydsc', '2.10.0-0.3'
mod 'dsc-computermanagementdsc', '8.5.0-0-0-0'

Output: onceover show puppetfile

+------------------------+-----------------+----------------+------------------+-------------+---------------+
| Full Name              | Current Version | Latest Version | Out of Date?     | Endorsement | Superseded by |
+------------------------+-----------------+----------------+------------------+-------------+---------------+
| dsc-activedirectorydsc | 6.2.0-0-0       | 6.2.0-0-2      | PatchLevel_minor | supported   |               |
+------------------------+-----------------+----------------+------------------+-------------+---------------+
+---------------------------+---------------+------------+--------------------------+
| Issue assessing module    | Current       | Latest     | Error                    |
+---------------------------+---------------+------------+--------------------------+
| dsc-computermanagementdsc | 8.5.0-0-0-0-0 | 8.5.0-0-2  | Extra characters: "-0-0" |
| dsc-securitypolicydsc     | 2.10.0-0.3    | 2.10.0-0-5 | Extra characters: ".3"   |
+---------------------------+---------------+------------+--------------------------+

After onceover update puppetfile
All modules have been updated to the latest version, all poorly formed versions have been replaced.

+---------------------------+-----------------+----------------+--------------+-------------+---------------+
| Full Name                 | Current Version | Latest Version | Out of Date? | Endorsement | Superseded by |
+---------------------------+-----------------+----------------+--------------+-------------+---------------+
| dsc-activedirectorydsc    | 6.2.0-0-2       | 6.2.0-0-2      | No           | supported   |               |
| dsc-computermanagementdsc | 8.5.0-0-2       | 8.5.0-0-2      | No           | supported   |               |
| dsc-securitypolicydsc     | 2.10.0-0-5      | 2.10.0-0-5     | No           | supported   |               |
+---------------------------+-----------------+----------------+--------------+-------------+---------------+

@the-yorkshire-allen
Copy link

This is a more robust solution to #325 and should be included over my implementation.

@the-yorkshire-allen
Copy link

@dylanratcliffe Could you spend a little time reviewing some one these Pull requests? I know you're busy with Onceover :)

@dylanratcliffe
Copy link
Collaborator

Hey sorry about how dark the repo has gone since work on Overmind took off. I've schedule a few hours on Saturday to review as much as I can 👍

@the-yorkshire-allen
Copy link

the-yorkshire-allen commented Jun 15, 2023

Awesome, thanks @dylanratcliffe . I actually meant Overmind, not Onceover. Stop naming things beginning with O.

@dylanratcliffe dylanratcliffe merged commit fc2fa26 into voxpupuli:master Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants