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

[INTERNAL] Remove envdir #439

Merged
merged 5 commits into from
Sep 25, 2023
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
run: make docs
env:
SYSTEM_PYTHON: python${{ matrix.python-version }}
SECRET_KEY: github-actions

- name: Deploy to GitHub Pages
if: ${{ github.ref == 'refs/heads/main' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# https://github.com/django/django/blob/master/.gitignore

.coverage
.env
.venv
*.egg-info
*.pyc
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ RUN pip install --no-cache-dir -e .
USER promgen
EXPOSE 8000

RUN promgen collectstatic --noinput
RUN SECRET_KEY=1 promgen collectstatic --noinput

VOLUME ["/etc/promgen", "/etc/prometheus"]
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
2 changes: 0 additions & 2 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ django-filter==23.2
# via promgen (setup.py)
djangorestframework==3.14.0
# via promgen (setup.py)
envdir==1.0.1
# via promgen (setup.py)
gunicorn==21.2.0
# via -r docker/requirements.in
idna==3.4
Expand Down
24 changes: 0 additions & 24 deletions promgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,3 @@
PROMGEN_CONFIG_FILE = pathlib.Path(
os.environ.get("PROMGEN_CONFIG", str(PROMGEN_CONFIG_DIR / "promgen.yml"))
)

# In the future we want to remove the dependency on envdir, but this will
# require some cleanup and documentation changes, so for now we will just
# ensure that it can't fail here if envdir is not already installed
if PROMGEN_CONFIG_DIR.exists():
try:
import envdir
except ImportError:
pass
else:
envdir.open(PROMGEN_CONFIG_DIR)


if "SECRET_KEY" not in os.environ:
try:
from django.utils.crypto import get_random_string
import warnings

warnings.warn("Unset SECRET_KEY setting to random for now")
os.environ["SECRET_KEY"] = get_random_string(
50, "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)"
)
except ImportError:
pass
kfdm marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 0 additions & 6 deletions promgen/management/commands/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,3 @@ def handle(self, **kwargs):
shutil.copy(PROMGEN_CONFIG_DEFAULT, PROMGEN_CONFIG_FILE)
else:
self.success("Config {} Exists", PROMGEN_CONFIG_FILE)

self.write("Checking environment settings", color=self.style.MIGRATE_HEADING)
self.setting("SECRET_KEY", default=settings.SECRET_KEY)
self.setting("DATABASE_URL")
self.setting("CELERY_BROKER_URL")
self.stdout.write("")
2 changes: 1 addition & 1 deletion promgen/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# Load our environment
env = environ.Env()
if DOT_ENV.exists():
env.read_env(".env")
env.read_env(DOT_ENV)

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str("SECRET_KEY")
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ install_requires =
django-filter
Django~=3.2
djangorestframework
envdir
kombu
prometheus-client
python-dateutil
Expand Down