Fixing pitfall due to failure of following the DRY principle
@@ -134,17 +134,7 @@ function verifyZitiVersionExists {
return 1
fi
- ZITI_ARCH="amd64"
- detected_arch="$(uname -m)"
- # Apple M1 silicon
- if [[ "${detected_arch}" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" == "darwin" ]]; then
- echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")"
- # LLVM 64 bit backends have merged so some versions of *nix use aarch64 while others use arm64 for parity with Apple
- elif [[ "${detected_arch}" == *"aarch64"* ]] || [[ "${detected_arch}" == *"arm64"* ]]; then
- ZITI_ARCH="arm64"
- elif [[ "${detected_arch}" == *"arm"* ]]; then
- ZITI_ARCH="arm"
- fi
+ detectArchitecture
unset ZITI_BINARIES_VERSION
@@ -162,6 +152,20 @@ function verifyZitiVersionExists {
echo "ZITI_BINARIES_VERSION: ${ZITI_BINARIES_VERSION}"
}
+function detectArchitecture {
+ ZITI_ARCH="amd64"
+ detected_arch="$(uname -m)"
+ # Apple M1 silicon
+ if [[ "${detected_arch}" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" == "darwin" ]]; then
+ echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")"
+ # LLVM 64 bit backends have merged so some versions of *nix use aarch64 while others use arm64 for parity with Apple
+ elif [[ "${detected_arch}" == *"aarch64"* ]] || [[ "${detected_arch}" == *"arm64"* ]]; then
+ ZITI_ARCH="arm64"
+ elif [[ "${detected_arch}" == *"arm"* ]]; then
+ ZITI_ARCH="arm"
+ fi
+}
+
function getLatestZitiVersion {
setupZitiHome
@@ -169,12 +173,7 @@ function getLatestZitiVersion {
return 1
fi
- ZITI_ARCH="amd64"
- if [[ "$(uname -a)" == *"arm"* ]] && [[ "${ZITI_OSTYPE}" == "darwin" ]]; then
- echo -e "$(YELLOW "WARN: It has been detected that you are using an Apple computer with ARM architecture. Deployment of Apple ARM architecture distributions is currently unsupported through git, the installer will pull darwin amd distribution instead.")"
- elif [[ "$(uname -a)" == *"arm"* ]]; then
- ZITI_ARCH="arm"
- fi
+ detectArchitecture
unset ZITI_BINARIES_VERSION
