Skip to content

Commit

Permalink
e2e: add resourcegen and package
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Mar 5, 2024
1 parent ca8c2b7 commit c6243ac
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
48 changes: 48 additions & 0 deletions e2e/internal/kuberesource/resourcegen/main.go
Original file line number Diff line number Diff line change
@@ -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 <set> <dest>")
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)
}
}
11 changes: 5 additions & 6 deletions packages/by-name/nunki/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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"
'';
Expand Down

0 comments on commit c6243ac

Please sign in to comment.