Fix kubernetes_version matching #705
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the Puppet case expression that selects the correct Kubernetes API template version based on
$kubernetes_version
Previously, the regex patterns were too permissive and matched unintended substrings (e.g., 1.31.12 was incorrectly matching /1.12/).
The updated implementation ensures that matching occurs strictly on the major.minor portion of the version string, following the format X.Y.Z.
Changes
Anchored regex patterns with
^
to ensure the version string starts with1.
Improved readability by grouping valid minor versions explicitly.
Example of the updated logic:
Additional Context
Root cause: Regex patterns were too broad, leading to false positives when the patch version contained substrings like 12.
Steps to reproduce:
Set
$kubernetes_version = '1.31.12'
→ previously matched v1alpha3.After fix → correctly resolves to v1beta3.
Thought process:
Instead of substring matches, I anchor on start-of-string
^
to ensure the regex only evaluates against major.minor.