From 6388e4de10a952a66700f2afcfe76f93618f7ff6 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Mon, 27 Jun 2022 02:44:49 +0530 Subject: [PATCH] feat: CI local_settings.py loads config from env vars --- dashboard/local_settings.ci.py | 85 ++++++++++++++++++++++++++++++++++ integration/ci.sh | 2 + 2 files changed, 87 insertions(+) create mode 100644 dashboard/local_settings.ci.py diff --git a/dashboard/local_settings.ci.py b/dashboard/local_settings.ci.py new file mode 100644 index 0000000..6a3f38c --- /dev/null +++ b/dashboard/local_settings.ci.py @@ -0,0 +1,85 @@ +""" +Django settings for dashboard project. + +Generated by 'django-admin startproject' using Django 4.0.3. + +For more information on this file, see +https://docs.djangoproject.com/en/4.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.0/ref/settings/ +""" +import environ +import os + +env = environ.Env() + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +# A new SECRET_KEY can be generated by running the following command: +# openssl rand -hex 32 +SECRET_KEY = "django-insecure-44zt@)$td7_yh(01q^hrce%h(311n!djn%%#s1b7$cvfy!pf7y" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + +# Database +# https://docs.djangoproject.com/en/4.0/ref/settings/#databases + +DATABASES = { + "default": env.db_url( + "DATABSE_URL", default="postgres://postgres:password@localhost:5432/postgres" + ) +} + + +## django-payments configuration + +PAYMENT_HOST = "http://localhost:8000" +PAYMENT_VARIANTS = { + "stripe": ( + "payments.stripe.StripeProvider", # please don't change this + { + "secret_key": env.get_value("STRIPE_SECRET_KEY"), + "public_key": env.get_value("STRIPE_PUBLIC_KEY"), + }, + ) +} + + +### Dashbaord specific configuration options + +HOSTEA = { + "INSTANCE_MAINTAINER_CONTACT": "contact@hostea.example.org", + "ACCOUNTS": { + "MAX_VERIFICATION_TOLERANCE_PERIOD": 60 * 60 * 24, # in seconds + "SUDO_TTL": 60 * 5, + }, + "META": { + "GITEA_INSTANCE": env.get_value("HOSTEA_META_GITEA_INSTANCE"), # meta Gitea insatnce + "GITEA_ORG_NAME": "Hostea", # Organisation name on Hostea meta instance + # Repository dedicated for handling support + # ref: https://gitea.hostea.org/Hostea/july-mvp/issues/17 + "SUPPORT_REPOSITORY": "support", + }, + "INFRA": { + "HOSTEA_REPO": { + # where to clone the repository + "PATH": "/tmp/hostea/dashboard/infrastructure", + # Git remote URI of the repository + "REMOTE": env.get_value("HOSTEA_INFRA_HOSTEA_REPO_REMOTE"), + # SSH key that can push to the Git repository remote mentioned above + "SSH_KEY": "tests/fleet-deploy-key", + } + }, +} + +# Please see EMAIL_* configuration options: +# https://docs.djangoproject.com/en/4.1/ref/settings/#email-host +EMAIL_CONFIG = env.email("EMAIL_URL", default="smtp://admin:password@localhost:10025") + +vars().update(EMAIL_CONFIG) diff --git a/integration/ci.sh b/integration/ci.sh index 8d0bfb9..c1f8fef 100755 --- a/integration/ci.sh +++ b/integration/ci.sh @@ -15,6 +15,8 @@ main() { docker_compose_up setup_env wait_for_env + else + cp dashboard/local_settings.ci.py dashboard/local_settings.py fi gitea_root support_repo_init