diff --git a/apiserver/bin/instance_configuration.py b/apiserver/bin/instance_configuration.py index 159c5d397..806a391ec 100644 --- a/apiserver/bin/instance_configuration.py +++ b/apiserver/bin/instance_configuration.py @@ -9,23 +9,39 @@ import django django.setup() -def load_config(): - from plane.license.models import InstanceConfiguration - # List of config keys to load from env - config_keys = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_STORAGE_BUCKET_NAME', 'AWS_S3_ENDPOINT_URL', 'AWS_REGION_NAME'] - for key in config_keys: - value = os.getenv(key) - if value is not None: - obj, created = InstanceConfiguration.objects.update_or_create( - key=key, - value=value - ) - action = 'Created' if created else 'Updated' - sys.stdout.write(sys.stdout.style.SUCCESS(f'{action} {key} with value from environment variable.')) - else: - sys.stdout.write(sys.stdout.style.WARNING(f'Environment variable {key} not set.')) +def load_config(): + from plane.license.models import InstanceConfiguration + + config_keys = { + # Authentication Settings + "GOOGLE_CLIENT_ID": os.environ.get("GOOGLE_CLIENT_ID"), + "GITHUB_CLIENT_ID": os.environ.get("GITHUB_CLIENT_ID"), + "GITHUB_CLIENT_SECRET": os.environ.get("GITHUB_CLIENT_SECRET"), + "ENABLE_SIGNUP": os.environ.get("ENABLE_SIGNUP", "1"), + "ENABLE_EMAIL_PASSWORD": os.environ.get("ENABLE_EMAIL_PASSWORD", "1"), + "ENABLE_MAGIC_LINK_LOGIN": os.environ.get("ENABLE_MAGIC_LINK_LOGIN", "0"), + # Email Settings + "EMAIL_HOST": os.environ.get("EMAIL_HOST", ""), + "EMAIL_HOST_USER": os.environ.get("EMAIL_HOST_USER", ""), + "EMAIL_HOST_PASSWORD": os.environ.get("EMAIL_HOST_PASSWORD"), + "EMAIL_PORT": os.environ.get("EMAIL_PORT", "587"), + "EMAIL_FROM": os.environ.get("EMAIL_FROM", ""), + "EMAIL_USE_TLS": os.environ.get("EMAIL_USE_TLS", "1"), + "EMAIL_USE_SSL": os.environ.get("EMAIL_USE_SSL", "0"), + # Open AI Settings + "OPENAI_API_BASE": os.environ.get("", "https://api.openai.com/v1"), + "OPENAI_API_KEY": os.environ.get("OPENAI_API_KEY", "sk-"), + "GPT_ENGINE": os.environ.get("GPT_ENGINE", "gpt-3.5-turbo"), + } + + for key, value in config_keys.items(): + obj, created = InstanceConfiguration.objects.update_or_create( + key=key, value=value + ) + action = "Created" if created else "Updated" + print(f"{action} {key} with value from environment variable.") if __name__ == "__main__": - load_config() \ No newline at end of file + load_config()