Skip to content

Commit

Permalink
e2e: move generate to Go
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Meyer <[email protected]>
  • Loading branch information
burgerdev and katexochen committed Mar 19, 2024
1 parent a0599c4 commit dabe6c9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_openssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Build, deploy, contrast generate, contrast set, contrast verify
run: |
just coordinator initializer openssl
just generate openssl contrast.cli
just populate openssl
- name: Setup Summary
run: |
cat ./workspace/just.namespace | tee -a "${GITHUB_STEP_SUMMARY}"
Expand Down
18 changes: 18 additions & 0 deletions e2e/openssl/openssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ func TestOpenSSL(t *testing.T) {
resources, err := filepath.Glob("./workspace/deployment/*.yml")
require.NoError(t, err)

require.True(t, t.Run("generate", func(t *testing.T) {
require := require.New(t)

args := []string{
"--workspace-dir", "./workspace",
}
args = append(args, resources...)

generate := cmd.NewGenerateCmd()
generate.Flags().String("workspace-dir", "", "") // Make generate aware of root flags
generate.SetArgs(args)
generate.SetOut(io.Discard)
errBuf := &bytes.Buffer{}
generate.SetErr(errBuf)

require.NoError(generate.Execute(), "could not generate manifest: %s", errBuf)
}))

// TODO(burgerdev): policy hash should come from contrast generate output.
coordinatorPolicyHashBytes, err := os.ReadFile("workspace/coordinator-policy.sha256")
require.NoError(t, err)
Expand Down
10 changes: 7 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ default_deploy_target := "simple"
workspace_dir := "workspace"

# Generate policies, apply Kubernetes manifests.
deploy target=default_deploy_target cli=default_cli: (generate target cli) (apply target)
deploy target=default_deploy_target cli=default_cli: (populate target) (generate cli) (apply target)

# Generate policies, update manifest.
generate target=default_deploy_target cli=default_cli:
# Populate the workspace with a Kubernetes deployment
populate target=default_deploy_target:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p ./{{ workspace_dir }}
Expand All @@ -47,6 +47,10 @@ generate target=default_deploy_target cli=default_cli:
--replace ghcr.io/edgelesssys ${container_registry}
nix run .#kypatch namespace -- ./{{ workspace_dir }}/deployment \
--replace edg-default {{ target }}${namespace_suffix-}
# Generate policies, update manifest.
generate cli=default_cli:
#!/usr/bin/env bash
t=$(date +%s)
nix run .#{{ cli }} -- generate \
--workspace-dir ./{{ workspace_dir }} \
Expand Down

0 comments on commit dabe6c9

Please sign in to comment.