Skip to content

Conversation

@james-nesbitt
Copy link
Collaborator

@james-nesbitt james-nesbitt commented Oct 13, 2025

  • go-version no longer throws a runtime error on invalid versions, so we can drop our custom error catch version detection function

NOTE

What is this: we had issues when we first started analyzing the mcr version in
the configuration, as some invalid values would produce a runtime error. The
error came right out of hashicorps go-version library, so our only option
was to wrap the function and catch any runtime errors.
We also included a unit test which validated that a proper error was returned
on the invalid version value, to confirm in unit testing that the runtime
error was caught

Why isn't it needed anymore: I ran the go-version function recently without the
wrapper and found that the runtime exception no longer occurs, meaning that
our wrapper is no longer needed. The unit test now runs without exception
without the wrapper.
Additionally, the go-version code now properly handles CalVer values,
which may have leading zeroes in values.

- go-version no longer throws a runtime error on invalid versions, so we
  can drop our custom error catch version detection function

NOTE

What is this: we had issues when we first started analyzing the mcr version in
    the configuration, as some invalid values would produce a runtime error. The
    error came right out of hashicorps go-version library, so our only option
    was to wrap the function and catch any runtime errors.

    We also included a unit test which validated that a proper error was returned
    on the invalid version value, to confirm in unit testing that the runtime
    error was caught

Why isn't it needed anymore: I ran the go-version function recently without the
    wrapper and found that the runtime exception no longer occurs, meaning that
    our wrapper is no longer needed.  The unit test now runs without exception
    without the wrapper.

Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
@james-nesbitt
Copy link
Collaborator Author

https://github.com/Mirantis/launchpad/blob/main/pkg/product/common/api/mcr_config_validate_test.go#L53

Here is the unit test which used to throw a runtime exception/error.

@james-nesbitt james-nesbitt merged commit 41712d7 into main Oct 13, 2025
8 checks passed
@james-nesbitt james-nesbitt deleted the PRODENG-3148-mcr-version-detect-cleanup branch October 13, 2025 08:16
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.

2 participants