From f05862af870191b925d17c23105969e608fe3b40 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 10 Sep 2018 11:07:43 +0200 Subject: [PATCH] new: ``charm`` and ``service`` are now clear distinct concept --- apache/actions/load | 4 +- .../actions/relations/publish-dir/load-files | 2 +- apache/hooks/log_rotate-relation-joined | 6 +-- apache/lib/common | 30 ++++++------- apache/test/vhost_files | 42 +++++++++---------- .../hooks/postgres_database-relation-joined | 4 +- .../hooks/web_proxy-relation-joined | 2 +- odoo-tecnativa/lib/common | 6 +-- .../hooks/postgres_database-relation-joined | 2 +- .../relations/postgres-database/load-db | 2 +- .../hooks/postgres_database-relation-joined | 2 +- .../hooks/schedule_command-relation-joined | 6 +-- sftp/hooks/sftp_access-relation-joined | 8 ++-- traefik/hooks/web_proxy-relation-joined | 2 +- 14 files changed, 59 insertions(+), 59 deletions(-) diff --git a/apache/actions/load b/apache/actions/load index 476d620..af33b58 100755 --- a/apache/actions/load +++ b/apache/actions/load @@ -46,8 +46,8 @@ fi set -e DOCKER_SITE_PATH=/var/www/$DOMAIN -if [ "$RELATION_BASE_CHARM" ]; then ## In a relation, we should use it then - DST=$DATASTORE/$RELATION_BASE_CHARM$DOCKER_SITE_PATH +if [ "$RELATION_BASE_SERVICE" ]; then ## In a relation, we should use it then + DST=$DATASTORE/$RELATION_BASE_SERVICE$DOCKER_SITE_PATH else DST=${SERVICE_DATASTORE}$DOCKER_SITE_PATH fi diff --git a/apache/actions/relations/publish-dir/load-files b/apache/actions/relations/publish-dir/load-files index 6d05d04..87aa261 100755 --- a/apache/actions/relations/publish-dir/load-files +++ b/apache/actions/relations/publish-dir/load-files @@ -39,6 +39,6 @@ set -e DOMAIN=$(relation-get domain) -run_service_action "$RELATION_TARGET_CHARM" load "$SOURCE" "$DOMAIN" "$@" +run_service_action "$RELATION_TARGET_SERVICE" load "$SOURCE" "$DOMAIN" "$@" info "Correctly deployed '$SOURCE' towards domain '$DOMAIN'" diff --git a/apache/hooks/log_rotate-relation-joined b/apache/hooks/log_rotate-relation-joined index 56d9ef3..9d879a1 100755 --- a/apache/hooks/log_rotate-relation-joined +++ b/apache/hooks/log_rotate-relation-joined @@ -36,17 +36,17 @@ file_put "$DST" </dev/null) || - LOCATION="$DATASTORE/$BASE_CHARM_NAME$DOCKER_SITE_PATH" + LOCATION="$DATASTORE/$BASE_SERVICE_NAME$DOCKER_SITE_PATH" apache_vhost_create || return 1 info "Added $DOMAIN apache config." @@ -143,7 +143,7 @@ ssl_fallback_vars() { ssl_fallback_prepare() { local cfg="$1" cert key ca_cert - dst="$CONFIGSTORE/$BASE_CHARM_NAME" + dst="$CONFIGSTORE/$BASE_SERVICE_NAME" volumes="" for label in cert key ca_cert; do content="$(eval echo "\"\$__vhost_cfg_ssl_$label\"")" @@ -157,7 +157,7 @@ ssl_fallback_prepare() { if [ "$volumes" ]; then config-add "\ -$MASTER_TARGET_CHARM_NAME: +$MASTER_TARGET_SERVICE_NAME: volumes: $volumes " @@ -182,7 +182,7 @@ ssl_plugin_letsencrypt-dns_prepare() { config-add "\ services: - $MASTER_TARGET_CHARM_NAME: + $MASTER_TARGET_SERVICE_NAME: volumes: - $DATASTORE/${letsencrypt_charm}/etc/letsencrypt:/etc/letsencrypt:ro " || return 1 @@ -196,8 +196,8 @@ apache_passwd_file() { ## XXXvlab: called twice... no better way to do this ? __vhost_creds_statement >/dev/null first= - if ! [ -e "$CONFIGSTORE/$MASTER_TARGET_CHARM_NAME$password_file" ]; then - debug "No file $CONFIGSTORE/$MASTER_TARGET_CHARM_NAME$password_file, creating password file." || true + if ! [ -e "$CONFIGSTORE/$MASTER_TARGET_SERVICE_NAME$password_file" ]; then + debug "No file $CONFIGSTORE/$MASTER_TARGET_SERVICE_NAME$password_file, creating password file." || true first=c fi while read-0 login password; do @@ -247,7 +247,7 @@ apache_code_dir() { info "Set permission for read and traversal on '$LOCATION'." config-add " -$MASTER_BASE_CHARM_NAME: +$MASTER_BASE_SERVICE_NAME: volumes: - $LOCATION:$DOCKER_SITE_PATH " @@ -260,7 +260,7 @@ apache_data_dirs() { return 0 fi - DST=$DATASTORE/$BASE_CHARM_NAME$DOCKER_SITE_PATH + DST=$DATASTORE/$BASE_SERVICE_NAME$DOCKER_SITE_PATH DATA=() while IFS="," read -ra ADDR; do for dir in "${ADDR[@]}"; do @@ -284,7 +284,7 @@ apache_data_dirs() { setfacl -R -d -m g:"$www_data_gid":rwx "${dirs[@]}" config-add " -$MASTER_BASE_CHARM_NAME: +$MASTER_BASE_SERVICE_NAME: volumes: $( for d in "${DATA[@]}"; do @@ -310,13 +310,13 @@ export -f deploy_files apache_core_rules_add() { - local conf="$1" dst="/etc/apache2/conf-enabled/$BASE_CHARM_NAME.conf" + local conf="$1" dst="/etc/apache2/conf-enabled/$BASE_SERVICE_NAME.conf" debug "Adding core rule." - echo "$conf" | file_put "$CONFIGSTORE/$BASE_CHARM_NAME$dst" + echo "$conf" | file_put "$CONFIGSTORE/$BASE_SERVICE_NAME$dst" config-add " -$MASTER_BASE_CHARM_NAME: +$MASTER_BASE_SERVICE_NAME: volumes: - - $CONFIGSTORE/$BASE_CHARM_NAME$dst:$dst:ro + - $CONFIGSTORE/$BASE_SERVICE_NAME$dst:$dst:ro " } @@ -422,9 +422,9 @@ __vhost_proxy_statement() { TARGET=$(relation-get target 2>/dev/null) || true if [ -z "$TARGET" ]; then ## First exposed port: - base_image=$(service_base_docker_image "$BASE_CHARM_NAME") || return 1 + base_image=$(service_base_docker_image "$BASE_SERVICE_NAME") || return 1 first_exposed_port=$(image_exposed_ports_0 "$base_image" | tr '\0' '\n' | head -n 1 | cut -f 1 -d /) || return 1 - TARGET=$MASTER_BASE_CHARM_NAME:$first_exposed_port + TARGET=$MASTER_BASE_SERVICE_NAME:$first_exposed_port info "No target was specified, introspection found: $TARGET" fi diff --git a/apache/test/vhost_files b/apache/test/vhost_files index e26b44a..1d264da 100644 --- a/apache/test/vhost_files +++ b/apache/test/vhost_files @@ -102,8 +102,8 @@ is err '' try " export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' export CONFIGSTORE='\$CONFIGSTORE' -export BASE_CHARM_NAME='\$BASE_CHARM_NAME' -export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' +export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME' +export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME' DOMAIN=www.example.com DOCKER_SITE_PATH=/var/www/\$DOMAIN CFG=' @@ -115,22 +115,22 @@ ssl: ' apache_vhost_create" noerror -is out part 'file_put $CONFIGSTORE/$BASE_CHARM_NAME/etc/ssl/certs/www.example.com.pem +is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/certs/www.example.com.pem | c' -is out part 'file_put $CONFIGSTORE/$BASE_CHARM_NAME/etc/ssl/private/www.example.com.key +is out part 'file_put $CONFIGSTORE/$BASE_SERVICE_NAME/etc/ssl/private/www.example.com.key | a | b' is out reg 'config-add' -is out reg ' - \$CONFIGSTORE/\$BASE_CHARM_NAME/etc/ssl/certs/www.example.com.pem:/etc/ssl/certs/www.example.com.pem:ro' -is out reg ' - \$CONFIGSTORE/\$BASE_CHARM_NAME/etc/ssl/private/www.example.com.key:/etc/ssl/private/www.example.com.key:ro' +is out reg ' - \$CONFIGSTORE/\$BASE_SERVICE_NAME/etc/ssl/certs/www.example.com.pem:/etc/ssl/certs/www.example.com.pem:ro' +is out reg ' - \$CONFIGSTORE/\$BASE_SERVICE_NAME/etc/ssl/private/www.example.com.key:/etc/ssl/private/www.example.com.key:ro' try " export DOCKER_BASE_IMAGE=docker/apache export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' export CONFIGSTORE='\$CONFIGSTORE' -export BASE_CHARM_NAME='\$BASE_CHARM_NAME' -export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' +export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME' +export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME' DOMAIN=www.example.com DOCKER_SITE_PATH=/var/www/\$DOMAIN export CFG=' @@ -151,8 +151,8 @@ try " export DOCKER_BASE_IMAGE=docker/apache export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' export CONFIGSTORE='\$CONFIGSTORE' -export BASE_CHARM_NAME='\$BASE_CHARM_NAME' -export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' +export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME' +export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME' export CFG=' creds: toto: xxx @@ -166,8 +166,8 @@ export DATASTORE='\$DATASTORE' export DOCKER_BASE_IMAGE=docker/apache export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' export CONFIGSTORE='\$CONFIGSTORE' -export BASE_CHARM_NAME='\$BASE_CHARM_NAME' -export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' +export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME' +export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME' export CFG=' domain: www.example.com creds: @@ -175,7 +175,7 @@ creds: ' apache_publish_dir" is errlvl 0 -is err reg 'setfacl -R -m g::rx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com' +is err reg 'setfacl -R -m g::rx \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com' is err reg 'cached_cmd_on_base_image apache id -g www-data' @@ -184,8 +184,8 @@ export DATASTORE='\$DATASTORE' export DOCKER_BASE_IMAGE=docker/apache export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' export CONFIGSTORE='\$CONFIGSTORE' -export BASE_CHARM_NAME='\$BASE_CHARM_NAME' -export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' +export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME' +export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME' export CFG=' domain: www.example.com creds: @@ -197,8 +197,8 @@ data-dirs: ' apache_publish_dir" is errlvl 0 -is err reg 'setfacl -R -m g::rwx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/c' -is err reg 'setfacl -R -d -m g::rwx \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_CHARM_NAME/var/www/www.example.com/c' +is err reg 'setfacl -R -m g::rwx \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/c' +is err reg 'setfacl -R -d -m g::rwx \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/a \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/b \$DATASTORE/\$BASE_SERVICE_NAME/var/www/www.example.com/c' try " @@ -206,9 +206,9 @@ export DATASTORE='\$DATASTORE' export DOCKER_BASE_IMAGE=docker/apache export SERVICE_CONFIGSTORE='\$SERVICE_CONFIGSTORE' export CONFIGSTORE='\$CONFIGSTORE' -export BASE_CHARM_NAME='\$BASE_CHARM_NAME' -export MASTER_BASE_CHARM_NAME='\$MASTER_BASE_CHARM_NAME' -export MASTER_TARGET_CHARM_NAME='\$MASTER_TARGET_CHARM_NAME' +export BASE_SERVICE_NAME='\$BASE_SERVICE_NAME' +export MASTER_BASE_SERVICE_NAME='\$MASTER_BASE_SERVICE_NAME' +export MASTER_TARGET_SERVICE_NAME='\$MASTER_TARGET_SERVICE_NAME' export CFG=' domain: www.example.com location: /opt/apps/newlocation @@ -223,7 +223,7 @@ apache_publish_dir" is errlvl 0 is err reg 'mkdir -p /opt/apps/newlocation' is err reg 'setfacl -R -m g::rx /opt/apps/newlocation' -is out part ' | $MASTER_BASE_CHARM_NAME: +is out part ' | $MASTER_BASE_SERVICE_NAME: | volumes: | - /opt/apps/newlocation:/var/www/www.example.com' diff --git a/odoo-tecnativa/hooks/postgres_database-relation-joined b/odoo-tecnativa/hooks/postgres_database-relation-joined index 802e1c3..80cf6cb 100755 --- a/odoo-tecnativa/hooks/postgres_database-relation-joined +++ b/odoo-tecnativa/hooks/postgres_database-relation-joined @@ -18,12 +18,12 @@ control=$(echo -en "$USER\0$DBNAME\0$PASSWORD\0$ADMIN_PASSWORD" | md5_compat) config-add "\ services: - $MASTER_BASE_CHARM_NAME: + $MASTER_BASE_SERVICE_NAME: command: - '--database=$DBNAME' ## All this is to please technativa image, but is quite redundant environment: - PGHOST: $MASTER_TARGET_CHARM_NAME + PGHOST: $MASTER_TARGET_SERVICE_NAME PGDATABASE: $DBNAME PGPASSWORD: $PASSWORD PGUSER: $USER diff --git a/odoo-tecnativa/hooks/web_proxy-relation-joined b/odoo-tecnativa/hooks/web_proxy-relation-joined index a3d028f..32886c7 100755 --- a/odoo-tecnativa/hooks/web_proxy-relation-joined +++ b/odoo-tecnativa/hooks/web_proxy-relation-joined @@ -4,7 +4,7 @@ set -e config-add "\ services: - $MASTER_BASE_CHARM_NAME: + $MASTER_BASE_SERVICE_NAME: environment: PROXY_MODE: \"true\" " diff --git a/odoo-tecnativa/lib/common b/odoo-tecnativa/lib/common index 779a864..3b84d86 100644 --- a/odoo-tecnativa/lib/common +++ b/odoo-tecnativa/lib/common @@ -2,10 +2,10 @@ get_odoo_uid() { uid_label="odoo" - odoo_uid=$(cached_cmd_on_base_image odoo "id -u \"$uid_label\"") || { - debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}odoo${NORMAL} base image." + 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}odoo${NORMAL} is '$odoo_uid'" + info "openerp uid from ${DARKYELLOW}$SERVICE_NAME${NORMAL} is '$odoo_uid'" echo "$odoo_uid" } diff --git a/postgres-alpine/hooks/postgres_database-relation-joined b/postgres-alpine/hooks/postgres_database-relation-joined index 002462a..cdd6844 100755 --- a/postgres-alpine/hooks/postgres_database-relation-joined +++ b/postgres-alpine/hooks/postgres_database-relation-joined @@ -12,7 +12,7 @@ PASSWORD="$(relation-get password 2>/dev/null)" || PASSWORD="$(gen_password)" config-add "\ services: - $TARGET_CHARM_NAME: + $TARGET_SERVICE_NAME: environment: POSTGRES_USER: $USER POSTGRES_PASSWORD: $PASSWORD diff --git a/postgres/actions/relations/postgres-database/load-db b/postgres/actions/relations/postgres-database/load-db index 353ae0e..e9982a8 100755 --- a/postgres/actions/relations/postgres-database/load-db +++ b/postgres/actions/relations/postgres-database/load-db @@ -52,4 +52,4 @@ if [ "$UNACCENT" ]; then opts+=("--with-unaccent") fi -run_service_action "$RELATION_TARGET_CHARM" load "$SOURCE" "$USER@$DBNAME" "${opts[@]}" "$@" +run_service_action "$RELATION_TARGET_SERVICE" load "$SOURCE" "$USER@$DBNAME" "${opts[@]}" "$@" diff --git a/postgres/hooks/postgres_database-relation-joined b/postgres/hooks/postgres_database-relation-joined index 950a873..a74087c 100755 --- a/postgres/hooks/postgres_database-relation-joined +++ b/postgres/hooks/postgres_database-relation-joined @@ -35,7 +35,7 @@ fi db_grant_rights "$DBNAME" "$USER" pgpass_line="*:*:*:$USER:$PASSWORD" -pgpass_file="$CONFIGSTORE/$BASE_CHARM_NAME/root/.pgpass" +pgpass_file="$CONFIGSTORE/$BASE_SERVICE_NAME/root/.pgpass" if [ -e "$pgpass_file" ]; then sed -ri "/^.+:.+:.+:$USER:.*$/d" "$pgpass_file" diff --git a/postgres/hooks/schedule_command-relation-joined b/postgres/hooks/schedule_command-relation-joined index 68cecb9..24d333f 100755 --- a/postgres/hooks/schedule_command-relation-joined +++ b/postgres/hooks/schedule_command-relation-joined @@ -12,7 +12,7 @@ set -e ## XXXvlab: should use container name here so that it could support ## multiple postgres label=pg-backup-$SERVICE_NAME -DST=$CONFIGSTORE/$TARGET_CHARM_NAME/etc/cron/$label +DST=$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/cron/$label schedule=$(relation-get schedule) if ! echo "$schedule" | egrep '^\s*(([0-9/,*-]+\s+){4,4}[0-9/,*-]+|@[a-z]+)\s*$' >/dev/null 2>&1; then @@ -43,7 +43,7 @@ EOF chmod +x "$DST" config-add "\ -$MASTER_TARGET_CHARM_NAME: +$MASTER_TARGET_SERVICE_NAME: links: - - $MASTER_BASE_CHARM_NAME + - $MASTER_BASE_SERVICE_NAME " diff --git a/sftp/hooks/sftp_access-relation-joined b/sftp/hooks/sftp_access-relation-joined index 51671b3..acf0cac 100755 --- a/sftp/hooks/sftp_access-relation-joined +++ b/sftp/hooks/sftp_access-relation-joined @@ -12,15 +12,15 @@ if test "$GROUP" && ! getent group "$GROUP" >/dev/null 2>&1; then fi config-add "\ -$MASTER_TARGET_CHARM_NAME: +$MASTER_TARGET_SERVICE_NAME: volumes: $(while read-0 volume_def; do IFS=: read src dst mode < <(echo "$volume_def:") mode=${mode:-rw} if [ "$mode" == "rw" -a "$GROUP" ]; then - debug setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_CHARM_NAME$src" - setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_CHARM_NAME$src" + debug setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_SERVICE_NAME$src" + setfacl -m "g:$GROUP:rwx" -R "$DATASTORE/$BASE_SERVICE_NAME$src" fi - echo " - $DATASTORE/$BASE_CHARM_NAME$src:$dst:$mode" + echo " - $DATASTORE/$BASE_SERVICE_NAME$src:$dst:$mode" done < <(echo "$VOLUMES" | shyaml get-values-0))" diff --git a/traefik/hooks/web_proxy-relation-joined b/traefik/hooks/web_proxy-relation-joined index 40a8c3a..7926ce0 100755 --- a/traefik/hooks/web_proxy-relation-joined +++ b/traefik/hooks/web_proxy-relation-joined @@ -6,7 +6,7 @@ set -e config-add " services: - $MASTER_BASE_CHARM_NAME: + $MASTER_BASE_SERVICE_NAME: labels: - 'traefik.frontend.rule=Host:$(relation-get domain)' "