From c87e68881e179f05f908492cd457cabc7c42af28 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 4 Mar 2024 11:18:24 +0100 Subject: [PATCH] e2e: add resourcegen and package Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- e2e/internal/kuberesource/resourcegen/main.go | 43 +++++++++++++++++++ packages/by-name/nunki/package.nix | 11 +++-- 2 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 e2e/internal/kuberesource/resourcegen/main.go diff --git a/e2e/internal/kuberesource/resourcegen/main.go b/e2e/internal/kuberesource/resourcegen/main.go new file mode 100644 index 0000000000..6a27a55f53 --- /dev/null +++ b/e2e/internal/kuberesource/resourcegen/main.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "os" + "path" + + "github.com/edgelesssys/nunki/e2e/internal/kuberesource" +) + +func main() { + if len(os.Args) != 3 { + fmt.Println("Usage: kuberesource ") + os.Exit(1) + } + + set := os.Args[1] + dest := os.Args[2] + + var resources []any + switch set { + case "simple": + resources = kuberesource.Simple() + default: + fmt.Printf("Error: unknown set: %s\n", set) + os.Exit(1) + } + + b, err := kuberesource.EncodeResources(resources...) + if err != nil { + fmt.Printf("Error: %v\n", err) + os.Exit(1) + } + + if err := os.Mkdir(path.Dir(dest), 0o755); err != nil { + fmt.Println(err) + os.Exit(1) + } + if err := os.WriteFile(dest, b, 0o644); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/packages/by-name/nunki/package.nix b/packages/by-name/nunki/package.nix index 0721a4679f..b5e293aa20 100644 --- a/packages/by-name/nunki/package.nix +++ b/packages/by-name/nunki/package.nix @@ -16,13 +16,15 @@ let subPackages = [ "e2e/openssl" ]; }; + + packageOutputs = [ "coordinator" "initializer" "cli" ]; in buildGoModule rec { pname = "nunki"; version = builtins.readFile ../../../version.txt; - outputs = subPackages ++ [ "out" ]; + outputs = packageOutputs ++ [ "out" ]; # The source of the main module of this repo. We filter for Go files so that # changes in the other parts of this repo don't trigger a rebuild. @@ -45,7 +47,7 @@ buildGoModule rec { proxyVendor = true; vendorHash = "sha256-VBCTnRx4BBvG/yedChE55ZQbsaFk2zDcXtXof9v3XNI="; - subPackages = [ "coordinator" "initializer" "cli" ]; + subPackages = packageOutputs ++ [ "e2e/internal/kuberesource/resourcegen" ]; prePatch = '' install -D ${lib.getExe genpolicy} cli/cmd/assets/genpolicy @@ -71,14 +73,11 @@ buildGoModule rec { ''; postInstall = '' - for sub in ${builtins.concatStringsSep " " subPackages}; do + for sub in ${builtins.concatStringsSep " " packageOutputs}; do mkdir -p "''${!sub}/bin" mv "$out/bin/$sub" "''${!sub}/bin/$sub" done - # ensure no binary is left in out - rmdir "$out/bin/" - # rename the cli binary to nunki mv "$cli/bin/cli" "$cli/bin/nunki" '';