From 7e1699b96b1dd0e270cbaa78bc8cdc7b6daa4bb0 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 11 Jul 2018 11:25:32 +0200 Subject: [PATCH] new: [postgres-alpine] added charm. --- .../hooks/postgres_database-relation-joined | 21 +++++++++++++++++++ postgres-alpine/metadata.yml | 4 ++++ 2 files changed, 25 insertions(+) create mode 100755 postgres-alpine/hooks/postgres_database-relation-joined create mode 100644 postgres-alpine/metadata.yml diff --git a/postgres-alpine/hooks/postgres_database-relation-joined b/postgres-alpine/hooks/postgres_database-relation-joined new file mode 100755 index 00000000..002462aa --- /dev/null +++ b/postgres-alpine/hooks/postgres_database-relation-joined @@ -0,0 +1,21 @@ +#!/bin/bash + +## When writing relation script, remember: +## - they should be idempotents +## - they can be launched while the dockers is already up +## - they are launched from the host +## - the target of the link is launched first, and get a chance to ``relation-set`` +## - both side of the scripts get to use ``relation-get``. + +USER=$(relation-get user) +PASSWORD="$(relation-get password 2>/dev/null)" || PASSWORD="$(gen_password)" + +config-add "\ +services: + $TARGET_CHARM_NAME: + environment: + POSTGRES_USER: $USER + POSTGRES_PASSWORD: $PASSWORD +" + +relation-set password "$PASSWORD" \ No newline at end of file diff --git a/postgres-alpine/metadata.yml b/postgres-alpine/metadata.yml new file mode 100644 index 00000000..3c801410 --- /dev/null +++ b/postgres-alpine/metadata.yml @@ -0,0 +1,4 @@ + +docker-image: postgres:9.3-alpine +data-resources: + - /var/lib/postgresql/data