diff --git a/justfile b/justfile index 0d4b2f82b4..9eaed4ffe7 100644 --- a/justfile +++ b/justfile @@ -187,16 +187,18 @@ fmt: lint: nix run .#scripts.golangci-lint -- run -demodir cli=default_cli: undeploy coordinator initializer +demodir: coordinator initializer #!/usr/bin/env bash d=$(mktemp -d) + namespace=edg-default echo "Creating demo directory at ${d}" - nix build .#{{ cli }} - cp ./result-cli/bin/contrast "${d}/contrast" cp -R ./deployments/emojivoto "${d}/deployment" + rm -f "${d}/deployment/coordinator.yml" nix run .#scripts.patch-contrast-image-hashes -- "${d}/deployment" nix run .#kypatch images -- "${d}/deployment" \ --replace ghcr.io/edgelesssys ${container_registry} + # TODO(burgerdev): set namespace on generated resources, too. + nix run .#scripts.fetch-latest-contrast -- "${namespace}" "${d}" echo "Demo directory ready at ${d}" # Cleanup auxiliary files, caches etc. diff --git a/packages/scripts.nix b/packages/scripts.nix index 799e31880e..7c1377fecf 100644 --- a/packages/scripts.nix +++ b/packages/scripts.nix @@ -168,4 +168,24 @@ with pkgs; popd >/dev/null ''; }; + + fetch-latest-contrast = writeShellApplication { + name = "fetch-latest-contrast"; + runtimeInputs = [ + jq + github-cli + ]; + text = '' + namespace=$1 + targetDir=$2 + release=$(gh release list --json name,isLatest | jq -r '.[] | select(.isLatest) | .name') + gh release download "$release" \ + --repo edgelesssys/contrast \ + -D "$targetDir" \ + --skip-existing + chmod a+x "$targetDir/contrast" + + yq -i ".metadata.namespace = \"$namespace\"" "$targetDir/coordinator.yaml" + ''; + }; }