You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
1.3 KiB

# -*- mode: shell-script -*-
get_odoo_uid() {
uid_label="odoo"
odoo_uid=$(cached_cmd_on_base_image "$SERVICE_NAME" "id -u \"$uid_label\"") || {
debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}$SERVICE_NAME${NORMAL} base image."
return 1
}
info "openerp uid from ${DARKYELLOW}$SERVICE_NAME${NORMAL} is '$odoo_uid'"
echo "$odoo_uid"
}
sql() {
local dbname="$1"
(
DBNAME="$(relation:get "$SERVICE_NAME":postgres-database dbname)" || return 1
ts=$(service:traverse "$SERVICE_NAME":"postgres-database") || return 1
export SERVICE_NAME="$ts"
export SERVICE_DATASTORE="$DATASTORE/$SERVICE_NAME"
target_charm=$(get_service_charm "$ts") || return 1
target_charm_path=$(charm.get_dir "$target_charm") || return 1
set +e
. "$target_charm_path/lib/common"
set -e
metadata_service_def=$(_get_service_metadata "$ts") || return 1
type=$(e "$metadata_service_def" | yq -r '.type') || true
if [[ "$type" != "stub" ]]; then
DOCKER_BASE_IMAGE=$(service_ensure_image_ready "$SERVICE_NAME") || return 1
export DOCKER_BASE_IMAGE
ensure_db_docker_running
fi
ddb "${dbname:-$DBNAME}"
)
}