Skip to content

fix: clean configured chart dirs before matching chart directories - #878

Open
RaphaelFakhri wants to merge 1 commit into
helm:mainfrom
RaphaelFakhri:fix/lookup-chart-dir-clean-path
Open

RaphaelFakhri wants to merge 1 commit into
helm:mainfrom
RaphaelFakhri:fix/lookup-chart-dir-clean-path

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

What this PR does / why we need it:

LookupChartDir compares the cleaned parent of a candidate chart directory (filepath.Dir) with the configured chart directory, but only strips trailing slashes from the configured value. When --chart-dirs (or chart-dirs in ct.yaml) is written as ./charts, the comparison is charts == ./charts, which never matches. As a result:

  • ct list-changed, ct lint and ct install print Directory "charts/foo" is not a valid chart directory. Skipping... for every changed chart and report no changes.
  • ct lint --all finds no charts and still prints All charts linted successfully, so CI passes without linting anything.

This change cleans the configured chart dir with filepath.Clean, so equivalent spellings such as ./charts and charts/ match. It adds TestLookupChartDir covering the plain, trailing-slash and leading ./ forms.

Reproduction on main (repository with charts/foo and a committed change to charts/foo/values.yaml):

$ ct list-changed --chart-dirs charts
charts/foo
$ ct list-changed --chart-dirs ./charts
Directory "charts/foo" is not a valid chart directory. Skipping...

With this change, both commands print charts/foo.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #877

Special notes for your reviewer:

This is one cause of the "not a valid chart directory" reports in #226, #315 and #633, which were closed by the stale bot. Absolute chart dirs and Windows path separators are separate causes and are not addressed here.

LookupChartDir compares the cleaned parent of a candidate chart directory
with the configured chart directory, but only stripped trailing slashes
from the configured value. A chart dir written as "./charts" therefore
never matched "charts", so every changed chart was reported as "not a
valid chart directory" and skipped, and --all found no charts at all
while still reporting success.

Clean the configured chart dir with filepath.Clean so equivalent spellings
such as "./charts" and "charts/" match.

Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--chart-dirs ./charts skips every chart as "not a valid chart directory"

1 participant