From 6a6626f1d8d4fa52063914487e1f5cd9660a2383 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Tue, 20 Aug 2024 09:43:16 +0200 Subject: [PATCH] contrast-releases: support files with platform suffix --- packages/contrast-releases.nix | 55 ++++++++++++++++++++++++++-- packages/update-contrast-releases.sh | 5 +++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/packages/contrast-releases.nix b/packages/contrast-releases.nix index c18ae6ec53..a27e000ca5 100644 --- a/packages/contrast-releases.nix +++ b/packages/contrast-releases.nix @@ -31,6 +31,7 @@ let inherit version; url = "https://github.com/edgelesssys/contrast/releases/download/${version}/coordinator.yml"; inherit (findVersion "coordinator.yml" version) hash; + passthru.exists = (builtins.compareVersions version "v0.10.0") < 0; }; runtime = fetchurl { @@ -38,7 +39,9 @@ let url = "https://github.com/edgelesssys/contrast/releases/download/${version}/runtime.yml"; inherit (findVersion "runtime.yml" version) hash; # runtime.yml was introduced in release v0.6.0 - passthru.exists = (builtins.compareVersions "v0.6.0" version) <= 0; + passthru.exists = + (builtins.compareVersions "v0.6.0" version) <= 0 + && (builtins.compareVersions version "v0.10.0") < 0; }; emojivoto-zip = fetchurl { @@ -56,8 +59,42 @@ let url = "https://github.com/edgelesssys/contrast/releases/download/${version}/emojivoto-demo.yml"; inherit (findVersion "emojivoto-demo.yml" version) hash; # emojivoto-demo.yml was changed from zip to yml in version v0.8.0 - passthru.exists = (builtins.compareVersions "v0.8.0" version) <= 0; + passthru.exists = + (builtins.compareVersions "v0.8.0" version) <= 0 + && (builtins.compareVersions version "v0.10.0") < 0; }; + + # starting with version v0.10.0 all files has a platform-specific suffix. + platformSpecificFiles = builtins.listToAttrs ( + lib.lists.map + ( + platform: + lib.attrsets.nameValuePair platform { + exist = (builtins.compareVersions "v0.10.0" version) <= 0; + coordinator = fetchurl { + inherit version; + url = "https://github.com/edgelesssys/contrast/releases/download/${version}/coordinator-${platform}.yml"; + inherit (findVersion "coordinator-${platform}.yml" version) hash; + }; + runtime = fetchurl { + inherit version; + url = "https://github.com/edgelesssys/contrast/releases/download/${version}/runtime-${platform}.yml"; + inherit (findVersion "runtime-${platform}.yml" version) hash; + }; + emojivoto = fetchurl { + inherit version; + url = "https://github.com/edgelesssys/contrast/releases/download/${version}/emojivoto-demo-${platform}.yml"; + inherit (findVersion "emojivoto-demo-${platform}.yml" version) hash; + }; + } + ) + [ + "aks-clh-snp" + "k3s-qemu-tdx" + "k3s-qemu-snp" + "rke2-qemu-tdx" + ] + ); in runCommand version { @@ -74,7 +111,8 @@ let --bash <($out/bin/contrast completion bash) \ --fish <($out/bin/contrast completion fish) \ --zsh <($out/bin/contrast completion zsh) - + '' + + lib.optionalString coordinator.exists '' install -m 644 ${coordinator} $out/coordinator.yml '' + lib.optionalString runtime.exists '' @@ -87,6 +125,17 @@ let mkdir -p $out/deployment install -m 644 ${emojivoto} $out/deployment/emojivoto-demo.yml '' + + lib.concatStrings ( + lib.attrsets.mapAttrsToList ( + platform: files: + lib.optionalString files.exist '' + install -m 644 ${files.coordinator} $out/coordinator-${platform}.yml + install -m 644 ${files.runtime} $out/runtime-${platform}.yml + mkdir -p $out/deployment/${platform} + install -m 644 ${files.emojivoto} $out/deployment/${platform}/emojivoto-demo.yml + '' + ) platformSpecificFiles + ) ); }; releases = builtins.listToAttrs (builtins.map buildContrastRelease json.contrast); diff --git a/packages/update-contrast-releases.sh b/packages/update-contrast-releases.sh index 28b32dc8b8..337e9df271 100644 --- a/packages/update-contrast-releases.sh +++ b/packages/update-contrast-releases.sh @@ -20,6 +20,11 @@ fields["coordinator.yml"]="./workspace/coordinator.yml" fields["runtime.yml"]="./workspace/runtime.yml" fields["emojivoto-demo.zip"]="./workspace/emojivoto-demo.zip" fields["emojivoto-demo.yml"]="./workspace/emojivoto-demo.yml" +for platform in aks-clh-snp k3s-qemu-tdx k3s-qemu-snp rke2-qemu-tdx; do + fields["coordinator-${platform}.yml"]="./workspace/coordinator-${platform}.yml" + fields["runtime-${platform}.yml"]="./workspace/runtime-${platform}.yml" + fields["emojivoto-demo-${platform}.yml"]="./workspace/emojivoto-demo-${platform}.yml" +done for field in "${!fields[@]}"; do # get the file path