From a9be1aea30cff64ff72e176b36fd3f1fdd588c65 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 18 Nov 2020 17:02:49 +0100 Subject: [PATCH] new: doc: [rocketchat] added some update docs. Signed-off-by: Valentin Lab --- rocketchat/README.org | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 rocketchat/README.org diff --git a/rocketchat/README.org b/rocketchat/README.org new file mode 100644 index 00000000..3f548ef5 --- /dev/null +++ b/rocketchat/README.org @@ -0,0 +1,81 @@ +# -*- ispell-local-dictionary: "english" -*- +#+SETUPFILE: ~/.emacs.d/etc/setup/latex.setup +#+SETUPFILE: ~/.emacs.d/etc/setup/html-readtheorg-local.setup + +#+TITLE: Rocket.Chat + +* Updating the charm to a new version + +We are using official image. Latest tags usually. You can +double-check available candidate for official images like this: + +#+begin_src sh +docker search rocket.chat +#+end_src + +So we usually pull and test images like this : + +#+begin_src sh +docker pull rocket.chat:X.Y.Z +#+end_src + +This worked on 3.6.3, but changed before 3.8.0 to: + +#+begin_src sh +docker pull rocketchat/rocket.chat:X.Y.Z +#+end_src + +from: https://hub.docker.com/r/rocketchat/rocket.chat + +Get the available tags: + +#+begin_src sh +IMAGE_BASE_NAME=rocket.chat + +## lookup on docker hub only. Could think doing it for any docker +## image identifier available on `pull`. This would mean querying +## other registries, probably with a different api. +docker:lookup_available_tags() { + local image="$1" limit="${2:-10}" filter="$3" eor p + + ## remove any tags on image name + image="${image%%:*}" + + if [[ "$image" == *"/"* ]]; then + username="${image%%/*}" + image="${image##*/}" + else + username="library" + fi + + p=0 + eor= + while [ -z "$eor" ]; do + ((p++)) + out=$(curl -s "https://registry.hub.docker.com/v2/repositories/$username/$image/tags/?page=$p" | + jq -r '."results"[]["name"]') || break + [ -z "$out" ] && break + ## 10 results are expected per request, otherwise + ## this means we are hitting End of Records. + nb_result=$(printf "%s\n" "$out" | wc -l) + [ "$nb_result" -lt 10 ] && eor=true + ## filter records + [ "$filter" ] && out=$(printf "%s\n" "$out" | egrep "$filter") + [ -z "$out" ] && continue + nb_result=$(printf "%s\n" "$out" | wc -l) + if [ "$limit" -le "$nb_result" ]; then + printf "%s\n" "$out" | head -n "$limit" + break + fi + printf "%s\n" "$out" + limit=$((limit - nb_result)) + done + +} + +docker:lookup_available_tags rocketchat/rocket.chat 15 "^[0-9]+(\.[0-9]+)*$" + +#+end_src + +Rocket.chat has a powerfull and working update database that will +take care of migrating database on startup. \ No newline at end of file