voxpupuli / onceover

Your gateway drug to automated infrastructure testing with Puppet
Apache License 2.0
142 stars 45 forks source link

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

Closed chambersmp closed 1 year ago

chambersmp commented 1 year ago

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.

# 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 commented 1 year ago

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

the-yorkshire-allen commented 1 year ago

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

dylanratcliffe commented 1 year ago

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 commented 1 year ago

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