From c620ebd31530181c4b4fe0362ce132b035453233 Mon Sep 17 00:00:00 2001 From: Markus Rudy Date: Tue, 20 Feb 2024 14:40:45 +0100 Subject: [PATCH] just: make cli variant configurable Introduces a new parameter for some just targets that allows overriding the nix rule used to build the cli. The dev variant stays the default, while the release variant is used for e2e testing. --- .github/workflows/e2e_simple.yml | 2 +- justfile | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/e2e_simple.yml b/.github/workflows/e2e_simple.yml index f6d17b494..60a560eee 100644 --- a/.github/workflows/e2e_simple.yml +++ b/.github/workflows/e2e_simple.yml @@ -57,7 +57,7 @@ jobs: just get-credentials - name: Build, deploy, nunki generate, nunki set, nunki verify run: | - just default simple + just default simple cli-release - name: Summary run: | cat ./workspace/just.namespace | tee -a "${GITHUB_STEP_SUMMARY}" diff --git a/justfile b/justfile index e0df7db60..6f6f961b5 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ # Undeploy, rebuild, deploy. -default target=default_deploy_target: undeploy coordinator initializer openssl port-forwarder (deploy target) set verify (wait-for-workload target) +default target=default_deploy_target cli=default_cli: undeploy coordinator initializer openssl port-forwarder (deploy target cli) set verify (wait-for-workload target) # Build the coordinator, containerize and push it. coordinator: @@ -17,14 +17,15 @@ port-forwarder: initializer: nix run .#containers.push-initializer -- "$container_registry/nunki/initializer" +default_cli := "nunki.cli" default_deploy_target := "simple" workspace_dir := "workspace" # Generate policies, apply Kubernetes manifests. -deploy target=default_deploy_target: (generate target) apply +deploy target=default_deploy_target cli=default_cli: (generate target cli) apply # Generate policies, update manifest. -generate target=default_deploy_target: +generate target=default_deploy_target cli=default_cli: #!/usr/bin/env bash set -euo pipefail mkdir -p ./{{ workspace_dir }} @@ -37,7 +38,7 @@ generate target=default_deploy_target: nix run .#kypatch namespace -- ./{{ workspace_dir }}/deployment \ --replace edg-default {{ target }}${namespace_suffix-} t=$(date +%s) - nix run .#nunki.cli -- generate \ + nix run .#{{ cli }} -- generate \ -m ./{{ workspace_dir }}/manifest.json \ -p ./{{ workspace_dir }}/rules.rego \ -s ./{{ workspace_dir }}/genpolicy-msft.json \ @@ -69,7 +70,7 @@ create: nix run .#scripts.create-coco-aks -- --name="$azure_resource_group" # Set the manifest at the coordinator. -set: +set cli=default_cli: #!/usr/bin/env bash set -euo pipefail ns=$(cat ./{{ workspace_dir }}/just.namespace) @@ -81,7 +82,7 @@ set: nix run .#scripts.wait-for-port-listen -- 1313 policy=$(<./{{ workspace_dir }}/just.coordinator-policy-hash) t=$(date +%s) - nix run .#nunki.cli -- set \ + nix run .#{{ cli }} -- set \ -m ./{{ workspace_dir }}/manifest.json \ -c localhost:1313 \ --coordinator-policy-hash "${policy}" \ @@ -91,7 +92,7 @@ set: echo "set $duration" >> ./{{ workspace_dir }}/just.perf # Verify the Coordinator. -verify: +verify cli=default_cli: #!/usr/bin/env bash set -euo pipefail rm -rf ./{{ workspace_dir }}/verify @@ -102,7 +103,7 @@ verify: trap "kill $PID" EXIT nix run .#scripts.wait-for-port-listen -- 1314 t=$(date +%s) - nix run .#nunki.cli -- verify \ + nix run .#{{ cli }} -- verify \ -c localhost:1314 \ -o ./{{ workspace_dir }}/verify duration=$(( $(date +%s) - $t )) @@ -164,11 +165,11 @@ fmt: lint: nix run .#scripts.golangci-lint -- run -demodir: undeploy coordinator initializer +demodir cli=default_cli: undeploy coordinator initializer #!/usr/bin/env bash d=$(mktemp -d) echo "Creating demo directory at ${d}" - nix build .#nunki.cli + nix build .#{{ cli }} cp ./result-cli/bin/nunki "${d}/nunki" cp -R ./deployments/emojivoto "${d}/deployment" nix run .#scripts.patch-nunki-image-hashes -- "${d}/deployment"