Skip to content

Commit

Permalink
contrast-releases: support files with platform suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Aug 20, 2024
1 parent b58995e commit 6a6626f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
55 changes: 52 additions & 3 deletions packages/contrast-releases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ 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 {
inherit version;
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 {
Expand All @@ -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
{
Expand All @@ -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 ''
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions packages/update-contrast-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a6626f

Please sign in to comment.