spiff-arena/spiffworkflow-backend/bin/save_to_secrets_from_file

34 lines
1.1 KiB
Plaintext
Raw Normal View History

"""Get the bpmn process json for a given process instance id and store it in /tmp."""
import os
import sys
from spiffworkflow_backend import create_app
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.user import UserModel
from spiffworkflow_backend.services.secret_service import SecretService
def main(env_file: str):
"""Main."""
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"
if os.environ.get("BPMN_SPEC_ABSOLUTE_DIR") is None:
os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = "hey"
flask_env_key = "FLASK_SESSION_SECRET_KEY"
os.environ[flask_env_key] = "whatevs"
app = create_app()
with app.app_context():
contents = None
with open(env_file, 'r') as f:
contents = f.readlines()
for line in contents:
key, value_raw = line.split('=')
value = value_raw.replace('"', '').rstrip()
SecretService().add_secret(key, value, UserModel.query.first().id)
if len(sys.argv) < 2:
raise Exception("env file must be specified")
main(sys.argv[1])