From 4bde19a1947ba2e4808c9c91d1e2ba62a67e961b Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Fri, 24 Sep 2021 11:31:54 -0700 Subject: [PATCH] moved default dolt branch to env var --- development/Dockerfile-dolt | 5 ++++- development/dev.env | 3 +++ development/docker-compose.requirements.yml | 3 +++ development/nautobot_config.py | 13 ++++++++----- dolt/constants.py | 8 ++++---- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/development/Dockerfile-dolt b/development/Dockerfile-dolt index 539b135..bc88fe9 100644 --- a/development/Dockerfile-dolt +++ b/development/Dockerfile-dolt @@ -8,9 +8,12 @@ RUN mkdir -p /var/lib/nautobot ARG DOLT_RELEASE=latest RUN curl -L https://github.com/dolthub/dolt/releases/${DOLT_RELEASE}/download/install.sh | bash +ARG dolt_default_branch +RUN echo "dolt default branch: dolt_default_branch" + RUN dolt config --global --add user.name nautobot RUN dolt config --global --add user.email opensource@networktocode.COM -RUN dolt config --global --add init.defaultbranch main +RUN dolt config --global --add init.defaultbranch $dolt_default_branch WORKDIR /var/lib/nautobot diff --git a/development/dev.env b/development/dev.env index 517167e..a5bf726 100644 --- a/development/dev.env +++ b/development/dev.env @@ -7,6 +7,9 @@ METRICS_ENABLED=True NAPALM_TIMEOUT=5 NAUTOBOT_ROOT=/opt/nautobot DOLT_DB=nautobot +# This must match dolt_default_branch +# in docker-compose.requirements.yml +DOLT_DEFAULT_BRANCH=main DOLT_HOST=dolt DOLT_USER=nautobot REDIS_HOST=redis diff --git a/development/docker-compose.requirements.yml b/development/docker-compose.requirements.yml index a621d5b..3228673 100644 --- a/development/docker-compose.requirements.yml +++ b/development/docker-compose.requirements.yml @@ -4,6 +4,9 @@ services: dolt: build: context: "../" + args: + # this must match DOLT_DEFAULT_BRANCH in dev.env + dolt_default_branch: "main" dockerfile: "development/Dockerfile-dolt" command: - dolt diff --git a/development/nautobot_config.py b/development/nautobot_config.py index af0a767..ec07f5a 100644 --- a/development/nautobot_config.py +++ b/development/nautobot_config.py @@ -15,6 +15,7 @@ for key in [ "ALLOWED_HOSTS", "DOLT_DB", + "DOLT_DEFAULT_BRANCH", "DOLT_USER", "DOLT_HOST", "DOLT_PASSWORD", @@ -52,19 +53,21 @@ def is_truthy(arg): # Dolt database configuration. Dolt is compatible with the MySQL database backend. # See the Django documentation for a complete list of available parameters: # https://docs.djangoproject.com/en/stable/ref/settings/#databases +DOLT_DB = os.getenv("DOLT_DB") +DOLT_DEFAULT_BRANCH = os.getenv("DOLT_DEFAULT_BRANCH") +GLOBAL_DB = "global" + DATABASES = { "default": { - "NAME": "nautobot", # Database name + "NAME": DOLT_DB, # Database name "USER": os.getenv("DOLT_USER", ""), # Database username "PASSWORD": os.getenv("DOLT_PASSWORD", ""), # Database password "HOST": os.getenv("DOLT_HOST", "localhost"), # Database server "PORT": os.getenv("DOLT_PORT", ""), # Database port (leave blank for default) "ENGINE": "django.db.backends.mysql", }, - # TODO: use `dolt.constants.GLOBAL_STATE_DB` - "global": { - # TODO: use `dolt.constants.DOLT_DEFAULT_BRANCH` - "NAME": "nautobot", # Database username + GLOBAL_DB: { + "NAME": DOLT_DB, # Database username "USER": os.getenv("DOLT_USER", ""), # Database username "PASSWORD": os.getenv("DOLT_PASSWORD", ""), # Database password "HOST": os.getenv("DOLT_HOST", "localhost"), # Database server diff --git a/dolt/constants.py b/dolt/constants.py index aec8598..666b9ee 100644 --- a/dolt/constants.py +++ b/dolt/constants.py @@ -1,10 +1,10 @@ -# TODO: move these to settings? +from django.conf import settings -DB_NAME = "nautobot" +DB_NAME = settings.DOLT_DB -GLOBAL_DB = "global" +GLOBAL_DB = settings.GLOBAL_DB -DOLT_DEFAULT_BRANCH = "main" +DOLT_DEFAULT_BRANCH = settings.DOLT_DEFAULT_BRANCH DOLT_BRANCH_KEYWORD = "dolt-branch"