k0s icon indicating copy to clipboard operation
k0s copied to clipboard

left-pad helm chart filenames with 0s to fix sorting

Open laverya opened this issue 4 months ago • 6 comments

Description

Fixes # (issue)

Currently, helm chart apply order is determined by sorting the helm chart manifest filenames. The order is included as the first element in the filename, resulting in names like 1_helm_extension_chartname.yaml.

Manifests are fetched here, which uses filepath.Glob, which calls sort on the results.

Unfortunately, this breaks at 10 - 10_helm_extension_anothername.yaml is alphabetically before 1_helm_extension_chartname.yaml.

This PR adds a fmt directive to left-pad these integers to 9 digits, which allows sorting to work properly - see https://go.dev/play/p/THZg3TD6eHI.

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Documentation update

How Has This Been Tested?

  • [ ] Manual test
  • [ ] Auto test added

Checklist:

  • [ ] My code follows the style guidelines of this project
  • [x] My commit messages are signed-off
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] My changes generate no new warnings
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes
  • [ ] Any dependent changes have been merged and published in downstream modules
  • [x] I have checked my code and corrected any misspellings

laverya avatar Feb 21 '24 21:02 laverya