From 6ee25d8f97d52d6e952ce27b2ba2638e5b752d82 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Tue, 6 Aug 2024 02:40:50 +0000 Subject: [PATCH] Add OCIRepository as a parsed object --- flux_local/git_repo.py | 46 +++++++++- flux_local/manifest.py | 52 +++++++++++ flux_local/tool/get.py | 11 ++- flux_local/tool/visitor.py | 5 +- tests/__snapshots__/test_git_repo.ambr | 88 ++++++++++++++----- .../tool/__snapshots__/test_get_cluster.ambr | 14 +++ tests/tool/__snapshots__/test_get_ks.ambr | 21 +++-- tests/tool/test_get_ks.py | 2 + 8 files changed, 206 insertions(+), 33 deletions(-) diff --git a/flux_local/git_repo.py b/flux_local/git_repo.py index f9f712b0..167b16c0 100644 --- a/flux_local/git_repo.py +++ b/flux_local/git_repo.py @@ -58,6 +58,7 @@ Secret, SECRET_KIND, CONFIG_MAP_KIND, + OCIRepository, ) from .exceptions import InputException from .context import trace_context @@ -204,7 +205,11 @@ class ResourceVisitor: func: Callable[ [ Path, - Kustomization | HelmRelease | HelmRepository | ClusterPolicy, + Kustomization + | HelmRelease + | HelmRepository + | ClusterPolicy + | OCIRepository, kustomize.Kustomize | None, ], Awaitable[None], @@ -265,11 +270,20 @@ class MetadataSelector: @property def predicate( self, - ) -> Callable[[Kustomization | HelmRelease | HelmRepository | ClusterPolicy], bool]: + ) -> Callable[ + [Kustomization | HelmRelease | HelmRepository | ClusterPolicy | OCIRepository], + bool, + ]: """A predicate that selects Kustomization objects.""" def predicate( - obj: Kustomization | HelmRelease | HelmRepository | ClusterPolicy, + obj: ( + Kustomization + | HelmRelease + | HelmRepository + | ClusterPolicy + | OCIRepository + ), ) -> bool: if not self.enabled: return False @@ -323,6 +337,9 @@ class ResourceSelector: helm_release: MetadataSelector = field(default_factory=MetadataSelector) """HelmRelease objects to return.""" + oci_repo: MetadataSelector = field(default_factory=MetadataSelector) + """OCIRepository objects to return.""" + cluster_policy: MetadataSelector = field(default_factory=MetadataSelector) """ClusterPolicy objects to return.""" @@ -568,11 +585,13 @@ async def build_kustomization( root: Path = selector.path.root kustomization_selector: MetadataSelector = selector.kustomization helm_repo_selector: MetadataSelector = selector.helm_repo + oci_repo_selector: MetadataSelector = selector.oci_repo helm_release_selector: MetadataSelector = selector.helm_release cluster_policy_selector: MetadataSelector = selector.cluster_policy if ( not kustomization_selector.enabled and not helm_repo_selector.enabled + and not oci_repo_selector.visitor and not helm_release_selector.enabled and not cluster_policy_selector.enabled and not selector.doc_visitor @@ -608,6 +627,8 @@ async def build_kustomization( kinds.append(CONFIG_MAP_KIND) if helm_repo_selector.enabled: kinds.append(HELM_REPO_KIND) + if oci_repo_selector.enabled: + kinds.append(OCI_REPO_KIND) if helm_release_selector.enabled: kinds.append(HELM_RELEASE_KIND) # Needed for expanding value references @@ -640,6 +661,16 @@ async def build_kustomization( ], ) ) + kustomization.oci_repos = list( + filter( + oci_repo_selector.predicate, + [ + OCIRepository.parse_doc(doc) + for doc in docs + if doc.get("kind") == OCI_REPO_KIND + ], + ) + ) kustomization.helm_releases = list( filter( helm_release_selector.predicate, @@ -793,6 +824,15 @@ async def update_kustomization(cluster: Cluster) -> None: None, ) + if selector.oci_repo.visitor: + for kustomization in cluster.kustomizations: + for oci_repo in kustomization.oci_repos: + await selector.oci_repo.visitor.func( + Path(kustomization.path), + oci_repo, + None, + ) + if selector.helm_release.visitor: for kustomization in cluster.kustomizations: for helm_release in kustomization.helm_releases: diff --git a/flux_local/manifest.py b/flux_local/manifest.py index 2d033f23..cf053d86 100644 --- a/flux_local/manifest.py +++ b/flux_local/manifest.py @@ -50,6 +50,7 @@ VALUE_B64_PLACEHOLDER = base64.b64encode(VALUE_PLACEHOLDER.encode()) HELM_REPOSITORY = "HelmRepository" GIT_REPOSITORY = "GitRepository" +GIT_REPOSITORY_DOMAIN = "source.toolkit.fluxcd.io" REPO_TYPE_DEFAULT = "default" REPO_TYPE_OCI = "oci" @@ -275,6 +276,45 @@ def repo_name(self) -> str: return f"{self.namespace}-{self.name}" +@dataclass +class OCIRepository(BaseManifest): + """A representation of a flux OCIRepository.""" + + name: str + """The name of the OCIRepository.""" + + namespace: str + """The namespace of owning the OCIRepository.""" + + url: str + """The URL to the repository.""" + + @classmethod + def parse_doc(cls, doc: dict[str, Any]) -> "OCIRepository": + """Parse a HelmRepository from a kubernetes resource.""" + _check_version(doc, GIT_REPOSITORY_DOMAIN) + if not (metadata := doc.get("metadata")): + raise InputException(f"Invalid {cls} missing metadata: {doc}") + if not (name := metadata.get("name")): + raise InputException(f"Invalid {cls} missing metadata.name: {doc}") + if not (namespace := metadata.get("namespace")): + raise InputException(f"Invalid {cls} missing metadata.namespace: {doc}") + if not (spec := doc.get("spec")): + raise InputException(f"Invalid {cls} missing spec: {doc}") + if not (url := spec.get("url")): + raise InputException(f"Invalid {cls} missing spec.url: {doc}") + return cls( + name=name, + namespace=namespace, + url=url, + ) + + @property + def repo_name(self) -> str: + """Identifier for the OCIRepository.""" + return f"{self.namespace}-{self.name}" + + @dataclass class ClusterPolicy(BaseManifest): """A kyverno policy object.""" @@ -412,6 +452,9 @@ class Kustomization(BaseManifest): helm_repos: list[HelmRepository] = field(default_factory=list) """The set of HelmRepositories represented in this kustomization.""" + oci_repos: list[OCIRepository] = field(default_factory=list) + """The set of OCIRepositories represented in this kustomization.""" + helm_releases: list[HelmRelease] = field(default_factory=list) """The set of HelmRelease represented in this kustomization.""" @@ -564,6 +607,15 @@ def helm_repos(self) -> list[HelmRepository]: for repo in kustomization.helm_repos ] + @property + def oci_repos(self) -> list[OCIRepository]: + """Return the list of OCIRepository objects from all Kustomizations.""" + return [ + repo + for kustomization in self.kustomizations + for repo in kustomization.oci_repos + ] + @property def helm_releases(self) -> list[HelmRelease]: """Return the list of HelmRelease objects from all Kustomizations.""" diff --git a/flux_local/tool/get.py b/flux_local/tool/get.py index 1a2034c1..59e2cbb9 100644 --- a/flux_local/tool/get.py +++ b/flux_local/tool/get.py @@ -68,16 +68,17 @@ async def run( # type: ignore[no-untyped-def] results: list[dict[str, str]] = [] cols = ["name", "path"] if output == "wide": - cols.extend(["helmrepos", "releases"]) + cols.extend(["helmrepos", "ocirepos", "releases"]) if query.kustomization.namespace is None: cols.insert(0, "namespace") if len(manifest.clusters) > 1: cols.insert(0, "cluster") for cluster in manifest.clusters: for ks in cluster.kustomizations: - value = { k: v for k, v in ks.compact_dict().items() if k in cols } + value = {k: v for k, v in ks.compact_dict().items() if k in cols} if output == "wide": value["helmrepos"] = len(ks.helm_repos) + value["ocirepos"] = len(ks.oci_repos) value["releases"] = len(ks.helm_releases) value["cluster"] = cluster.path results.append(value) @@ -126,7 +127,9 @@ async def run( # type: ignore[no-untyped-def] results: list[dict[str, Any]] = [] for cluster in manifest.clusters: for helmrelease in cluster.helm_releases: - value = { k: v for k, v in helmrelease.compact_dict().items() if k in cols } + value = { + k: v for k, v in helmrelease.compact_dict().items() if k in cols + } value["revision"] = str(helmrelease.chart.version) value["chart"] = f"{helmrelease.namespace}-{helmrelease.chart.name}" value["source"] = helmrelease.chart.repo_name @@ -230,7 +233,7 @@ async def run( # type: ignore[no-untyped-def] cols = ["path", "kustomizations"] results: list[dict[str, Any]] = [] for cluster in manifest.clusters: - value = { k: v for k, v in cluster.compact_dict().items() if k in cols } + value = {k: v for k, v in cluster.compact_dict().items() if k in cols} value["kustomizations"] = len(cluster.kustomizations) results.append(value) diff --git a/flux_local/tool/visitor.py b/flux_local/tool/visitor.py index 43cb856a..978af719 100644 --- a/flux_local/tool/visitor.py +++ b/flux_local/tool/visitor.py @@ -18,6 +18,7 @@ HelmRepository, ClusterPolicy, Manifest, + OCIRepository, ) @@ -32,7 +33,9 @@ ] -ResourceType = Kustomization | HelmRelease | HelmRepository | ClusterPolicy +ResourceType = ( + Kustomization | HelmRelease | HelmRepository | ClusterPolicy | OCIRepository +) @dataclass(frozen=True, order=True) diff --git a/tests/__snapshots__/test_git_repo.ambr b/tests/__snapshots__/test_git_repo.ambr index 835d560a..c296adcc 100644 --- a/tests/__snapshots__/test_git_repo.ambr +++ b/tests/__snapshots__/test_git_repo.ambr @@ -29,6 +29,8 @@ ]), 'name': 'apps', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/apps/prod', 'secrets': list([ ]), @@ -48,6 +50,8 @@ ]), 'name': 'flux-system', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/clusters/prod', 'secrets': list([ ]), @@ -84,6 +88,8 @@ ]), 'name': 'infra-configs', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/configs', 'secrets': list([ ]), @@ -119,6 +125,8 @@ ]), 'name': 'infra-controllers', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/controllers', 'secrets': list([ ]), @@ -155,6 +163,8 @@ ]), 'name': 'apps', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/apps/prod', 'secrets': list([ ]), @@ -174,6 +184,8 @@ ]), 'name': 'flux-system', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/clusters/prod', 'secrets': list([ ]), @@ -210,6 +222,8 @@ ]), 'name': 'infra-configs', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/configs', 'secrets': list([ ]), @@ -225,6 +239,8 @@ ]), 'name': 'infra-controllers', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/controllers', 'secrets': list([ ]), @@ -265,6 +281,8 @@ ]), 'name': 'apps', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/apps/prod', 'secrets': list([ ]), @@ -284,6 +302,8 @@ ]), 'name': 'flux-system', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/clusters/prod', 'secrets': list([ ]), @@ -320,6 +340,8 @@ ]), 'name': 'infra-configs', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/configs', 'secrets': list([ ]), @@ -355,6 +377,8 @@ ]), 'name': 'infra-controllers', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/controllers', 'secrets': list([ ]), @@ -414,6 +438,8 @@ ]), 'name': 'apps', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/apps/prod', 'secrets': list([ ]), @@ -433,6 +459,8 @@ ]), 'name': 'flux-system', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/clusters/prod', 'secrets': list([ ]), @@ -451,6 +479,8 @@ ]), 'name': 'infra-configs', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/configs', 'secrets': list([ ]), @@ -486,6 +516,8 @@ ]), 'name': 'infra-controllers', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/controllers', 'secrets': list([ ]), @@ -526,6 +558,8 @@ ]), 'name': 'apps', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/apps/prod', 'secrets': list([ ]), @@ -545,6 +579,8 @@ ]), 'name': 'flux-system', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/clusters/prod', 'secrets': list([ ]), @@ -581,6 +617,8 @@ ]), 'name': 'infra-configs', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/configs', 'secrets': list([ ]), @@ -616,6 +654,8 @@ ]), 'name': 'infra-controllers', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/controllers', 'secrets': list([ ]), @@ -651,31 +691,31 @@ "Build 'flux-system/cluster'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/cluster-apps'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/cluster-apps-ingress-nginx'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/cluster-apps-ingress-nginx-certificates'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/cluster-apps-kubernetes-dashboard'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/cluster'": dict({ @@ -734,13 +774,13 @@ "Build 'flux-system/namespaces'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/tenants'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/namespaces'": dict({ @@ -775,19 +815,19 @@ "Build 'flux-system/cluster'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/cluster-apps'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/cluster-apps-kubernetes-dashboard'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/cluster'": dict({ @@ -830,7 +870,7 @@ "Build 'flux-system/flux-system'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/flux-system'": dict({ @@ -857,13 +897,13 @@ "Build 'flux-system/apps'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/flux-system'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/apps'": dict({ @@ -898,19 +938,19 @@ "Build 'flux-system/apps'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/charts'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/flux-system'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/apps'": dict({ @@ -954,25 +994,25 @@ 'cmds': list([ 'flux build tests/testdata/cluster/apps/prod (abs)', "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/flux-system'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/infra-configs'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Build 'flux-system/infra-controllers'": dict({ 'cmds': list([ "kustomize cfg grep 'kind=^(CustomResourceDefinition|Secret)$' --invert-match", - "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|HelmRelease|Secret|ClusterPolicy)$'", + "kustomize cfg grep 'kind=^(ConfigMap|HelmRepository|OCIRepository|HelmRelease|Secret|ClusterPolicy)$'", ]), }), "Kustomization 'flux-system/apps'": dict({ @@ -1058,6 +1098,8 @@ ]), 'name': 'apps', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/apps/prod', 'secrets': list([ ]), @@ -1077,6 +1119,8 @@ ]), 'name': 'flux-system', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/clusters/prod', 'secrets': list([ ]), @@ -1113,6 +1157,8 @@ ]), 'name': 'infra-configs', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/configs', 'secrets': list([ ]), @@ -1148,6 +1194,8 @@ ]), 'name': 'infra-controllers', 'namespace': 'flux-system', + 'oci_repos': list([ + ]), 'path': 'tests/testdata/cluster/infrastructure/controllers', 'secrets': list([ ]), diff --git a/tests/tool/__snapshots__/test_get_cluster.ambr b/tests/tool/__snapshots__/test_get_cluster.ambr index 3970ae88..4dbc3753 100644 --- a/tests/tool/__snapshots__/test_get_cluster.ambr +++ b/tests/tool/__snapshots__/test_get_cluster.ambr @@ -72,6 +72,7 @@ namespace: flux-system path: tests/testdata/cluster/apps/prod helm_repos: [] + oci_repos: [] helm_releases: - name: podinfo namespace: podinfo @@ -92,6 +93,7 @@ namespace: flux-system path: tests/testdata/cluster/clusters/prod helm_repos: [] + oci_repos: [] helm_releases: [] cluster_policies: [] config_maps: @@ -114,6 +116,7 @@ namespace: flux-system url: oci://ghcr.io/weaveworks/charts repo_type: oci + oci_repos: [] helm_releases: [] cluster_policies: - name: test-allow-policy @@ -123,6 +126,7 @@ namespace: flux-system path: tests/testdata/cluster/infrastructure/controllers helm_repos: [] + oci_repos: [] helm_releases: - name: metallb namespace: metallb @@ -159,6 +163,7 @@ namespace: flux-system path: tests/testdata/cluster/apps/prod helm_repos: [] + oci_repos: [] helm_releases: - name: podinfo namespace: podinfo @@ -176,6 +181,7 @@ namespace: flux-system path: tests/testdata/cluster/clusters/prod helm_repos: [] + oci_repos: [] helm_releases: [] cluster_policies: [] config_maps: @@ -198,6 +204,7 @@ namespace: flux-system url: oci://ghcr.io/weaveworks/charts repo_type: oci + oci_repos: [] helm_releases: [] cluster_policies: - name: test-allow-policy @@ -207,6 +214,7 @@ namespace: flux-system path: tests/testdata/cluster/infrastructure/controllers helm_repos: [] + oci_repos: [] helm_releases: - name: metallb namespace: metallb @@ -246,6 +254,7 @@ namespace: flux-system url: https://pkgs.tailscale.com/helmcharts repo_type: default + oci_repos: [] helm_releases: - name: podinfo namespace: podinfo @@ -279,6 +288,7 @@ namespace: flux-system path: tests/testdata/cluster8/cluster helm_repos: [] + oci_repos: [] helm_releases: [] cluster_policies: [] config_maps: [] @@ -304,6 +314,7 @@ namespace: flux-system url: https://pkgs.tailscale.com/helmcharts repo_type: default + oci_repos: [] helm_releases: - name: podinfo namespace: podinfo @@ -336,6 +347,7 @@ namespace: flux-system path: tests/testdata/cluster8/cluster helm_repos: [] + oci_repos: [] helm_releases: [] cluster_policies: [] config_maps: [] @@ -361,6 +373,7 @@ namespace: flux-system url: https://pkgs.tailscale.com/helmcharts repo_type: default + oci_repos: [] helm_releases: - name: podinfo namespace: podinfo @@ -385,6 +398,7 @@ namespace: flux-system path: tests/testdata/cluster8/cluster helm_repos: [] + oci_repos: [] helm_releases: [] cluster_policies: [] config_maps: [] diff --git a/tests/tool/__snapshots__/test_get_ks.ambr b/tests/tool/__snapshots__/test_get_ks.ambr index 780dd937..2baaeb29 100644 --- a/tests/tool/__snapshots__/test_get_ks.ambr +++ b/tests/tool/__snapshots__/test_get_ks.ambr @@ -1,4 +1,15 @@ # serializer version: 1 +# name: test_get_ks[cluster2-wide] + ''' + NAME PATH HELMREPOS OCIREPOS RELEASES + cluster tests/testdata/cluster2/flux 3 1 0 + cluster-apps tests/testdata/cluster2/apps 0 0 0 + cluster-apps-ingress-nginx tests/testdata/cluster2/apps/networking/ingress-nginx/app 0 0 1 + cluster-apps-ingress-nginx-certificates tests/testdata/cluster2/apps/networking/ingress-nginx/certificates 0 0 0 + cluster-apps-kubernetes-dashboard tests/testdata/cluster2/apps/monitoring/kubernetes-dashboard/app 0 0 1 + + ''' +# --- # name: test_get_ks[cluster2] ''' NAME PATH @@ -95,11 +106,11 @@ # --- # name: test_get_ks[wide] ''' - NAME PATH HELMREPOS RELEASES - apps tests/testdata/cluster/apps/prod 0 1 - flux-system tests/testdata/cluster/clusters/prod 0 0 - infra-configs tests/testdata/cluster/infrastructure/configs 3 0 - infra-controllers tests/testdata/cluster/infrastructure/controllers 0 2 + NAME PATH HELMREPOS OCIREPOS RELEASES + apps tests/testdata/cluster/apps/prod 0 0 1 + flux-system tests/testdata/cluster/clusters/prod 0 0 0 + infra-configs tests/testdata/cluster/infrastructure/configs 3 0 0 + infra-controllers tests/testdata/cluster/infrastructure/controllers 0 0 2 ''' # --- diff --git a/tests/tool/test_get_ks.py b/tests/tool/test_get_ks.py index e28a7065..12ec3413 100644 --- a/tests/tool/test_get_ks.py +++ b/tests/tool/test_get_ks.py @@ -28,6 +28,7 @@ (["--path", "tests/testdata/cluster7"]), (["--path", "./tests/testdata/cluster/clusters/prod"]), (["--path", "tests/testdata/cluster", "-o", "wide"]), + (["--path", "tests/testdata/cluster2", "-o", "wide"]), (["--all-namespaces", "--path", "./tests/testdata/cluster/apps/prod"]), (["--path", "tests/testdata/cluster9/clusters/dev"]), ], @@ -42,6 +43,7 @@ "cluster7", "cluster_path", "wide", + "cluster2-wide", "ks_path", "cluster9", ],