Skip to content

Commit

Permalink
Fix script with shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbreno committed Oct 14, 2024
1 parent 572f39b commit 5151e88
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions release/rancher/rancher.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ const checkRancherRCDepsTemplate = `{{- define "componentsFile" -}}
{{- end}}
{{ end }}`

const updateDashboardReferencesScript = `#!/bin/bash
const updateDashboardReferencesScript = `#!/bin/sh
# Enable verbose mode and exit on any error
set -ex
Expand All @@ -1017,33 +1017,33 @@ git fetch upstream
git stash
# Delete the branch if it exists, then create a new one based on upstream
git branch -D "${BRANCH_NAME}" &>/dev/null || true
git branch -D "${BRANCH_NAME}" > /dev/null 2>&1 || true
git checkout -B "${BRANCH_NAME}" upstream/{{.RancherReleaseBranch}}
# git clean -xfd
# Function to update the file
update_file() {
local sed_cmd
# Set the appropriate sed command based on the OS
case ${OS} in
Darwin)
sed_cmd="sed -i '' "
;;
Linux)
sed_cmd="sed -i"
;;
*)
>&2 echo "$(OS) not supported yet"
exit 1
;;
_update_file_sed_cmd=""
# Set the appropriate sed command based on the OS
case "${OS}" in
Darwin)
_update_file_sed_cmd="sed -i ''"
;;
Linux)
_update_file_sed_cmd="sed -i"
;;
*)
echo "$(OS) not supported yet" >&2
exit 1
;;
esac
# Update CATTLE_UI_VERSION, removing leading 'v' if present (${VERSION#v} the '#v' removes the leading 'v')
$sed_cmd "s/ENV CATTLE_UI_VERSION .*/ENV CATTLE_UI_VERSION ${VERSION#v}/" "$FILENAME"
# Update CATTLE_UI_VERSION, removing leading 'v' if present (${VERSION#v} the '#v' removes the leading 'v')
${_update_file_sed_cmd} "s/ENV CATTLE_UI_VERSION .*/ENV CATTLE_UI_VERSION ${VERSION#v}/" "${FILENAME}"
# Update CATTLE_DASHBOARD_UI_VERSION
$sed_cmd "s/ENV CATTLE_DASHBOARD_UI_VERSION .*/ENV CATTLE_DASHBOARD_UI_VERSION $VERSION/" "$FILENAME"
# Update CATTLE_DASHBOARD_UI_VERSION
${_update_file_sed_cmd} "s/ENV CATTLE_DASHBOARD_UI_VERSION .*/ENV CATTLE_DASHBOARD_UI_VERSION ${VERSION}/" "${FILENAME}"
}
# Run the update function
Expand Down

0 comments on commit 5151e88

Please sign in to comment.