Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
# Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# See the LICENSE file for details.
|
|
|
|
# Python imports
|
|
import os
|
|
|
|
# Django imports
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
# Module imports
|
|
from plane.license.models import InstanceConfiguration
|
|
from plane.utils.instance_config_variables import instance_config_variables
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Configure instance variables"
|
|
|
|
def handle(self, *args, **options):
|
|
from plane.license.utils.encryption import encrypt_data
|
|
|
|
mandatory_keys = ["SECRET_KEY"]
|
|
|
|
for item in mandatory_keys:
|
|
if not os.environ.get(item):
|
|
raise CommandError(f"{item} env variable is required.")
|
|
|
|
for item in instance_config_variables:
|
|
obj, created = InstanceConfiguration.objects.get_or_create(key=item.get("key"))
|
|
if created:
|
|
obj.category = item.get("category")
|
|
obj.is_encrypted = item.get("is_encrypted", False)
|
|
if item.get("is_encrypted", False):
|
|
obj.value = encrypt_data(item.get("value"))
|
|
else:
|
|
obj.value = item.get("value")
|
|
obj.save()
|
|
self.stdout.write(self.style.SUCCESS(f"{obj.key} loaded with value from environment variable."))
|
|
else:
|
|
self.stdout.write(self.style.WARNING(f"{obj.key} configuration already exists"))
|