Browse Source

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 <valentin.lab@kalysto.org>
element
Valentin Lab 2 years ago
parent
commit
314604682b
  1. 28
      monujo/README.org
  2. 6
      monujo/hooks/init
  3. 16
      monujo/lib/common
  4. 2
      monujo/metadata.yml

28
monujo/README.org

@ -63,6 +63,19 @@ odoo:
dbname: foo dbname: foo
#+end_src #+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 ** Map
@ -160,3 +173,18 @@ monujo:
odoo: odoo:
#+end_src #+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

6
monujo/hooks/init

@ -15,8 +15,10 @@
set -e set -e
version=$(options-get version 2>/dev/null) 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"

16
monujo/lib/common

@ -8,11 +8,16 @@ CONFIGFILE="$LOCATION/config.json"
monujo:code_init() { monujo:code_init() {
local version="$1"
local version="$1" enforce_version="$2"
if [ -e "$LOCATION/.version" ] && \ if [ -e "$LOCATION/.version" ] && \
[ "$(cat "$LOCATION/.version")" == "$version" ]; then [ "$(cat "$LOCATION/.version")" == "$version" ]; then
return 0 return 0
fi fi
if [[ "${enforce_version,,}" =~ ^(false|0|no)$ ]]; then
if [ -d "$LOCATION" ]; then
return 0
fi
fi
[ -d "$LOCATION" ] && rm -rf "$LOCATION" [ -d "$LOCATION" ] && rm -rf "$LOCATION"
mkdir -p "$LOCATION" mkdir -p "$LOCATION"
cd "$LOCATION" cd "$LOCATION"
@ -35,13 +40,20 @@ export MONUJO_OPTIONS=(
local-password-retention-time:numeric local-password-retention-time:numeric
theme:struct\* theme:struct\*
version:ignore version:ignore
enforce-version:ignore
enforce-config:ignore
) )
export MONUJO_OPTIONS_CONCAT=" ${MONUJO_OPTIONS[*]} " export MONUJO_OPTIONS_CONCAT=" ${MONUJO_OPTIONS[*]} "
monujo:code_config_base() { 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 service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1
options=$(e "$service_def" | shyaml get-value -y options) || true options=$(e "$service_def" | shyaml get-value -y options) || true

2
monujo/metadata.yml

@ -4,6 +4,8 @@ subordinate: true
default-options: default-options:
version: 1.0.0-rc.3 version: 1.0.0-rc.3
enforce-version: true
enforce-config: true
uses: uses:
publish-dir: publish-dir:

Loading…
Cancel
Save