From f32d83de025177aceb8f8084689671f712b8f90a Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 16 Feb 2023 13:47:26 -0500 Subject: [PATCH 1/3] update configs for publish feature --- src/spiffworkflow_backend/config/default.py | 6 +++--- src/spiffworkflow_backend/config/dev.py | 4 ++-- .../config/local_development.py | 2 +- src/spiffworkflow_backend/config/qa1.py | 4 ++-- src/spiffworkflow_backend/config/sartography.py | 2 +- src/spiffworkflow_backend/config/staging.py | 4 ++-- .../config/terraform_deployed_environment.py | 2 +- .../routes/process_models_controller.py | 4 ++-- src/spiffworkflow_backend/services/git_service.py | 12 ++++++------ 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/spiffworkflow_backend/config/default.py b/src/spiffworkflow_backend/config/default.py index 4aeecd37..68e7fa52 100644 --- a/src/spiffworkflow_backend/config/default.py +++ b/src/spiffworkflow_backend/config/default.py @@ -80,11 +80,11 @@ SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get( # When a user clicks on the `Publish` button, this is the default branch this server merges into. # I.e., dev server could have `staging` here. Staging server might have `production` here. -SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO = environ.get( - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO" +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH" ) SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get("SPIFFWORKFLOW_BACKEND_GIT_BRANCH") -SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING = environ.get("GIT_CLONE_URL") +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get("GIT_CLONE_URL") SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = ( environ.get("SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE", default="false") == "true" ) diff --git a/src/spiffworkflow_backend/config/dev.py b/src/spiffworkflow_backend/config/dev.py index 7cc73bc8..ef025060 100644 --- a/src/spiffworkflow_backend/config/dev.py +++ b/src/spiffworkflow_backend/config/dev.py @@ -1,8 +1,8 @@ """Dev.""" from os import environ -SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO = environ.get( - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO", default="staging" +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH", default="staging" ) SPIFFWORKFLOW_BACKEND_GIT_USERNAME = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_USERNAME", default="sartography-automated-committer" diff --git a/src/spiffworkflow_backend/config/local_development.py b/src/spiffworkflow_backend/config/local_development.py index e9e674ef..aa138731 100644 --- a/src/spiffworkflow_backend/config/local_development.py +++ b/src/spiffworkflow_backend/config/local_development.py @@ -13,7 +13,7 @@ SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER = ( environ.get("SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER", default="false") == "true" ) -SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING = environ.get( +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( "GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" ) SPIFFWORKFLOW_BACKEND_GIT_USERNAME = "sartography-automated-committer" diff --git a/src/spiffworkflow_backend/config/qa1.py b/src/spiffworkflow_backend/config/qa1.py index b1592d93..ac56d84f 100644 --- a/src/spiffworkflow_backend/config/qa1.py +++ b/src/spiffworkflow_backend/config/qa1.py @@ -1,8 +1,8 @@ """Qa1.""" from os import environ -SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO = environ.get( - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO", default="qa2" +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH", default="qa2" ) SPIFFWORKFLOW_BACKEND_GIT_USERNAME = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_USERNAME", default="sartography-automated-committer" diff --git a/src/spiffworkflow_backend/config/sartography.py b/src/spiffworkflow_backend/config/sartography.py index f384622e..4c7174a1 100644 --- a/src/spiffworkflow_backend/config/sartography.py +++ b/src/spiffworkflow_backend/config/sartography.py @@ -9,7 +9,7 @@ SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL = ( SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_BRANCH", default="main" ) -SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING = environ.get( +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( "GIT_CLONE_URL", default="https://github.com/sartography/sartography-process-models.git", ) diff --git a/src/spiffworkflow_backend/config/staging.py b/src/spiffworkflow_backend/config/staging.py index 56b4a3ff..bfb613ec 100644 --- a/src/spiffworkflow_backend/config/staging.py +++ b/src/spiffworkflow_backend/config/staging.py @@ -4,8 +4,8 @@ from os import environ SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_BRANCH", default="staging" ) -SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO = environ.get( - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO", default="main" +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH", default="main" ) SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = False SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = "staging.yml" diff --git a/src/spiffworkflow_backend/config/terraform_deployed_environment.py b/src/spiffworkflow_backend/config/terraform_deployed_environment.py index f75b5f06..bf7843b2 100644 --- a/src/spiffworkflow_backend/config/terraform_deployed_environment.py +++ b/src/spiffworkflow_backend/config/terraform_deployed_environment.py @@ -33,6 +33,6 @@ SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_URL = ( f"https://connector-proxy.{environment_identifier_for_this_config_file_only}" ".spiffworkflow.org" ) -SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING = environ.get( +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( "GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" ) diff --git a/src/spiffworkflow_backend/routes/process_models_controller.py b/src/spiffworkflow_backend/routes/process_models_controller.py index 1e2a16a7..1a628c4c 100644 --- a/src/spiffworkflow_backend/routes/process_models_controller.py +++ b/src/spiffworkflow_backend/routes/process_models_controller.py @@ -226,11 +226,11 @@ def process_model_publish( """Process_model_publish.""" if branch_to_update is None: branch_to_update = current_app.config[ - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO" + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH" ] if branch_to_update is None: raise MissingGitConfigsError( - "Missing config for SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO. " + "Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH. " "This is required for publishing process models" ) process_model_identifier = _un_modify_modified_process_model_id( diff --git a/src/spiffworkflow_backend/services/git_service.py b/src/spiffworkflow_backend/services/git_service.py index 37b04937..45f90578 100644 --- a/src/spiffworkflow_backend/services/git_service.py +++ b/src/spiffworkflow_backend/services/git_service.py @@ -132,17 +132,17 @@ class GitService: def check_for_publish_configs(cls) -> None: """Check_for_configs.""" cls.check_for_basic_configs() - if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO"] is None: + if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH"] is None: raise MissingGitConfigsError( - "Missing config for SPIFFWORKFLOW_BACKEND_GIT_BRANCH_TO_PUBLISH_TO. " + "Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH. " "This is required for publishing process models" ) if ( - current_app.config["SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING"] + current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"] is None ): raise MissingGitConfigsError( - "Missing config for SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING." + "Missing config for SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL." " This is required for publishing process models" ) @@ -198,7 +198,7 @@ class GitService: clone_url = webhook["repository"]["clone_url"] if ( clone_url - != current_app.config["SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING"] + != current_app.config["SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL"] ): raise GitCloneUrlMismatchError( "Configured clone url does not match clone url from webhook:" @@ -243,7 +243,7 @@ class GitService: destination_process_root = f"/tmp/{clone_dir}" # noqa git_clone_url = current_app.config[ - "SPIFFWORKFLOW_BACKEND_GIT_CLONE_URL_FOR_PUBLISHING" + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL" ] if git_clone_url.startswith("https://"): git_clone_url = git_clone_url.replace( From 18917e627a3631141a0774610071387da3ae9141 Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 16 Feb 2023 13:56:48 -0500 Subject: [PATCH 2/3] fix unprefixed config --- src/spiffworkflow_backend/config/default.py | 2 +- src/spiffworkflow_backend/config/local_development.py | 2 +- src/spiffworkflow_backend/config/sartography.py | 2 +- .../config/terraform_deployed_environment.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/spiffworkflow_backend/config/default.py b/src/spiffworkflow_backend/config/default.py index 68e7fa52..92c40d0a 100644 --- a/src/spiffworkflow_backend/config/default.py +++ b/src/spiffworkflow_backend/config/default.py @@ -84,7 +84,7 @@ SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH" ) SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get("SPIFFWORKFLOW_BACKEND_GIT_BRANCH") -SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get("GIT_CLONE_URL") +SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get("SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL") SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = ( environ.get("SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE", default="false") == "true" ) diff --git a/src/spiffworkflow_backend/config/local_development.py b/src/spiffworkflow_backend/config/local_development.py index aa138731..78013c4b 100644 --- a/src/spiffworkflow_backend/config/local_development.py +++ b/src/spiffworkflow_backend/config/local_development.py @@ -14,7 +14,7 @@ SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER = ( == "true" ) SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( - "GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" ) SPIFFWORKFLOW_BACKEND_GIT_USERNAME = "sartography-automated-committer" SPIFFWORKFLOW_BACKEND_GIT_USER_EMAIL = ( diff --git a/src/spiffworkflow_backend/config/sartography.py b/src/spiffworkflow_backend/config/sartography.py index 4c7174a1..71bdb399 100644 --- a/src/spiffworkflow_backend/config/sartography.py +++ b/src/spiffworkflow_backend/config/sartography.py @@ -10,6 +10,6 @@ SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_BRANCH", default="main" ) SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( - "GIT_CLONE_URL", + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL", default="https://github.com/sartography/sartography-process-models.git", ) diff --git a/src/spiffworkflow_backend/config/terraform_deployed_environment.py b/src/spiffworkflow_backend/config/terraform_deployed_environment.py index bf7843b2..3fba7aaf 100644 --- a/src/spiffworkflow_backend/config/terraform_deployed_environment.py +++ b/src/spiffworkflow_backend/config/terraform_deployed_environment.py @@ -34,5 +34,5 @@ SPIFFWORKFLOW_BACKEND_CONNECTOR_PROXY_URL = ( ".spiffworkflow.org" ) SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( - "GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" + "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL", default="https://github.com/sartography/sample-process-models.git" ) From 5b89d0cf31a45a934f15887f6db0cd1dcda3e2f2 Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 16 Feb 2023 14:10:31 -0500 Subject: [PATCH 3/3] use _GIT_SOURCE_BRANCH instead of _GIT_BRANCH --- src/spiffworkflow_backend/config/default.py | 6 +++++- src/spiffworkflow_backend/config/sartography.py | 4 ++-- src/spiffworkflow_backend/config/staging.py | 4 ++-- src/spiffworkflow_backend/services/git_service.py | 12 ++++++------ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/spiffworkflow_backend/config/default.py b/src/spiffworkflow_backend/config/default.py index 92c40d0a..e7b42c1a 100644 --- a/src/spiffworkflow_backend/config/default.py +++ b/src/spiffworkflow_backend/config/default.py @@ -83,7 +83,11 @@ SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get( SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH" ) -SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get("SPIFFWORKFLOW_BACKEND_GIT_BRANCH") +# This is the branch that the app automatically commits to every time the user clicks the save button +# or otherwise changes a process model. +# If publishing is enabled, the contents of this "staging area" / "scratch pad" / WIP spot will be used +# as the relevant contents for process model that the user wants to publish. +SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH = environ.get("SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH") SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get("SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL") SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = ( environ.get("SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE", default="false") == "true" diff --git a/src/spiffworkflow_backend/config/sartography.py b/src/spiffworkflow_backend/config/sartography.py index 71bdb399..08368474 100644 --- a/src/spiffworkflow_backend/config/sartography.py +++ b/src/spiffworkflow_backend/config/sartography.py @@ -6,8 +6,8 @@ SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL = ( f"https://keycloak.{environment_identifier_for_this_config_file_only}" ".spiffworkflow.org/realms/sartography" ) -SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get( - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH", default="main" +SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH = environ.get( + "SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH", default="main" ) SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL", diff --git a/src/spiffworkflow_backend/config/staging.py b/src/spiffworkflow_backend/config/staging.py index bfb613ec..edfe36d7 100644 --- a/src/spiffworkflow_backend/config/staging.py +++ b/src/spiffworkflow_backend/config/staging.py @@ -1,8 +1,8 @@ """Staging.""" from os import environ -SPIFFWORKFLOW_BACKEND_GIT_BRANCH = environ.get( - "SPIFFWORKFLOW_BACKEND_GIT_BRANCH", default="staging" +SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH = environ.get( + "SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH", default="staging" ) SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH = environ.get( "SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_TARGET_BRANCH", default="main" diff --git a/src/spiffworkflow_backend/services/git_service.py b/src/spiffworkflow_backend/services/git_service.py index 45f90578..93390c60 100644 --- a/src/spiffworkflow_backend/services/git_service.py +++ b/src/spiffworkflow_backend/services/git_service.py @@ -82,7 +82,7 @@ class GitService: cls.check_for_basic_configs() branch_name_to_use = branch_name if branch_name_to_use is None: - branch_name_to_use = current_app.config["SPIFFWORKFLOW_BACKEND_GIT_BRANCH"] + branch_name_to_use = current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] repo_path_to_use = repo_path if repo_path is None: repo_path_to_use = current_app.config[ @@ -122,9 +122,9 @@ class GitService: @classmethod def check_for_basic_configs(cls) -> None: """Check_for_basic_configs.""" - if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_BRANCH"] is None: + if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] is None: raise MissingGitConfigsError( - "Missing config for SPIFFWORKFLOW_BACKEND_GIT_BRANCH. " + "Missing config for SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH. " "This is required for publishing process models" ) @@ -210,14 +210,14 @@ class GitService: f"Could not find the 'ref' arg in the webhook boy: {webhook}" ) - if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_BRANCH"] is None: + if current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] is None: raise MissingGitConfigsError( - "Missing config for SPIFFWORKFLOW_BACKEND_GIT_BRANCH. This is required" + "Missing config for SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH. This is required" " for updating the repository as a result of the webhook" ) ref = webhook["ref"] - git_branch = current_app.config["SPIFFWORKFLOW_BACKEND_GIT_BRANCH"] + git_branch = current_app.config["SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH"] if ref != f"refs/heads/{git_branch}": return False