Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 2 additions & 42 deletions bin/build_ztunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,50 +76,11 @@ function download_ztunnel_if_necessary () {
cp -f "${2}" "${TARGET_OUT_LINUX}/ztunnel"
}

function maybe_build_ztunnel() {
# TODO detect git changes or something to avoid unnecessarily building
# BUILD_ZTUNNEL=1 with no BUILD_ZTUNNEL_REPO tries to infer BUILD_ZTUNNEL_REPO
if [[ "${BUILD_ZTUNNEL_REPO:-}" == "" ]] && [[ "${BUILD_ZTUNNEL:-}" != "" ]]; then
local ZTUNNEL_DIR
ZTUNNEL_DIR="$(pwd)/../ztunnel"
if [[ -d "${ZTUNNEL_DIR}" ]]; then
BUILD_ZTUNNEL_REPO="${ZTUNNEL_DIR}"
else
echo "No directory at ${ZTUNNEL_DIR}"
return
fi
fi
if [[ "${BUILD_ZTUNNEL_REPO:-}" == "" ]]; then
return
fi

if ! which cargo; then
echo "the rust toolchain (cargo, etc) is required for building ztunnel"
return 1
fi

pushd "${BUILD_ZTUNNEL_REPO}"
cargo build --profile="${BUILD_ZTUNNEL_PROFILE:-dev}" ${BUILD_ZTUNNEL_TARGET:+--target=${BUILD_ZTUNNEL_TARGET}}

local ZTUNNEL_BIN_PATH
if [[ "${BUILD_ZTUNNEL_PROFILE:-dev}" == "dev" ]]; then
ZTUNNEL_BIN_PATH=debug
else
ZTUNNEL_BIN_PATH="${BUILD_ZTUNNEL_PROFILE}"
fi
ZTUNNEL_BIN_PATH="out/rust/${BUILD_ZTUNNEL_TARGET:+${BUILD_ZTUNNEL_TARGET}/}${ZTUNNEL_BIN_PATH}/ztunnel"

echo "Copying $(pwd)/${ZTUNNEL_BIN_PATH} to ${TARGET_OUT_LINUX}/ztunnel"
mkdir -p "${TARGET_OUT_LINUX}"
cp "${ZTUNNEL_BIN_PATH}" "${TARGET_OUT_LINUX}/ztunnel"
popd
}

# ztunnel binary vars (TODO handle debug builds, arm, darwin etc.)
ISTIO_ZTUNNEL_BASE_URL="${ISTIO_ZTUNNEL_BASE_URL:-https://storage.googleapis.com/istio-build/ztunnel}"
ISTIO_ZTUNNEL_BASE_URL="${ISTIO_ZTUNNEL_BASE_URL:-https://storage.googleapis.com/maistra-prow-testing/ztunnel}"

# If we are not using the default, assume its private and we need to authenticate
if [[ "${ISTIO_ZTUNNEL_BASE_URL}" != "https://storage.googleapis.com/istio-build/ztunnel" ]]; then
if [[ "${ISTIO_ZTUNNEL_BASE_URL}" != "https://storage.googleapis.com/istio-build/ztunnel" && "${ISTIO_ZTUNNEL_BASE_URL}" != "https://storage.googleapis.com/maistra-prow-testing/ztunnel" ]]; then
AUTH_HEADER="Authorization: Bearer $(gcloud auth print-access-token)"
export AUTH_HEADER
fi
Expand All @@ -133,5 +94,4 @@ ISTIO_ZTUNNEL_LINUX_DEBUG_DIR="${ISTIO_ZTUNNEL_LINUX_DEBUG_DIR:-${TARGET_OUT_LIN
ISTIO_ZTUNNEL_LINUX_RELEASE_PATH="${ISTIO_ZTUNNEL_LINUX_RELEASE_PATH:-${ISTIO_ZTUNNEL_LINUX_RELEASE_DIR}/${ISTIO_ZTUNNEL_LINUX_RELEASE_NAME}}"

set_download_command
maybe_build_ztunnel
download_ztunnel_if_necessary "${ISTIO_ZTUNNEL_RELEASE_URL}" "$ISTIO_ZTUNNEL_LINUX_RELEASE_PATH" "ztunnel"
2 changes: 1 addition & 1 deletion bin/update_ztunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cd "${ROOTDIR}"
function getSha() {
local dir result
dir=$(mktemp -d)
git clone --depth=1 "https://github.com/istio/${1}.git" -b "${UPDATE_BRANCH}" "${dir}"
git clone --depth=1 "https://github.com/openshift-service-mesh/${1}.git" -b "${UPDATE_BRANCH}" "${dir}"

result="$(cd "${dir}" && git rev-parse HEAD)"
rm -rf "${dir}"
Expand Down
2 changes: 1 addition & 1 deletion istio.deps
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"name": "ZTUNNEL_REPO_SHA",
"repoName": "ztunnel",
"file": "",
"lastStableSHA": "055baef94d1d1ec90859196ce015ac0bba587503"
"lastStableSHA": "f64fcbc3cf1cc47106187837bb9a6cf24e5e66b7"
}
]