Skip to content

Chore/stackittpr 739 change semver library - #1627

Open
cgoetz-inovex wants to merge 3 commits into
mainfrom
chore/STACKITTPR-739-change-semver-library
Open

Chore/stackittpr 739 change semver library#1627
cgoetz-inovex wants to merge 3 commits into
mainfrom
chore/STACKITTPR-739-change-semver-library

Conversation

@cgoetz-inovex

@cgoetz-inovex cgoetz-inovex commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

I've used the mastermind semver library, since we already had it in our transitive deps

  • original implementation worked with KubernetesVersion and MachineImageVersion
    structs
  • from both types the version and state fields were used during version
    selection
  • introduced interface VersionWithState to cover both cases
  • introduce helper funcs for working with this interface: toVersionWithState,
    sortVersions, isDeprecated, isPreview, isSupported
  • consolidated getLatestSupportedMachineVersion and
    getLatestSupportedKubernetesVersion into getLatestSupportedVersion
  • test cases for these two functions were the same with the only
    difference being the type
  • consolidated TestGetLatestSupportedKubernetesVersion and
    TestGetLatestSupportedMachineVersion into TestGetLatestSupportedVersion
  • convert to VersionWithState early in call tree
  • extracted common parts into latestMatchingVersion
  • replace regex check for full version and selectFullVersion
    selectMatchingVersion with constraint and single selectVersion
  • move calculation of available out of selectVersion and into error
    branch, when no version could be found

relates to #1234

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

- original implementation worked with KubernetesVersion and MachineImageVersion
  structs
- from both types the version and state fields were used during version
  selection
- introduced interface VersionWithState to cover both cases
- introduce helper funcs for working with this interface: toVersionWithState,
  sortVersions, isDeprecated, isPreview, isSupported
- consolidated getLatestSupportedMachineVersion and
  getLatestSupportedKubernetesVersion into getLatestSupportedVersion
- test cases for these two functions were the same with the only
  difference being the type
- consolidated TestGetLatestSupportedKubernetesVersion and
  TestGetLatestSupportedMachineVersion into TestGetLatestSupportedVersion
- convert to VersionWithState early in call tree
- extracted common parts into latestMatchingVersion
- replace regex check for full version and selectFullVersion
  selectMatchingVersion with constraint and single selectVersion
- move calculation of available out of selectVersion and into error
  branch, when no version could be found
@cgoetz-inovex
cgoetz-inovex requested a review from a team as a code owner July 29, 2026 14:04
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/ske/cluster 45.15% (-3.22%) 👎
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate 97.20% (-0.10%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/ske/cluster/resource.go 47.23% (-3.21%) 847 (-65) 400 (-60) 447 (-5) 👎
github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate/validate.go 97.17% (-0.10%) 106 (-4) 103 (-4) 3 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/ske/cluster/resource_test.go

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.

1 participant