helmfile/pkg/app/testdata
Aditya Menon c63947483c
fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410)
* fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution

The sequential code path used within() → os.Chdir() to change the
process-wide working directory when processing helmfile.d files.
This broke relative environment variable paths (e.g. KUBECONFIG=kubeconfig.yaml)
because they resolved from the wrong directory after chdir.

Replace the chdir-based approach with the same baseDir parameter pattern
used by the parallel code path, passing explicit directory context through
loadDesiredStateFromYamlWithBaseDir() instead of mutating global process state.

Closes #2409

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>

* fix: restore within() for single-file sequential to preserve chart path format

The previous approach used baseDir for all sequential processing, which
changed chart path format in output (e.g. from "../../../../charts/raw"
to "test/integration/charts/raw"). This broke integration tests that
compare chart paths in expected output.

Now the sequential branch uses two strategies:
- Single file: use os.Chdir via within() to preserve backward-compatible
  relative chart paths in output
- Multiple files with --sequential-helmfiles: use baseDir parameter to
  avoid os.Chdir, fixing relative env var paths like KUBECONFIG (#2409)

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>

* fix: revert e2e snapshot outputs to match within() behavior

The previous commit restored within() for single-file sequential
processing, which produces relative chart paths (e.g. ../../charts/raw)
and filename-only FilePath. Revert the e2e snapshot expected outputs
to match main branch since single-file behavior is now identical.

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>

* fix: restructure integration test for multi-file sequential processing

- Point -f at helmfile.d/ directly (not parent dir) so findDesiredStateFiles
  discovers the yaml files
- Add second helmfile to trigger baseDir path (len > 1)
- Inline environment config to avoid base file relative path issues
- Verify both releases appear in output instead of comparing with parallel
  (which may differ in ordering)

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>

* fix: reduce cognitive complexity and improve accuracy of sequential helmfiles

Replace inline visitSubHelmfiles closure with calls to the existing
processNestedHelmfiles() method, matching the parallel path. This
eliminates duplicated nested logic and reduces gocognit complexity
below the CI threshold of 110. Also fixes help text and docs to
accurately describe that single-file processing still uses within(),
and adds kubeContext verification to the integration test.

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>

* test: validate kubeContext resolution in sequential helmfiles integration test

Restructure the integration test to replicate the exact user scenario
from issue #2409:
  - Multiple files in helmfile.d/ using bases: with relative paths
    (../bases/) for environments and defaults
  - Environment values set kubeContext via .Environment.Values
  - helmDefaults.kubeContext rendered from gotmpl
  - Local chart references (../../../../charts/raw) from helmfile.d/
  - Run diff against the minikube cluster to exercise kubeContext
    resolution, which would fail with "context does not exist" if
    os.Chdir() broke relative path resolution
  - Also verify template output for both releases and relative values
    file (values/common.yaml) resolution

Fix normalizeChart() in util.go to be idempotent — skip re-prefixing
when the chart path already starts with basePath. This prevents
double-prefixing of local chart paths (e.g. helmfile.d/test/.../raw)
when normalizeChart is called multiple times (once during chart
preparation and again during diff/sync).

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>

---------

Signed-off-by: Aditya Menon <amenon@canarytechnologies.com>
2026-02-22 09:21:46 +08:00
..
app_diff_test fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
app_diff_test_1 fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
app_diff_test_2 fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
app_lint_test fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
app_list_test fix: array merge regression - layer arrays now replace defaults (#2367) 2026-01-18 14:04:54 +08:00
app_template_test fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
app_unittest_test fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
dag_test fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
formatters 🐛 Fix four critical issues: environment merging, kubeVersion detection, lookup() with kustomize, and Helm 4 color flags (#2276) 2025-11-21 08:32:54 +08:00
testapply fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
testapply_2 fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
testapply_3 fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
testapply_hooks add NAMESPACE filed for diff (#1460) 2024-04-18 17:43:59 +08:00
testdeps/smoke fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
testdestroy fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
testdestroy_2 fix: eliminate os.Chdir in sequential helmfiles to fix relative path resolution (#2410) 2026-02-22 09:21:46 +08:00
testreadfromyaml_rendertemplatelog fix: array merge regression - layer arrays now replace defaults (#2367) 2026-01-18 14:04:54 +08:00