Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of default dolt branch #115

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion development/Dockerfile-dolt
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
RUN dolt config --global --add init.defaultbranch main
RUN dolt config --global --add init.defaultbranch $dolt_default_branch

WORKDIR /var/lib/nautobot

Expand Down
3 changes: 3 additions & 0 deletions development/dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions development/docker-compose.requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
for key in [
"ALLOWED_HOSTS",
"DOLT_DB",
"DOLT_DEFAULT_BRANCH",
"DOLT_USER",
"DOLT_HOST",
"DOLT_PASSWORD",
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions dolt/constants.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible we should use the plugin settings to define the default branch instead of a the global settings


DOLT_BRANCH_KEYWORD = "dolt-branch"