Skip to content

Instantly share code, notes, and snippets.

@metcalfc
Last active December 22, 2023 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metcalfc/e080de6c23086dc151739fa8f30b6d66 to your computer and use it in GitHub Desktop.
Save metcalfc/e080de6c23086dc151739fa8f30b6d66 to your computer and use it in GitHub Desktop.
Update the Daytona Sample Index
#!/bin/bash
# https://blog.mdminhazulhaque.io/extract-patch-file-configmap
URL="https://raw.githubusercontent.com/daytonaio/samples-index/main/index.json"
# parse the arguments for --url
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-u|--url)
URL="$2"
shift
shift
;;
*)
shift
;;
esac
done
# error if no url is provided
if [[ -z "$URL" ]]; then
echo "ERROR: no url provided"
exit 1
fi
kubectl -n watkins get configmap watkins-dashboard -o go-template='{{index .data "configuration.json"}}' | \
jq --arg url "$URL" '.workspaceTemplatesIndexUrl = $url' > configuration.json
# trap the exit signal to delete configuration.json when the script exits
trap 'rm -f configuration.json' EXIT
echo "Replacing: $(kubectl -n watkins get configmap watkins-dashboard -o go-template='{{index .data "configuration.json"}}' | jq -r .workspaceTemplatesIndexUrl)"
echo "With: $URL"
kubectl -n watkins create configmap watkins-dashboard --from-file=configuration.json=configuration.json --dry-run=client -o yaml | \
kubectl -n watkins patch configmaps watkins-dashboard --type merge --patch-file /dev/stdin
# restart the watkins-dashboard pod
kubectl -n watkins rollout restart deployment watkins-dashboard
kubectl -n watkins rollout status deployment watkins-dashboard --watch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment