Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove old staging/devspaces/build-requirements/devspaces-*-pluginregistry folders from spmm-util server once they're outdated #1039

Open
wants to merge 1 commit into
base: devspaces-3-rhel-8
Choose a base branch
from
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
18 changes: 15 additions & 3 deletions product/copyVSIXToStage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
REMOTE_USER_AND_HOST="[email protected]"
MIDSTM_BRANCH=""
DS_VERSION=""
# optionally, delete old versions of devspaces-$DS_VERSION-pluginregistry
DELETE_OLD_VERSIONS=0

usage ()
{
echo "Usage: $0 -b devspaces-3.y-rhel-8 -v 3.y [-w WORKSPACE_DIR]
echo "Usage: $0 -b devspaces-3.y-rhel-8 -v 3.y [-w WORKSPACE_DIR] [--delete-old-versions]
"
exit
}
Expand All @@ -29,6 +31,7 @@ while [[ "$#" -gt 0 ]]; do
'-b') MIDSTM_BRANCH="$2"; shift 1;;
'-v') DS_VERSION="$2"; shift 1;; # 3.y.0
'-w') WORKSPACE="$2"; shift 1;;
'--delete-old-versions') DELETE_OLD_VERSIONS=1;;
esac
shift 1
done
Expand All @@ -37,8 +40,6 @@ if [[ ! "${MIDSTM_BRANCH}" ]]; then usage; fi
if [[ ! "${WORKSPACE}" ]]; then WORKSPACE=/tmp; fi
if [[ ! "$DS_VERSION" ]]; then DS_VERSION=$(curl -sSLo- "https://raw.githubusercontent.com/redhat-developer/devspaces/${MIDSTM_BRANCH}/dependencies/VERSION"); fi



STAGE_DIR="$WORKSPACE/devspaces-$DS_VERSION-pluginregistry"
SOURCE_DIR="$STAGE_DIR/sources"
PLUGIN_DIR="$STAGE_DIR/plugins"
Expand All @@ -50,3 +51,14 @@ mv *.tar.gz $SOURCE_DIR
# next, update existing build-requirements/$PLUGIN_DIR folder (or create it if it does not exist)
rsync -rlP "$STAGE_DIR" "$REMOTE_USER_AND_HOST:staging/devspaces/build-requirements"

# optionally, delete old versions of devspaces-$DS_VERSION-pluginregistry, keeping only the last 3 folders (eg., for 3.x=3.12, keep 3.10, 3.11, and 3.12)
if [[ $DELETE_OLD_VERSIONS -eq 1 ]]; then
OLD_VERSIONS="$(ssh "$REMOTE_USER_AND_HOST" "ls -1d staging/devspaces/build-requirements/devspaces-*-pluginregistry" 2>/dev/null | sort -V | head --lines=-3)"
for dir in $OLD_VERSIONS; do
echo "Remove old plugin registry folder: $dir ..."
ssh "$REMOTE_USER_AND_HOST" "rm -fr $dir"
done
REMAINING_VERSIONS="$(ssh "$REMOTE_USER_AND_HOST" "ls -1d staging/devspaces/build-requirements/devspaces-*-pluginregistry" 2>/dev/null | sort -V)"
echo "Available plugin registry folders:"
echo "$REMAINING_VERSIONS"
fi