terraform/provider: make the smoke test and local build portable

Use the in-repo chart by default and check it before touching the
cluster, bind the port-forward to 127.0.0.1 and fail when it does not
start, build from the module directory, and point dev_overrides at the
directory holding the binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 14:17:49 -08:00
1 parent fbd11378cb
commit fae64ed81e
3 files changed
+29 -11

No files matched your search

+1
View File
@@ -0,0 +1 @@
/bin/
+6 -4
View File
@@ -50,7 +50,7 @@ and configuration you intend to use before relying on IAM resources.
```bash
cd terraform/provider
go build -o terraform-provider-seaweedfs
go build -o bin/terraform-provider-seaweedfs .
```
## Generate Docs
@@ -68,7 +68,7 @@ Create `~/.terraformrc`:
```hcl
provider_installation {
dev_overrides {
"seaweedfs/seaweedfs" = "/absolute/path/to/terraform-provider-seaweedfs"
"seaweedfs/seaweedfs" = "/absolute/path/to/seaweedfs/terraform/provider/bin"
}
direct {}
}
@@ -124,8 +124,10 @@ tofu fmt -check -recursive
./scripts/minikube-smoke.sh
```
The script requires the existing `seaweedfs-kvm-smoke` Minikube profile (or a
profile selected with `MINIKUBE_PROFILE`). It creates the namespace and Helm
The script requires a running Minikube profile, `seaweedfs-podman-smoke` by
default (set `MINIKUBE_PROFILE` to use another). It installs the chart from
`k8s/charts/seaweedfs` unless `SEAWEEDFS_CHART` points elsewhere, and forwards
the S3 port to `127.0.0.1:${SEAWEEDFS_LOCAL_PORT:-8333}`. It creates the namespace and Helm
resources if needed, but does not delete the cluster, release, or Terraform
resources. It applies the example automatically; use only a disposable test
cluster and review the local example state before any manual cleanup.
+22 -7
View File
@@ -2,10 +2,12 @@
set -euo pipefail
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
CHART=${SEAWEEDFS_CHART:-/home/lcosta/work/k8s/seaweedfs/charts/seaweedfs-4.51.0.tgz}
CHART=${SEAWEEDFS_CHART:-$ROOT/../../k8s/charts/seaweedfs}
NAMESPACE=${SEAWEEDFS_NAMESPACE:-seaweedfs}
RELEASE=${SEAWEEDFS_RELEASE:-seaweedfs}
PROFILE=${MINIKUBE_PROFILE:-seaweedfs-podman-smoke}
LOCAL_PORT=${SEAWEEDFS_LOCAL_PORT:-8333}
ENDPOINT="http://127.0.0.1:$LOCAL_PORT"
for tool in minikube kubectl helm tofu curl python3; do
command -v "$tool" >/dev/null || {
@@ -14,6 +16,12 @@ for tool in minikube kubectl helm tofu curl python3; do
}
done
if [ ! -e "$CHART" ]; then
echo "SeaweedFS chart not found: $CHART (set SEAWEEDFS_CHART)" >&2
exit 1
fi
helm show chart "$CHART" >/dev/null
MINIKUBE_ROOTLESS=true minikube -p "$PROFILE" status >/dev/null 2>&1 || {
echo "Minikube profile $PROFILE is unavailable. Start it with the host-compatible driver." >&2
exit 2
@@ -57,7 +65,7 @@ helm upgrade --install "$RELEASE" "$CHART" \
kubectl -n "$NAMESPACE" rollout status deployment/"$RELEASE"-all-in-one --timeout=5m
PORT_FORWARD_LOG=$(mktemp)
kubectl -n "$NAMESPACE" port-forward service/"$RELEASE"-all-in-one 8333:8333 >"$PORT_FORWARD_LOG" 2>&1 &
kubectl -n "$NAMESPACE" port-forward --address 127.0.0.1 service/"$RELEASE"-all-in-one "$LOCAL_PORT":8333 >"$PORT_FORWARD_LOG" 2>&1 &
PF_PID=$!
cleanup() {
kill "$PF_PID" 2>/dev/null || true
@@ -72,19 +80,26 @@ trap 'exit 143' TERM
attempt=1
while [ "$attempt" -le 30 ]; do
if curl -sS --max-time 1 -o /dev/null http://127.0.0.1:8333/ 2>/dev/null; then
if ! kill -0 "$PF_PID" 2>/dev/null; then
echo "kubectl port-forward exited:" >&2
cat "$PORT_FORWARD_LOG" >&2
exit 1
fi
if grep -q "Forwarding from 127.0.0.1:$LOCAL_PORT" "$PORT_FORWARD_LOG" &&
curl -sS --max-time 1 -o /dev/null "$ENDPOINT/" 2>/dev/null; then
break
fi
attempt=$((attempt + 1))
sleep 1
done
if [ "$attempt" -gt 30 ]; then
echo "SeaweedFS S3 gateway did not become ready on 127.0.0.1:8333" >&2
echo "SeaweedFS S3 gateway did not become ready on $ENDPOINT" >&2
cat "$PORT_FORWARD_LOG" >&2
exit 1
fi
mkdir -p "$ROOT/bin"
go build -o "$ROOT/bin/terraform-provider-seaweedfs" "$ROOT/main.go"
(cd "$ROOT" && go build -o bin/terraform-provider-seaweedfs .)
TMP_CONFIG=$(mktemp)
cat >"$TMP_CONFIG" <<EOF
@@ -101,10 +116,10 @@ export TF_IN_AUTOMATION=1
cd "$ROOT/examples/full"
tofu validate
tofu apply -input=false -auto-approve \
-var="seaweedfs_endpoint=http://127.0.0.1:8333" \
-var="seaweedfs_endpoint=$ENDPOINT" \
-var="admin_access_key=terraform-admin" \
-var="admin_secret_key=terraform-admin-secret-key-000000000001"
tofu plan -input=false -detailed-exitcode \
-var="seaweedfs_endpoint=http://127.0.0.1:8333" \
-var="seaweedfs_endpoint=$ENDPOINT" \
-var="admin_access_key=terraform-admin" \
-var="admin_secret_key=terraform-admin-secret-key-000000000001"