[feat] Setup end-user environment - #1029
Conversation
WalkthroughA new Bash script, Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Andrei Kvapil (@kvaps) pls check |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
scripts/user_setup_env.sh (5)
27-29: Quote logged messages for safety.
Inlog(), consider quoting$1to safely handle messages with special characters.-function log() { - echo "$(date '+%d-%m-%Y %H:%M:%S') - $1" -} +function log() { + echo "$(date '+%d-%m-%Y %H:%M:%S') - \"$1\"" +}
49-59: Make krew installation idempotent and clean up temp artifacts.
If/tmp/krewalready exists,mkdirwill fail, and leftover files may persist across runs. Usemktemp -dor clear the directory, and remove temp folders after installation. Also, instead of sourcing.bashrcdirectly, instruct the user to restart their shell or append a notice.-function install_krew() { - mkdir /tmp/krew && tar -xzf "/tmp/${KREW}.tar.gz" -C /tmp/krew/ - "/tmp/krew/${KREW}" install krew +function install_krew() { + local tmpdir + tmpdir=$(mktemp -d) + tar -xzf "/tmp/${KREW}.tar.gz" -C "$tmpdir" + "$tmpdir/${KREW}" install krew + rm -rf "$tmpdir" printf '# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc - source ~/.bashrc + log "Added krew to PATH; restart your shell to apply." }🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 58-58: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
88-96: Clean up Helm temp directory and prevent collisions.
/tmp/helmmay persist between runs. Usemktemp -dand remove it after moving the binary.-function install_helm() { +function install_helm() { log "Installing Helm" - mkdir /tmp/helm && tar -xzf /tmp/helm.tar.gz -C /tmp/helm/ - sudo mv "/tmp/helm/${OS}-${ARCH}/helm" /usr/local/bin/helm + local tmphelm + tmphelm=$(mktemp -d) + tar -xzf /tmp/helm.tar.gz -C "$tmphelm" + sudo mv "$tmphelm/${OS}-${ARCH}/helm" /usr/local/bin/helm sudo chown 0:0 /usr/local/bin/helm sudo chmod 0755 /usr/local/bin/helm + rm -rf "$tmphelm" }
105-113: Use temporary directory for FluxCD extraction.
Similar to Helm and krew, protect against stale/tmp/fluxfolders by leveragingmktemp -dand cleanup.-function install_fluxcd() { +function install_fluxcd() { log "Installing FluxCD" - mkdir /tmp/flux && tar -xzf /tmp/flux.tar.gz -C /tmp/flux/ - sudo mv /tmp/flux/flux /usr/local/bin/flux + local tmpflux + tmpflux=$(mktemp -d) + tar -xzf /tmp/flux.tar.gz -C "$tmpflux" + sudo mv "$tmpflux/flux" /usr/local/bin/flux sudo chown 0:0 /usr/local/bin/flux sudo chmod 0755 /usr/local/bin/flux + rm -rf "$tmpflux" }
116-116: Guard script execution when sourced.
Directly callinguser_setup_envon load prevents safe sourcing. Wrap in:if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then user_setup_env fipackages/apps/vm-instance/templates/vm.yaml (1)
97-118: Suggest DRY’ing repeated cloudinitdisk blocks.
The three conditional branches each declare identical keys (- name: cloudinitdisk,cloudInitNoCloud:). Consider collapsing common YAML structure and vary onlysecretRefvs.userData.For example, extract the disk name and volume into a single block and template the inner fields.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/apps/versions_map(2 hunks)packages/apps/virtual-machine/Chart.yaml(1 hunks)packages/apps/vm-instance/Chart.yaml(1 hunks)packages/apps/vm-instance/templates/vm.yaml(1 hunks)scripts/user_setup_env.sh(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
scripts/user_setup_env.sh
[warning] 58-58: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test
🔇 Additional comments (4)
packages/apps/vm-instance/Chart.yaml (1)
20-20: Approve chart version bump to 0.7.2.
This aligns with the updated version inversions_map. No other template changes detected.packages/apps/virtual-machine/Chart.yaml (1)
20-20: Approve chart version bump to 0.10.2.
Version bump is consistent with theversions_mapupdate and no template changes are required.packages/apps/versions_map (2)
174-174: Approve mapping update for virtual-machine 0.10.2.
The removed 0.10.1 entry was correctly replaced with 0.10.2 HEAD.
187-187: Approve mapping update for vm-instance 0.7.2.
Entry for 0.7.2 HEAD matches the bumped chart version.
| curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" | ||
| sudo mv /tmp/kubectl /usr/local/bin/kubectl | ||
| sudo chown 0:0 /usr/local/bin/kubectl | ||
| sudo chmod 0755 /usr/local/bin/kubectl | ||
| } |
There was a problem hiding this comment.
Fix conflicting curl flags.
Using both -o and -O is contradictory and may cause unexpected file naming. Remove -O when specifying the output file.
- curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl"
+ curl -o /tmp/kubectl -fsL "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" | |
| sudo mv /tmp/kubectl /usr/local/bin/kubectl | |
| sudo chown 0:0 /usr/local/bin/kubectl | |
| sudo chmod 0755 /usr/local/bin/kubectl | |
| } | |
| curl -o /tmp/kubectl -fsL "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" | |
| sudo mv /tmp/kubectl /usr/local/bin/kubectl | |
| sudo chown 0:0 /usr/local/bin/kubectl | |
| sudo chmod 0755 /usr/local/bin/kubectl | |
| } |
🤖 Prompt for AI Agents
In scripts/user_setup_env.sh around lines 43 to 47, the curl command uses both
-o and -O flags, which conflict because -o specifies a filename and -O saves
with the remote name. Remove the -O flag and keep only -o with the desired
output path to ensure the file is saved correctly without naming conflicts.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (4)
scripts/user_setup_env.sh (4)
43-47: Remove conflicting curl flagsAvoid using both
-oand-Otogether. Keep-ofor specifying the output path:- curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" + curl -o /tmp/kubectl -fsL "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl"
52-54: Fix curl invocation when downloading krewSimilarly, drop
-Oto ensure the output file is named correctly:- curl -o "/tmp/${KREW}.tar.gz" -fsLO "https://github.com/kubernetes-sigs/krew/releases/download/${krew_version}/${KREW}.tar.gz" + curl -o "/tmp/${KREW}.tar.gz" -fsL "https://github.com/kubernetes-sigs/krew/releases/download/${krew_version}/${KREW}.tar.gz"
1-2: 🛠️ Refactor suggestionAdd strict mode for robust error handling
Enable fail-fast behavior and protect against unset variables by adding
set -euo pipefailandIFSimmediately after the shebang.#!/bin/bash +set -euo pipefail +IFS=$'\n\t'
10-10:⚠️ Potential issueCorrect architecture normalization to handle all variants
Add mapping for 32-bit x86 (i[3-6]86) and reorder patterns to avoid mis-normalizing aarch64. For example:
-ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" +ARCH="$(uname -m | sed \ + -e 's/x86_64/amd64/' \ + -e 's/i[3-6]86/386/' \ + -e 's/aarch64$/arm64/' \ + -e 's/\(arm\)\(64\)\?.*/\1\2/')"
🧹 Nitpick comments (3)
scripts/user_setup_env.sh (3)
31-38: Use temporary files safelyAvoid static
/tmpnames to prevent race conditions. Usemktempfor downloads:function install_talm() { log "Installing talm" - - curl -o /tmp/talm -fsL "https://github.com/cozystack/talm/releases/download/${talm_version}/talm-${OS}-${ARCH}" - sudo mv /tmp/talm /usr/local/bin/talm + tmp=$(mktemp) + curl -fsL "https://github.com/cozystack/talm/releases/download/${talm_version}/talm-${OS}-${ARCH}" -o "$tmp" + sudo mv "$tmp" /usr/local/bin/talm sudo chown 0:0 /usr/local/bin/talm sudo chmod 0755 /usr/local/bin/talm }
57-59: Prevent duplicate PATH entries and guide shell reloadGuard against multiple
.bashrcappends and inform the user to reload:- printf '# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc - source ~/.bashrc + grep -qxF 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' ~/.bashrc || \ + printf '# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc + echo "Run 'source ~/.bashrc' or reopen your shell to activate krew."🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 58-58: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
27-29: Enhance log function to support multiple argumentsSwitch from
$1to$*so all passed parameters are logged:function log() { - echo "$(date '+%d-%m-%Y %H:%M:%S') - $1" + echo "$(date '+%d-%m-%Y %H:%M:%S') - $*" }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scripts/user_setup_env.sh(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
scripts/user_setup_env.sh
[warning] 58-58: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build
| if [[ ! $(kubectl krew version) ]]; then | ||
| log "krew is not installed, install it first!" | ||
| return 1 | ||
| fi |
There was a problem hiding this comment.
Correct plugin installation check
The current if [[ ! $(kubectl krew version) ]] test is unreliable. Instead, test the command’s exit status:
- if [[ ! $(kubectl krew version) ]]; then
+ if ! kubectl krew version >/dev/null 2>&1; then
log "krew is not installed, install it first!"
return 1📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [[ ! $(kubectl krew version) ]]; then | |
| log "krew is not installed, install it first!" | |
| return 1 | |
| fi | |
| if ! kubectl krew version >/dev/null 2>&1; then | |
| log "krew is not installed, install it first!" | |
| return 1 | |
| fi |
🤖 Prompt for AI Agents
In scripts/user_setup_env.sh around lines 64 to 67, the check for whether krew
is installed uses command substitution which is unreliable. Replace the
condition to test the exit status of `kubectl krew version` directly by running
the command and checking if it fails, for example using `if ! kubectl krew
version > /dev/null 2>&1; then`. This ensures a reliable check based on the
command's success or failure.
bb963f2 to
57bdd6e
Compare
|
Andrei Kvapil (@kvaps) |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (6)
hack/user_setup_env.sh (6)
3-12: Standardize version variables
You're mixingv-prefixed (e.g.talm_version="v0.13.0") and bare versions (fluxcd_version="2.6.1"). This inconsistency can lead to invalid URLs or redundantvcharacters. Either include thevprefix in all version vars or strip it when constructing URLs.
14-25: Halt on installer failure
All installers are chained without handling individual failures. Withset -euo pipefail(per above), the script will exit on a failed install, but it's worth documenting this or wrapping calls to provide clearer context on which step failed.
27-29: Fix typo in log message
log "Start setuping user environment"→ typo “setuping”. Consider:-log "Start setuping user environment" +log "Starting setup of user environment"
31-38: DRY up repetitive install functions
Eachinstall_*repeats download → mv → chown → chmod. Extract a helper:install_binary() { local name=$1 url=$2 curl -fsSL "$url" -o "/tmp/$name" sudo mv "/tmp/$name" "/usr/local/bin/$name" sudo chown 0:0 "/usr/local/bin/$name" sudo chmod 0755 "/usr/local/bin/$name" }Then call:
install_binary talm "https://.../${talm_version}/talm-${OS}-${ARCH}"This reduces duplication and eases future maintenance.
Also applies to: 40-47, 79-86, 88-96, 105-113
98-103: Idempotent Helm plugin installation
Re-running will fail ifdiffis already installed. Wrap with:helm plugin list | grep -q '^diff ' || \ helm plugin install https://github.com/databus23/helm-diff
116-116: Prevent unintended execution on sourcing
If someone sources this script, it will auto-run. Wrap the invocation:if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then user_setup_env fiThis clarifies entrypoint behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Makefile(1 hunks)hack/user_setup_env.sh(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- Makefile
🧰 Additional context used
🪛 Shellcheck (0.10.0)
hack/user_setup_env.sh
[warning] 58-58: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
| KREW="krew-${OS}_${ARCH}" | ||
| curl -o "/tmp/${KREW}.tar.gz" -fsLO "https://github.com/kubernetes-sigs/krew/releases/download/${krew_version}/${KREW}.tar.gz" | ||
| mkdir /tmp/krew && tar -xzf "/tmp/${KREW}.tar.gz" -C /tmp/krew/ | ||
| "/tmp/krew/${KREW}" install krew | ||
| log "configure .bashrc for krew" | ||
| printf '# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc | ||
| source ~/.bashrc | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Make krew setup idempotent & satisfy SC1090
- Use
mkdir -p /tmp/krewand clean any stale data. - Guard appending to
~/.bashrcto avoid duplicates:grep -qxF 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' ~/.bashrc || \ printf '\n# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc
- To appease ShellCheck SC1090:
# shellcheck source=/dev/null source ~/.bashrc
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 58-58: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
🤖 Prompt for AI Agents
In hack/user_setup_env.sh around lines 52 to 59, make the krew setup idempotent
by using mkdir -p /tmp/krew and removing any existing contents in /tmp/krew
before extracting. Prevent duplicate PATH entries in ~/.bashrc by checking if
the export line already exists using grep before appending it. Add a shellcheck
directive comment before sourcing ~/.bashrc to satisfy SC1090 by including "#
shellcheck source=/dev/null" above the source command.
| #!/bin/bash | ||
|
|
||
| #### variables list |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Enforce strict error handling
The script currently risks silent failures and uninitialized variables. Add at the top:
+ set -euo pipefail
+ if [[ $EUID -ne 0 ]]; then
+ echo "Please run as root or with sudo"
+ exit 1
+ fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #!/bin/bash | |
| #### variables list | |
| #!/bin/bash | |
| + set -euo pipefail | |
| + if [[ $EUID -ne 0 ]]; then | |
| + echo "Please run as root or with sudo" | |
| + exit 1 | |
| + fi | |
| #### variables list |
🤖 Prompt for AI Agents
In hack/user_setup_env.sh at the beginning of the file (lines 1 to 3), add
strict error handling by including 'set -euo pipefail' right after the shebang
line. This will ensure the script exits on errors, treats unset variables as
errors, and fails on pipeline errors, preventing silent failures and
uninitialized variables.
| function install_krew_plugins() { | ||
| log "Installing krew plugins..." | ||
|
|
||
| if [[ ! $(kubectl krew version) ]]; then | ||
| log "krew is not installed, install it first!" | ||
| return 1 | ||
| fi | ||
|
|
||
| log "Installing krew plugin: node-shell" | ||
| kubectl krew install node-shell | ||
|
|
||
| log "Installing krew plugin: virt" | ||
| kubectl krew install virt | ||
|
|
||
| log "Installing krew plugin: oidc-login" | ||
| kubectl krew install oidc-login | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Improve krew plugin install check
Testing with [[ ! $(kubectl krew version) ]] can misinterpret output. Prefer checking exit code:
- if [[ ! $(kubectl krew version) ]]; then
+ if ! kubectl krew version >/dev/null 2>&1; then
log "krew is not installed, install it first!"
return 1Also guard against re-installing plugins already present.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function install_krew_plugins() { | |
| log "Installing krew plugins..." | |
| if [[ ! $(kubectl krew version) ]]; then | |
| log "krew is not installed, install it first!" | |
| return 1 | |
| fi | |
| log "Installing krew plugin: node-shell" | |
| kubectl krew install node-shell | |
| log "Installing krew plugin: virt" | |
| kubectl krew install virt | |
| log "Installing krew plugin: oidc-login" | |
| kubectl krew install oidc-login | |
| } | |
| function install_krew_plugins() { | |
| log "Installing krew plugins..." | |
| if ! kubectl krew version >/dev/null 2>&1; then | |
| log "krew is not installed, install it first!" | |
| return 1 | |
| fi | |
| log "Installing krew plugin: node-shell" | |
| kubectl krew install node-shell | |
| log "Installing krew plugin: virt" | |
| kubectl krew install virt | |
| log "Installing krew plugin: oidc-login" | |
| kubectl krew install oidc-login | |
| } |
🤖 Prompt for AI Agents
In hack/user_setup_env.sh around lines 61 to 77, the check for krew installation
uses output testing which can be unreliable. Change this to check the exit code
of `kubectl krew version` instead. Additionally, before installing each krew
plugin, verify if the plugin is already installed to avoid redundant
installations.
| curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" | ||
| sudo mv /tmp/kubectl /usr/local/bin/kubectl |
There was a problem hiding this comment.
Remove conflicting curl flags
Using both -o /tmp/kubectl and -O is ambiguous—-O overrides -o. Drop -O so the download lands in /tmp/kubectl as intended:
-curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl"
+curl -fsSL -o /tmp/kubectl "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" | |
| sudo mv /tmp/kubectl /usr/local/bin/kubectl | |
| curl -fsSL -o /tmp/kubectl "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" | |
| sudo mv /tmp/kubectl /usr/local/bin/kubectl |
🤖 Prompt for AI Agents
In hack/user_setup_env.sh at lines 43-44, the curl command uses both -o and -O
flags, which conflict because -O overrides -o. Remove the -O flag so the file
downloads correctly to /tmp/kubectl as intended.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (4)
hack/user_setup_env.sh (4)
74-89: Robust check & idempotent plugin installation
[[ ! $(kubectl krew version) ]]mis-interprets output; rely on exit status.
Also skip plugins already present to avoid error spam.-if [[ ! $(kubectl krew version) ]]; then +if ! kubectl krew version >/dev/null 2>&1; then … fi … -kubectl krew install node-shell +kubectl krew list | grep -q '^node-shell$' || kubectl krew install node-shell(repeat for other plugins)
1-3: Add strict error-handling & root guard at script entry
The script still risks silent failures and uninitialised variables, and CI shows “permission denied”. Addset -euo pipefailand a root / sudo guard right after the she-bang.#!/bin/bash +set -euo pipefail + +if [[ $EUID -ne 0 ]]; then + echo "Please run as root or with sudo" + exit 1 +fi
56-57: Conflictingcurlflags (-o+-O)
-Ooverrides-o⇒ the file lands in the current dir, not/tmp. Drop-O.-curl -o /tmp/kubectl -fsLO … +curl -fsSL -o /tmp/kubectl …
62-72: Make krew install idempotent, fix curl flags & satisfy SC1090
mkdirfails second run; usemkdir -pand wipe stale files.- Same
-o/-Oflag issue.- Appending to
~/.bashrcon every run duplicates PATH.- Add ShellCheck directive before
source.KREW="krew-${OS}_${ARCH}" -curl -o "/tmp/${KREW}.tar.gz" -fsLO "https://github.com/kubernetes-sigs/krew/releases/download/${krew_version}/${KREW}.tar.gz" -mkdir /tmp/krew && tar -xzf "/tmp/${KREW}.tar.gz" -C /tmp/krew/ +curl -fsSL -o "/tmp/${KREW}.tar.gz" "https://github.com/kubernetes-sigs/krew/releases/download/${krew_version}/${KREW}.tar.gz" +mkdir -p /tmp/krew && rm -rf /tmp/krew/* +tar -xzf "/tmp/${KREW}.tar.gz" -C /tmp/krew/ … -printf '# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc - source ~/.bashrc +# Guard duplicate PATH entry +grep -qxF 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' ~/.bashrc || \ + printf '\n# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc +# shellcheck source=/dev/null +source ~/.bashrc
🧹 Nitpick comments (3)
hack/user_setup_env.sh (3)
11-14: Remove noisy unconditional echo
echo $ARCHspams every invocation (including CI logs) and provides no functional value.-echo $ARCH
30-32: Quote log payload to preserve whitespace
Protect against word-splitting in theloghelper.-echo "$(date '+%d-%m-%Y %H:%M:%S') - $1" +echo "$(date '+%d-%m-%Y %H:%M:%S') - $*"
62-62: Inconsistent function definition style
Every other function usesfunction name(), butinstall_krew()omits thefunctionkeyword. Stick to one style.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Makefile(1 hunks)hack/user_setup_env.sh(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- Makefile
🧰 Additional context used
🪛 Shellcheck (0.10.0)
hack/user_setup_env.sh
[warning] 71-71: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
🪛 GitHub Actions: Pull Request
hack/user_setup_env.sh
[error] 1-1: Permission denied when trying to execute the script. This caused 'make build' to fail with error code 127.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: pre-commit
🔇 Additional comments (2)
hack/user_setup_env.sh (2)
47-51: Ensure downloaded binary is executable before move
curl … > /tmp/talmleaves the file without +x; rely onchmodafter the move, not before—OK.
(No action required.)
129-129: Mark script executable in repo or call viabash
CI failure “permission denied” suggests the file lacks the executable bit. Either:chmod +x hack/user_setup_env.shor invoke it with an explicit interpreter (
bash hack/user_setup_env.sh) in the Makefile.
| curl -sSL https://github.com/cozystack/cozypkg/releases/download/${cozypkg_version}/cozypkg-${OS}-${ARCH}.tar.gz | \ | ||
| tar xzvf - cozypkg | ||
| sudo mv /tmp/cozypkg /usr/local/bin/cozypkg | ||
| sudo chown 0:0 /usr/local/bin/cozypkg | ||
| sudo chmod 0755 /usr/local/bin/cozypkg |
There was a problem hiding this comment.
Broken extraction path for cozypkg
The archive is unpacked into the CWD, yet we later mv /tmp/cozypkg …, producing “No such file” on fresh machines.
-curl -sSL … | tar xzvf - cozypkg
-sudo mv /tmp/cozypkg /usr/local/bin/cozypkg
+curl -sSL … | tar -xzvf - -C /tmp
+sudo mv /tmp/cozypkg /usr/local/bin/cozypkg📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| curl -sSL https://github.com/cozystack/cozypkg/releases/download/${cozypkg_version}/cozypkg-${OS}-${ARCH}.tar.gz | \ | |
| tar xzvf - cozypkg | |
| sudo mv /tmp/cozypkg /usr/local/bin/cozypkg | |
| sudo chown 0:0 /usr/local/bin/cozypkg | |
| sudo chmod 0755 /usr/local/bin/cozypkg | |
| curl -sSL https://github.com/cozystack/cozypkg/releases/download/${cozypkg_version}/cozypkg-${OS}-${ARCH}.tar.gz | \ | |
| tar -xzvf - -C /tmp | |
| sudo mv /tmp/cozypkg /usr/local/bin/cozypkg | |
| sudo chown 0:0 /usr/local/bin/cozypkg | |
| sudo chmod 0755 /usr/local/bin/cozypkg |
🤖 Prompt for AI Agents
In hack/user_setup_env.sh around lines 37 to 41, the script extracts the cozypkg
archive into the current directory but then tries to move /tmp/cozypkg, which
does not exist, causing an error. Fix this by extracting the archive directly
into /tmp or adjusting the mv command to move cozypkg from the actual extraction
location to /usr/local/bin/cozypkg.
Add script to automatically install all required packages on end-user system Linux distro independent, MacOS ready Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (5)
hack/user_setup_env.sh (5)
1-3: Add strict mode & privilege guard at script start
Withoutset -euo pipefail, failures go unnoticed; uninitialised vars or broken pipes will silently continue. Also, many installs require root – abort early when the user is non-root instead of lettingsudoprompts break CI.#!/bin/bash +set -euo pipefail +if [[ $EUID -ne 0 ]]; then + echo "Please run with sudo or as root" + exit 1 +fi
37-41: Broken extraction path: cozypkg never ends up in /tmp
tar xzvf - cozypkgextracts into CWD yet you latermv /tmp/cozypkg …, which fails on fresh machines.-curl -sSL … | tar xzvf - cozypkg -sudo mv /tmp/cozypkg /usr/local/bin/cozypkg +curl -sSL … | tar -xzvf - -C /tmp +sudo mv /tmp/cozypkg /usr/local/bin/cozypkg
56-56: Conflicting curl flags overwrite target file
-o /tmp/kubectland-Otogether cause-Oto win, the binary lands in$PWD. Use one flag:-curl -o /tmp/kubectl -fsLO "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl" +curl -fsSL -o /tmp/kubectl "https://dl.k8s.io/release/${kubectl_version}/bin/${OS}/${ARCH}/kubectl"
65-72: Make krew setup idempotent & silence ShellCheck SC1090
Repeated runs keep appending PATH lines and sourcing non-constant paths trips SC1090.-mkdir /tmp/krew && tar -xzf "/tmp/${KREW}.tar.gz" -C /tmp/krew/ +mkdir -p /tmp/krew && rm -rf /tmp/krew/* +tar -xzf "/tmp/${KREW}.tar.gz" -C /tmp/krew/ -printf '# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc +# Guard against duplicates +grep -qxF 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' ~/.bashrc || \ + printf '\n# krew\nexport PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"\n' >> ~/.bashrc +# shellcheck source=/dev/null
77-80: Use exit code to detect krew instead of output test
[[ ! $(kubectl krew version) ]]mis-fires when command prints to stderr. Prefer exit status:-if [[ ! $(kubectl krew version) ]]; then +if ! kubectl krew version >/dev/null 2>&1; then
🧹 Nitpick comments (1)
hack/user_setup_env.sh (1)
12-12: Remove stray debug echo
echo $ARCHpollutes stdout and interferes with callers piping the output.-echo $ARCH +# echo "$ARCH" # Uncomment for debugging if needed
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Makefile(1 hunks)hack/user_setup_env.sh(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- Makefile
🧰 Additional context used
🧠 Learnings (1)
hack/user_setup_env.sh (1)
Learnt from: lllamnyp
PR: cozystack/cozystack#1025
File: packages/apps/kafka/charts/cozy-lib:1-1
Timestamp: 2025-06-04T06:22:17.306Z
Learning: Files in packages/apps/*/charts/cozy-lib that contain the path "../../../library/cozy-lib" are symbolic links, not regular files. Git diffs may display symlinks as regular files with their target path as content, which can be misleading in code review.
🪛 Shellcheck (0.10.0)
hack/user_setup_env.sh
[warning] 71-71: ShellCheck can't follow non-constant source. Use a directive to specify location.
(SC1090)
🪛 GitHub Actions: Pull Request
hack/user_setup_env.sh
[error] 1-1: Permission denied when trying to execute the script. This caused 'make build' to fail with error code 127.
| } | ||
|
|
||
|
|
||
| user_setup_env No newline at end of file |
There was a problem hiding this comment.
CI failure: script lacks execute bit – call via bash or chmod +x
GitHub Actions shows “Permission denied”. Either commit the file with chmod +x or invoke it explicitly:
-build-deps:
- ./hack/user_setup_env.sh
+build-deps:
+ bash hack/user_setup_env.shFailing to fix this blocks the whole pipeline.
🤖 Prompt for AI Agents
In hack/user_setup_env.sh at line 129, the script is being called without
execute permissions, causing a "Permission denied" error in CI. Fix this by
either adding execute permissions to the script file with chmod +x before
committing or by changing the invocation in the Makefile or CI config to
explicitly call it with bash, for example, replacing ./hack/user_setup_env.sh
with bash hack/user_setup_env.sh.
|
This PR has had no activity for 60 days and was marked |
|
This has been open for well over a year and the pins have aged out. The script installs kubectl v1.33.1, helm v3.18.2 and talm v0.13.0 against a tree that now defaults tenant clusters to v1.35, so merging it as-is would set up a stale toolchain for anyone who runs it. Two things worth deciding before it moves. Are you still interested in refreshing it? And should this be a Makefile target that downloads binaries at all: main has since gained If you have moved on, say so and I will close it. |
|
Closing this, and I want to be clear that it is not a rejection of the idea. The gap you spotted is real: nothing in this repository tells a newcomer how to get talm, cozypkg, virtctl and the rest onto their machine. But this repository is not where that answer belongs. Developer tooling is documented on the website, per The form is the other half of it. A Makefile target that downloads binaries into a user's system competes with whatever package manager they already use, and it commits us to chasing versions forever. This PR shows how that ends: it pins kubectl v1.33.1 while the tree now defaults tenant clusters to v1.35, so merging it today would hand people a stale toolchain. The repo's own answer to the same need is If you are up for turning this into a page on the website instead, that would be genuinely useful and I would review it. |
Add script to automatically install all required packages on end-user system.
Linux distro independent, MacOS ready
Summary by CodeRabbit
New Features
Chores