From 86f3294689faf44bcc42bc227b303ffe7a25dd1a Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Mon, 28 Oct 2019 06:17:45 +0100 Subject: [PATCH] gen-config: 'service' replaces several variables. --- src/gen-config.cr | 7 +------ templates/gitea.cfg.j2 | 18 +++++++++--------- templates/nginx.conf.j2 | 4 ++-- templates/postgresql.conf.j2 | 4 ++-- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/gen-config.cr b/src/gen-config.cr index 451d0c9..455278e 100644 --- a/src/gen-config.cr +++ b/src/gen-config.cr @@ -94,12 +94,7 @@ class GenConfig::Context if service = Service.get_by_id service_id environment = service.environment - options["id"] = service.full_id - options["name"] = service.name - options["service_root"] = service.root - - options["environment"] = environment.name - options["environment_root"] = environment.root + options["service"] = service.to_genconfig providers = Hash(String, Variables).new service.providers.each do |token, provider| diff --git a/templates/gitea.cfg.j2 b/templates/gitea.cfg.j2 index 202fcac..59b6b26 100644 --- a/templates/gitea.cfg.j2 +++ b/templates/gitea.cfg.j2 @@ -16,25 +16,25 @@ SECRET_KEY = vPFgSqRMIe7Dzk4frRM4UA3CETedL8agK7x6IQFQt9YfRPiQGhQbYAGfyan71iU [database] DB_TYPE = postgres HOST = 127.0.0.1:{{ port(providers.postgresql) }} -NAME = {{ id | replace("/", "_") }}_db -USER = {{ id | replace("/", "_") }} -PASSWD = {{ random_password( id ) }} +NAME = {{ service.id | replace("/", "_") }}_db +USER = {{ service.id | replace("/", "_") }} +PASSWD = {{ random_password( service.id ) }} SSL_MODE = disable CHARSET = utf8 -PATH = /srv/{{ environment }}/gitea/data/gitea.db +PATH = {{ service.root }}/data/gitea.db [repository] -ROOT = /srv/{{ environment }}/gitea/repositories +ROOT = {{ service.root }}/repositories [server] SSH_DOMAIN = localhost DOMAIN = localhost -HTTP_PORT = {{ port(id) }} -ROOT_URL = http://localhost:{{ port(id) }}/ +HTTP_PORT = {{ port(service.id) }} +ROOT_URL = http://localhost:{{ port(service.id) }}/ DISABLE_SSH = false SSH_PORT = 22 LFS_START_SERVER = true -LFS_CONTENT_PATH = /srv/{{ environment }}/gitea/data/lfs +LFS_CONTENT_PATH = {{ service.root }}/data/lfs LFS_JWT_SECRET = nUIANTsStEelCeOo7SFTcJllpJ6I8DXNr7duUgGMXfI OFFLINE_MODE = false @@ -67,6 +67,6 @@ PROVIDER = file [log] MODE = file LEVEL = info -ROOT_PATH = /srv/{{ environment }}/gitea/log +ROOT_PATH = {{ service.root }}/log diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 119b48d..6f132ed 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -8,8 +8,8 @@ events { } http { - error_log /var/log/{{ id | replace("/", "_") }}_error.log warn; - access_log /var/log/{{ id | replace("/", "_") }}_access.log; + error_log /var/log/{{ service.id | replace("/", "_") }}_error.log warn; + access_log /var/log/{{ service.id | replace("/", "_") }}_access.log; include /etc/nginx/mime.types; default_type application/octet-stream; diff --git a/templates/postgresql.conf.j2 b/templates/postgresql.conf.j2 index 10c165c..d4ecebf 100644 --- a/templates/postgresql.conf.j2 +++ b/templates/postgresql.conf.j2 @@ -60,7 +60,7 @@ # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) -port = {{port(id)}} +port = {{port(service.id)}} max_connections = 100 # (change requires restart) #superuser_reserved_connections = 3 # (change requires restart) #unix_socket_directories = '/run/postgresql' # comma-separated list of directories @@ -687,4 +687,4 @@ default_text_search_config = 'pg_catalog.english' # CUSTOMIZED OPTIONS #------------------------------------------------------------------------------ -# Add settings for extensions here \ No newline at end of file +# Add settings for extensions here