diff --git a/e2e/internal/kuberesource/resourcegen/main.go b/e2e/internal/kuberesource/resourcegen/main.go new file mode 100644 index 000000000..a98403425 --- /dev/null +++ b/e2e/internal/kuberesource/resourcegen/main.go @@ -0,0 +1,48 @@ +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 + var err error + switch set { + case "simple": + resources, err = kuberesource.Simple() + default: + fmt.Printf("Error: unknown set: %s\n", set) + os.Exit(1) + } + if err != nil { + fmt.Printf("Error: %v\n", err) + 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 0721a4679..b5e293aa2 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" '';