Skip to content
Open
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
14 changes: 10 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ set -o noglob
# If set to true will not start k3s service.
#
# - INSTALL_K3S_VERSION
# Version of k3s to download from github. Will attempt to download from the
# Version of k3s to download. Will attempt to download from the
# stable channel if not specified.
#
# - INSTALL_K3S_COMMIT
# Commit of k3s to download from temporary cloud storage.
# * (for developer & QA use)
#
# - INSTALL_K3S_ARTIFACT_URL
# URL prefix for K3s release artifacts.
# Default is https://github.com/k3s-io/k3s/releases/download
#
# - INSTALL_K3S_PR
# PR build of k3s to download from Github Artifacts.
# * (for developer & QA use)
Expand Down Expand Up @@ -95,7 +99,7 @@ set -o noglob
# Channel to use for fetching k3s download URL.
# Defaults to 'stable'.

GITHUB_URL=${GITHUB_URL:-https://github.com/k3s-io/k3s/releases}
INSTALL_K3S_ARTIFACT_URL=${INSTALL_K3S_ARTIFACT_URL:-https://github.com/k3s-io/k3s/releases/download}
GITHUB_PR_URL=""
STORAGE_URL=https://k3s-ci-builds.s3.amazonaws.com
DOWNLOADER=
Expand Down Expand Up @@ -455,6 +459,7 @@ download() {

# --- download hash from github url ---
download_hash() {
VERSION_URLSAFE="$(echo ${VERSION_K3S} | sed 's/\+/%2B/g')"
if [ -n "${INSTALL_K3S_PR}" ]; then
info "Downloading hash ${GITHUB_PR_URL}"
curl -s -o ${TMP_ZIP} -H "Authorization: Bearer $GITHUB_TOKEN" -L ${GITHUB_PR_URL}
Expand All @@ -463,7 +468,7 @@ download_hash() {
if [ -n "${INSTALL_K3S_COMMIT}" ]; then
HASH_URL=${STORAGE_URL}/k3s${SUFFIX}-${INSTALL_K3S_COMMIT}.sha256sum
else
HASH_URL=${GITHUB_URL}/download/${VERSION_K3S}/sha256sum-${ARCH}.txt
HASH_URL=${INSTALL_K3S_ARTIFACT_URL}/${VERSION_URLSAFE}/sha256sum-${ARCH}.txt
fi
info "Downloading hash ${HASH_URL}"
download ${TMP_HASH} ${HASH_URL}
Expand Down Expand Up @@ -520,6 +525,7 @@ get_pr_artifact_url() {

# --- download binary from github url ---
download_binary() {
VERSION_URLSAFE="$(echo ${VERSION_K3S} | sed 's/\+/%2B/g')"
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VERSION_URLSAFE variable is computed identically in both download_hash() and download_binary() functions. Consider extracting this to a shared location or computing it once in get_release_version() after VERSION_K3S is set. This would improve maintainability and ensure consistency.

Copilot uses AI. Check for mistakes.
if [ -n "${INSTALL_K3S_PR}" ]; then
# Since Binary and Hash are zipped together, check if TMP_ZIP already exists
if ! [ -f ${TMP_ZIP} ]; then
Expand All @@ -532,7 +538,7 @@ download_binary() {
elif [ -n "${INSTALL_K3S_COMMIT}" ]; then
BIN_URL=${STORAGE_URL}/k3s${SUFFIX}-${INSTALL_K3S_COMMIT}
else
BIN_URL=${GITHUB_URL}/download/${VERSION_K3S}/k3s${SUFFIX}
BIN_URL=${INSTALL_K3S_ARTIFACT_URL}/${VERSION_URLSAFE}/k3s${SUFFIX}
fi
info "Downloading binary ${BIN_URL}"
download ${TMP_BIN} ${BIN_URL}
Expand Down
Loading