Browse Source

new: [monujo] upgrade to version 0.0.2 an support relation to odoo and map server

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
pull/21/head
Valentin Lab 3 years ago
parent
commit
714681224e
  1. 3
      gogocarto/metadata.yml
  2. 15
      monujo/hooks/init
  3. 27
      monujo/hooks/pre_deploy
  4. 76
      monujo/lib/common
  5. 14
      monujo/metadata.yml
  6. 3
      odoo-tecnativa/metadata.yml

3
gogocarto/metadata.yml

@ -6,6 +6,9 @@ requires:
scope: container
provides:
map-server:
uses:
publish-dir:
#constraint: required | recommended | optional

15
monujo/hooks/init

@ -10,18 +10,11 @@
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
. lib/common
set -e
APP_NAME=monujo
SOURCE_URL="https://docker.0k.io/downloads/$APP_NAME-0.0.1.tar.bz2"
LOCATION="$SERVICE_DATASTORE/opt/apps/$APP_NAME"
monujo:code_init
mkdir -p "$LOCATION"
if dir_is_empty "$LOCATION"; then
cd "$LOCATION"
wget -q "$SOURCE_URL" -O file.tar.bz2
tar xjf file.tar.bz2
rm file.tar.bz2
chown root:root "$LOCATION" -R
fi
monujo:code_config_base

27
monujo/hooks/pre_deploy

@ -0,0 +1,27 @@
#!/bin/bash
## Should be executable N time in a row with same result.
. lib/common
set -e
if ! url=$(relation:get "${SERVICE_NAME}":odoo-server:web-proxy url); then
err "Monujo doesn't support odoo-server not having a web-proxy yet."
exit 1
fi
if ! dbname=$(relation:get "${SERVICE_NAME}":odoo-server:postgres-database dbname); then
err "Can't find db name of our odoo-server relation."
exit 1
fi
monujo:config_merge "{
\"lokapiHost\": \"$url\",
\"lokapiDb\": \"$dbname\"
}"
if map_url=$(relation:get "${SERVICE_NAME}":map-server:publish-dir url); then
monujo:config_merge "{
\"mapUrl\": \"$map_url\"
}"
fi

76
monujo/lib/common

@ -0,0 +1,76 @@
APP_NAME=monujo
VERSION=0.0.2
SOURCE_URL="https://docker.0k.io/downloads/$APP_NAME-$VERSION.tar.bz2"
LOCATION="$SERVICE_DATASTORE/opt/apps/$APP_NAME"
CONFIGFILE="$LOCATION/config.json"
monujo:code_init() {
mkdir -p "$LOCATION"
if dir_is_empty "$LOCATION"; then
cd "$LOCATION"
wget -q "$SOURCE_URL" -O file.tar.bz2
tar xjf file.tar.bz2
rm file.tar.bz2
chown root:root "$LOCATION" -R
fi
}
monujo:code_config_base() {
MONUJO_OPTIONS=(
lokapi-host:string
lokapi-db:string
map-url:string
local-password-retention-time:string
)
MONUJO_OPTIONS_CONCAT=" ${MONUJO_OPTIONS[*]} "
service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1
echo "{}" > "$CONFIGFILE"
## XXXvlab: Should probably offer some lib to do this
while read-0 key val; do
key_option=${key//-/_}
case "$MONUJO_OPTIONS_CONCAT" in
*" ${key_option}:bool "*)
case "${val,,}" in
true|ok|yes|y)
val=yes
;;
false|ko|nok|no|n)
val=no
;;
*)
die "Invalid value for ${WHITE}$key$NORMAL, please use a boolean value."
;;
esac
;;
*" ${key_option}:numeric "*)
if ! is_int "$val"; then
die "Invalid value for ${WHITE}$key$NORMAL, please use numeric value."
fi
;;
*" ${key_option}:string "*)
:
;;
*)
key_option=$(echo "$key_option" | sed 's/_\([a-z0-9]\)/\U\1/g')
printf "%s %s\0" "$key_option" "$val"
;;
esac
done < <(printf "%s" "$service_def" | shyaml key-values-0 options) |
jq -R 'split("\u0000") | map(split(" ") | {key: .[0], value: .[1]}) | from_entries' > \
"$CONFIGFILE"
}
monujo:config_merge() {
local old_config new_config="$1"
old_config=$(cat "$CONFIGFILE")
e "$old_config" "$new_config" | jq -s 'reduce .[] as $x ({}; . * $x)' > "$CONFIGFILE"
}

14
monujo/metadata.yml

@ -15,3 +15,17 @@ uses:
location: !var-expand "$DATASTORE/$BASE_SERVICE_NAME/opt/apps/monujo"
# data-dirs: ## write permission for web-app
# - .
odoo-server:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: required
auto: pair
solves:
container: "LCC API provider"
map-server:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: optional
auto: pair
solves:
container: "Map server"

3
odoo-tecnativa/metadata.yml

@ -28,6 +28,9 @@ default-options:
# othersection:
# myvalue: yyy
provides:
odoo-server:
uses:
postgres-database:
#constraint: required | recommended | optional

Loading…
Cancel
Save