diff --git a/build/kind/Dockerfile.kind b/build/kind/Dockerfile.kind index 30432dee86..1b60750c90 100644 --- a/build/kind/Dockerfile.kind +++ b/build/kind/Dockerfile.kind @@ -3,7 +3,7 @@ FROM docker:20.10.24-dind # Step 2: Install necessary dependencies (curl, bash, tini) -RUN apk add --no-cache bash curl tini +RUN apk add --no-cache bash curl tini jq # Step 3: Install Kind (Kubernetes in Docker) RUN curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 && \ @@ -26,5 +26,12 @@ RUN chmod +x /usr/local/bin/entrypoint.sh COPY ./images /images COPY k6.yaml /examples/k6.yaml +ARG segmentio_key +ENV SEGMENTIO_KEY=$segmentio_key +ARG ga_id +ENV GA_ID=$ga_id +ARG ga_secret +ENV GA_SECRET=$ga_secret + # Step 8: Set Docker entry point for DIND (Docker-in-Docker) ENTRYPOINT ["tini", "--", "/usr/local/bin/entrypoint.sh"] diff --git a/build/kind/entrypoint.sh b/build/kind/entrypoint.sh index e02303766f..a3450a041a 100644 --- a/build/kind/entrypoint.sh +++ b/build/kind/entrypoint.sh @@ -8,15 +8,176 @@ log() { echo "[INFO] $1" } +_detect_arch() { + case $(uname -m) in + amd64|x86_64) echo "x86_64" + ;; + arm64|aarch64) echo "arm64" + ;; + i386) echo "i386" + ;; + *) echo "Unsupported processor architecture"; + ;; + esac +} + +_detect_os(){ + case $(uname) in + Linux) echo "Linux" + ;; + Darwin) echo "Darwin" + ;; + Windows) echo "Windows" + ;; + esac +} + +_detect_version() { + local tag + + tag="$( + curl -s "https://api.github.com/repos/kubeshop/testkube/releases/latest" \ + 2>/dev/null \ + | jq -r '.tag_name' \ + )" + + echo "${tag/#v/}" # remove leading v if present + +} + +_calculate_machine_id() { + local hash + +# Calculate hash using md5sum + hash=$(echo -n "$(hostname)" | md5sum | awk '{print $1}') + + echo "$hash" +} + +version="$(_detect_version)" +arch="$(_detect_arch)" +os="$(_detect_os)" +machine_id="$(_calculate_machine_id)" + +# Function to send event message to Segment.io +send_event_to_segment() { + local event="$1" + local error_code="$2" + local error_type="$3" + local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + + # Prepare the JSON payload + local payload=$(cat <