From a7a655ca865616825102d04dea78e6a0e276c1d0 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Tue, 6 Aug 2024 20:58:38 -0700 Subject: [PATCH] Fix issue with collecting OCIRepositories during diff (#772) Adding additional repository examples, but they don't reproduce the issue. --- flux_local/tool/diff.py | 6 +++++- .../flux/apps/cloudflare/release.yaml | 19 +++++++++++++++++++ .../cluster7/flux/charts/app-template.yaml | 14 ++++++++++++++ tests/tool/__snapshots__/test_get_hr.ambr | 5 +++-- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 tests/testdata/cluster7/flux/apps/cloudflare/release.yaml create mode 100644 tests/testdata/cluster7/flux/charts/app-template.yaml diff --git a/flux_local/tool/diff.py b/flux_local/tool/diff.py index e1e84dc7..4c6a945e 100644 --- a/flux_local/tool/diff.py +++ b/flux_local/tool/diff.py @@ -234,7 +234,9 @@ def create_diff_path( yield git_repo.PathSelector(path_orig, sources=kwargs.get("sources")) return - with git_repo.create_worktree(selector.repo, existing_branch=kwargs.get("branch_orig")) as worktree: + with git_repo.create_worktree( + selector.repo, existing_branch=kwargs.get("branch_orig") + ) as worktree: yield git_repo.PathSelector(pathlib.Path(worktree) / selector.relative_path) @@ -366,6 +368,7 @@ async def run( # type: ignore[no-untyped-def] helm_visitor = HelmVisitor() query.kustomization.visitor = content.visitor() query.helm_repo.visitor = helm_visitor.repo_visitor() + query.oci_repo.visitor = helm_visitor.repo_visitor() query.helm_release.visitor = helm_visitor.release_visitor() options = selector.build_helm_options(**kwargs) await git_repo.build_manifest( @@ -378,6 +381,7 @@ async def run( # type: ignore[no-untyped-def] query.path = path_selector query.kustomization.visitor = orig_content.visitor() query.helm_repo.visitor = orig_helm_visitor.repo_visitor() + query.oci_repo.visitor = orig_helm_visitor.repo_visitor() query.helm_release.visitor = orig_helm_visitor.release_visitor() await git_repo.build_manifest( selector=query, options=selector.options(**kwargs) diff --git a/tests/testdata/cluster7/flux/apps/cloudflare/release.yaml b/tests/testdata/cluster7/flux/apps/cloudflare/release.yaml new file mode 100644 index 00000000..0570d394 --- /dev/null +++ b/tests/testdata/cluster7/flux/apps/cloudflare/release.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: cloudflared + namespace: flux-system +spec: + interval: 60m + chartRef: + kind: OCIRepository + name: app-template + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 diff --git a/tests/testdata/cluster7/flux/charts/app-template.yaml b/tests/testdata/cluster7/flux/charts/app-template.yaml new file mode 100644 index 00000000..e1bd85ec --- /dev/null +++ b/tests/testdata/cluster7/flux/charts/app-template.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: OCIRepository +metadata: + name: app-template + namespace: flux-system +spec: + interval: 12h + layerSelector: + mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip + operation: copy + url: oci://ghcr.io/bjw-s/helm/app-template + ref: + tag: "3.3.2" diff --git a/tests/tool/__snapshots__/test_get_hr.ambr b/tests/tool/__snapshots__/test_get_hr.ambr index c94bc1e7..c6ef8e28 100644 --- a/tests/tool/__snapshots__/test_get_hr.ambr +++ b/tests/tool/__snapshots__/test_get_hr.ambr @@ -51,8 +51,9 @@ # --- # name: test_get_hr[cluster7] ''' - NAMESPACE NAME REVISION CHART SOURCE - database postgresql 12.7.1 database-postgresql bitnami-charts + NAMESPACE NAME REVISION CHART SOURCE + flux-system cloudflared None flux-system-app-template app-template + database postgresql 12.7.1 database-postgresql bitnami-charts ''' # ---