Skip to content

Commit

Permalink
Allow --kustomize-build-flags in flux-local test (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter authored May 30, 2023
1 parent 0300b03 commit 3279dac
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions flux_local/tool/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
class TestConfig:
"""Test configuration, which are parameters to types of the tests."""

options: git_repo.Options
kube_version: str | None = None
api_versions: str | None = None

Expand Down Expand Up @@ -137,7 +138,12 @@ def runtest(self) -> None:

async def async_runtest(self) -> None:
"""Run the Kustomizations test."""
cmd = await kustomize.build(Path(self.kustomization.path)).stash()
kustomize_flags = []
if self.test_config.options:
kustomize_flags = self.test_config.options.kustomize_flags
cmd = await kustomize.build(
Path(self.kustomization.path), kustomize_flags
).stash()
await cmd.objects()
await cmd.validate_policies(self.cluster.cluster_policies)

Expand Down Expand Up @@ -261,12 +267,10 @@ class ManifestPlugin:
def __init__(
self,
selector: git_repo.ResourceSelector,
options: git_repo.Options,
test_config: TestConfig,
test_filter: list[str],
) -> None:
self.selector = selector
self.options = options
self.manifest: Manifest | None = None
self.test_config = test_config
self.test_filter = test_filter
Expand All @@ -280,7 +284,7 @@ async def async_pytest_sessionstart(self, session: pytest.Session) -> None:
_LOGGER.debug("async_pytest_sessionstart")
manifest = await git_repo.build_manifest(
selector=self.selector,
options=self.options,
options=self.test_config.options,
)
self.manifest = manifest
_LOGGER.debug("async_pytest_sessionstart ended")
Expand Down Expand Up @@ -406,6 +410,7 @@ async def run( # type: ignore[no-untyped-def]
query.helm_release.enabled = enable_helm
query.helm_release.namespace = None
query.cluster_policy.enabled = enable_kyverno
options = selector.options(**kwargs)

nest_asyncio.apply()
pytest_args = [
Expand All @@ -423,8 +428,11 @@ async def run( # type: ignore[no-untyped-def]
plugins=[
ManifestPlugin(
query,
selector.options(**kwargs),
TestConfig(kube_version=kube_version, api_versions=api_versions),
TestConfig(
options=options,
kube_version=kube_version,
api_versions=api_versions,
),
test_filter=[str(test_path)] if test_path else [],
)
],
Expand Down

0 comments on commit 3279dac

Please sign in to comment.