eBPF-based security platform
testing/vm: write the stack's settings to a file a shell sources
John Fastabend61ec1d5d946f
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rstindex 0862f43a..3f04b23b 100644--- a/Documentation/contribute/testing/testing.rst+++ b/Documentation/contribute/testing/testing.rst@@ -762,6 +762,15 @@ storage.``make stack-up`` is shorthand for ``make oci telemetry``. Start the VMwith ``make vm``.+Each of the three writes ``build/test-vm/stack/env``, and ``make+stack-up`` ends with a ``Shell:`` line that names it. A shell that reads+the file, ``. build/test-vm/stack/env``, has the checkout's ``shirudo``+and ``shirudo-build`` on ``PATH``, the bundle's operator key directory+in ``KEYS``, the stack's CA in ``BPM_OCI_CA_FILE``, the tree the VM+follows in ``TREE`` and the stack's ClickHouse client in+``CLICKHOUSE_CLIENT``, as the commands of :doc:`/start/guides/index`+use them.+``make telemetry`` and ``make stack-up`` first build``tools/quote-check/shirudo-quote-check``, as ``make quote-check`` does,and turn that ClickHouse into a keepalive backend with it: they installdiff --git a/testing/Makefile b/testing/Makefileindex ecfa272a..db15d398 100644--- a/testing/Makefile+++ b/testing/Makefile@@ -458,6 +458,7 @@ clean:.PHONY: oci telemetry stack-up stack-down xtop shieldsstack-up: oci telemetry+ $(Q)TEST_VM_HOST_PRIVATE_DIR="$(TEST_VM_HOST_PRIVATE_DIR)" $(ROOT)/testing/vm/stack.sh envoci telemetry:$(Q)TEST_VM_HOST_PRIVATE_DIR="$(TEST_VM_HOST_PRIVATE_DIR)" $(ROOT)/testing/vm/stack.sh $@diff --git a/testing/vm/stack.sh b/testing/vm/stack.shindex 6e37a4b1..d3899fbb 100755--- a/testing/vm/stack.sh+++ b/testing/vm/stack.sh@@ -22,7 +22,7 @@ fiexec 9>"$W/.lock"flock 9case "$TLS_DIR/" in "$REPO/"*) echo 'stack private keys must be outside the checkout' >&2; exit 1 ;; esac-command=${1:?usage: stack.sh prepare|oci|telemetry|down|enroll|sbom|shields|xtop|vm}+command=${1:?usage: stack.sh prepare|oci|telemetry|env|down|enroll|sbom|shields|xtop|vm}shiftprepare(){@@ -33,11 +33,33 @@ prepare()fi}+quoted()+{+ printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\\\\''/g")"+}++# What a shell needs to run the guides' commands against the stack, in a+# file it sources: make cannot set a variable in the shell that ran it.+write_env()+{+ cat >"$W/env.tmp" <<-EOF+ export PATH=$(quoted "$REPO:$REPO/tools/shirudo-build"):"\$PATH"+ KEYS=$(quoted "${TEST_VM_HOST_PRIVATE_DIR:?}/operator-keys/keys")+ export BPM_OCI_CA_FILE=$(quoted "$W/ca.pem")+ TREE=oci://$REGISTRY/shirudo/local-tree+ export CLICKHOUSE_CLIENT='docker exec -i $STACK_NAME-clickhouse clickhouse-client'+ EOF+ [ "$(id -u)" != 0 ] || chown "$owner" "$W/env.tmp"+ mv -- "$W/env.tmp" "$W/env"+}+case "$command" inprepare) prepare ;;-oci) prepare; stack_oci; printf 'OCI: oci://%s (CA: %s/ca.pem)\n' "$REGISTRY" "$W" ;;+env) prepare; write_env; printf 'Shell: . %s/env\n' "$W" ;;+oci) prepare; write_env; stack_oci; printf 'OCI: oci://%s (CA: %s/ca.pem)\n' "$REGISTRY" "$W" ;;telemetry)prepare+ write_envchecker=$REPO/tools/quote-check/shirudo-quote-checkif [ -x "$checker" ]; thenstack_telemetry "$REPO/testing/vm/otelcol-stack.yaml" \