From 314604682bb97a1171b3f9c0a600117affd735f9 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 8 Jun 2022 18:33:00 +0200 Subject: [PATCH] new: [monujo] support un-managed code version External access and process can come and modify code without fearing of being replaced at each ``compose up``. Signed-off-by: Valentin Lab --- monujo/README.org | 28 ++++++++++++++++++++++++++++ monujo/hooks/init | 6 ++++-- monujo/lib/common | 16 ++++++++++++++-- monujo/metadata.yml | 2 ++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/monujo/README.org b/monujo/README.org index 84e28c9..a657a04 100644 --- a/monujo/README.org +++ b/monujo/README.org @@ -63,6 +63,19 @@ odoo: dbname: foo #+end_src +If you don't want an active forcing on monujo configuration file, you +can set option =enforce-config= to =false=. This will ensure that +whatever is already deployed in the internal directory, it won't be +replaced by the charm on next =compose up=. + +#+begin_src yaml +monujo: + options: + version: 1.0.0-rc.3 + enforce-config: false + +odoo: +#+end_src ** Map @@ -160,3 +173,18 @@ monujo: odoo: #+end_src + +If you don't want an active forcing on the version, you can set option +=enforce-version= to =false=. This will ensure that whatever is already +deployed in the internal directory, it won't be replaced by the charm +on next =compose up=. + +#+begin_src yaml +monujo: + options: + version: 1.0.0-rc.3 + enforce-version: false + +odoo: +#+end_src + diff --git a/monujo/hooks/init b/monujo/hooks/init index 09f0547..1c22ea0 100755 --- a/monujo/hooks/init +++ b/monujo/hooks/init @@ -15,8 +15,10 @@ set -e version=$(options-get version 2>/dev/null) +enforce_version=$(options-get enforce-version 2>/dev/null) +enforce_config=$(options-get enforce-config 2>/dev/null) -monujo:code_init "$version" +monujo:code_init "$version" "$enforce_version" -monujo:code_config_base +monujo:code_config_base "$enforce_config" diff --git a/monujo/lib/common b/monujo/lib/common index 7d487e6..35c6906 100644 --- a/monujo/lib/common +++ b/monujo/lib/common @@ -8,11 +8,16 @@ CONFIGFILE="$LOCATION/config.json" monujo:code_init() { - local version="$1" + local version="$1" enforce_version="$2" if [ -e "$LOCATION/.version" ] && \ [ "$(cat "$LOCATION/.version")" == "$version" ]; then return 0 fi + if [[ "${enforce_version,,}" =~ ^(false|0|no)$ ]]; then + if [ -d "$LOCATION" ]; then + return 0 + fi + fi [ -d "$LOCATION" ] && rm -rf "$LOCATION" mkdir -p "$LOCATION" cd "$LOCATION" @@ -35,13 +40,20 @@ export MONUJO_OPTIONS=( local-password-retention-time:numeric theme:struct\* version:ignore + enforce-version:ignore + enforce-config:ignore ) export MONUJO_OPTIONS_CONCAT=" ${MONUJO_OPTIONS[*]} " monujo:code_config_base() { - local service_def + local enforce_config="$1" service_def + if [[ "${enforce_config,,}" =~ ^(false|0|no)$ ]]; then + if [ -e "$CONFIGFILE" ]; then + return 0 + fi + fi service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1 options=$(e "$service_def" | shyaml get-value -y options) || true diff --git a/monujo/metadata.yml b/monujo/metadata.yml index 87bec30..5f5ba81 100644 --- a/monujo/metadata.yml +++ b/monujo/metadata.yml @@ -4,6 +4,8 @@ subordinate: true default-options: version: 1.0.0-rc.3 + enforce-version: true + enforce-config: true uses: publish-dir: