From 054c5b47d620265cbc6799dda4d960e066b7ebd7 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Tue, 9 Feb 2021 10:05:59 +0100 Subject: [PATCH] devtools/issues: add mailing support Resolves b/15 Change-Id: I53a4057ff428219ae1d4928db74eaa2e8bda6651 --- devtools/issues/prod.jsonnet | 9 ++++++++- devtools/issues/redmine.libsonnet | 32 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/devtools/issues/prod.jsonnet b/devtools/issues/prod.jsonnet index 2218716e..0d0c273a 100644 --- a/devtools/issues/prod.jsonnet +++ b/devtools/issues/prod.jsonnet @@ -4,7 +4,7 @@ # Bootstrap: # # ns=redmine -# kubectl -n $ns create secret generic redmine --from-literal=secret_key=$(pwgen 24 1) --from-literal=oidc_secret=... +# kubectl -n $ns create secret generic redmine --from-literal=secret_key=$(pwgen 24 1) --from-literal=postgres_password=$(pwgen 32 1) --from-literal=mailing_password=... --from-literal=oidc_secret=... # # ceph_ns=ceph-waw3; ceph_pool=waw-hdd-redundant-3 # kubectl -n $ceph_ns get secrets rook-ceph-object-user-${ceph_pool}-object-issues -o json | jq 'del(.metadata.namespace,.metadata.resourceVersion,.metadata.uid) | .metadata.creationTimestamp=null' | kubectl replace -f - -n $ns @@ -35,6 +35,13 @@ local redmine = import "./redmine.libsonnet"; clientID: "70ee2821-2657-4409-a298-98649d1f689f", clientSecret: { secretKeyRef: { name: "redmine", key: "oidc_secret" } }, }, + + mailing+: { + address: "mail.hackerspace.pl", + user_name: "issues", + domain: "hackerspace.pl", + password: { secretKeyRef: { name: "redmine", key: "mailing_password" } }, + }, }, }, } diff --git a/devtools/issues/redmine.libsonnet b/devtools/issues/redmine.libsonnet index 420e488c..2c4d4e0e 100644 --- a/devtools/issues/redmine.libsonnet +++ b/devtools/issues/redmine.libsonnet @@ -31,8 +31,23 @@ local postgres = import "../../kube/postgres.libsonnet"; clientID: error "oidc.clientID must be set", clientSecret: error "oidc.clientSecret must be set", }, + + # Mailing configuration object passed to smtp_settings + mailing: { + address: error "mailing.address must be set", + port: 465, + ssl: true, + domain: error "mailing.domain must be set", + authentication: ":login", + user_name: error "mailing.user_name must be set", + password: error "mailing.password must be set", + }, }, + # Generates YAML file while preserving specified ruby-style symbols. + # (ie. removes surrounding quotes) + rubyYaml(obj, symbols):: std.foldr(function (symbol, str) std.strReplace(str, '"%s"' % symbol, symbol), symbols, std.manifestYamlDoc(obj)), + ns: kube.Namespace(app.cfg.namespace), postgres: postgres { @@ -59,6 +74,11 @@ local postgres = import "../../kube/postgres.libsonnet"; containers_: { web: kube.Container("redmine") { image: cfg.image, + args: ['sh', '-c', ||| + set -e + echo "${X_EXTRA_CONFIGURATION}" > config/configuration.yml + exec /docker-entrypoint.sh rails server -b 0.0.0.0 + |||], ports_: { http: { containerPort: 3000 }, }, @@ -81,6 +101,18 @@ local postgres = import "../../kube/postgres.libsonnet"; REDMINE_S3_ACCESS_KEY_ID: cfg.storage.accessKey, REDMINE_S3_SECRET_ACCESS_KEY: cfg.storage.secretKey, REDMINE_S3_REGION: cfg.storage.region, + + REDMINE_MAILING_PASSWORD: cfg.mailing.password, + X_EXTRA_CONFIGURATION: app.rubyYaml({ + production: { + email_delivery: { + delivery_method: ":smtp", + smtp_settings: cfg.mailing { + password: "$(REDMINE_MAILING_PASSWORD)", + }, + } + }, + }, [":smtp", ":login"]), }, }, },