From 79be76da053df3467f99d46e4c4647243f220b2e Mon Sep 17 00:00:00 2001 From: topher-lo <46541035+topher-lo@users.noreply.github.com> Date: Sun, 8 Dec 2024 18:03:49 -0800 Subject: [PATCH] refactor: Drop duplicated env vars (public runner url) --- .env.example | 7 +++---- docker-compose.dev.yml | 4 ++-- docker-compose.yml | 4 ++-- tests/conftest.py | 1 - tracecat/config.py | 11 ----------- tracecat/db/schemas.py | 2 +- 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.env.example b/.env.example index 10d2d9f8c..84291d209 100644 --- a/.env.example +++ b/.env.example @@ -29,18 +29,17 @@ TRACECAT__SIGNING_SECRET=your-tracecat-signing-secret TRACECAT__API_URL=${INTERNAL_API_URL} # Root path to deal with extra path prefix behind the reverse proxy TRACECAT__API_ROOT_PATH=/api -# Public Runner URL +# This the public URL for the frontend +TRACECAT__PUBLIC_APP_URL=${PUBLIC_APP_URL} # This is the public URL for incoming webhooks # If you wish to expose your webhooks to the internet, you can use a tunneling service like ngrok. # If using ngrok, run `ngrok http --domain=INSERT_STATIC_NGROK_DOMAIN_HERE 8001` # to start ngrok and update this with the forwarding URL -TRACECAT__PUBLIC_RUNNER_URL=${PUBLIC_API_URL} +TRACECAT__PUBLIC_API_URL=${PUBLIC_API_URL} # CORS (comman separated string of allowed origins) TRACECAT__ALLOW_ORIGINS=http://localhost:3000,${PUBLIC_APP_URL} # Postgres SSL model TRACECAT__DB_SSLMODE=disable -TRACECAT__PUBLIC_APP_URL=${PUBLIC_APP_URL} -TRACECAT__PUBLIC_API_URL=${PUBLIC_API_URL} # --- Postgres --- TRACECAT__POSTGRES_USER=postgres diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 6852ae39c..ce96f42be 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -28,7 +28,7 @@ services: TRACECAT__DB_ENCRYPTION_KEY: ${TRACECAT__DB_ENCRYPTION_KEY} # Sensitive TRACECAT__DB_SSLMODE: ${TRACECAT__DB_SSLMODE} TRACECAT__DB_URI: ${TRACECAT__DB_URI} # Sensitive - TRACECAT__PUBLIC_RUNNER_URL: ${TRACECAT__PUBLIC_RUNNER_URL} + TRACECAT__PUBLIC_API_URL: ${TRACECAT__PUBLIC_API_URL} TRACECAT__PUBLIC_APP_URL: ${TRACECAT__PUBLIC_APP_URL} TRACECAT__SERVICE_KEY: ${TRACECAT__SERVICE_KEY} # Sensitive TRACECAT__SIGNING_SECRET: ${TRACECAT__SIGNING_SECRET} # Sensitive @@ -78,7 +78,7 @@ services: TRACECAT__DB_ENCRYPTION_KEY: ${TRACECAT__DB_ENCRYPTION_KEY} # Sensitive TRACECAT__DB_SSLMODE: ${TRACECAT__DB_SSLMODE} TRACECAT__DB_URI: ${TRACECAT__DB_URI} # Sensitive - TRACECAT__PUBLIC_RUNNER_URL: ${TRACECAT__PUBLIC_RUNNER_URL} + TRACECAT__PUBLIC_API_URL: ${TRACECAT__PUBLIC_API_URL} TRACECAT__EXECUTOR_URL: ${INTERNAL_EXECUTOR_URL} TRACECAT__SERVICE_KEY: ${TRACECAT__SERVICE_KEY} # Sensitive TRACECAT__SIGNING_SECRET: ${TRACECAT__SIGNING_SECRET} # Sensitive diff --git a/docker-compose.yml b/docker-compose.yml index 0173aaf40..58c6891a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: TRACECAT__DB_ENCRYPTION_KEY: ${TRACECAT__DB_ENCRYPTION_KEY} # Sensitive TRACECAT__DB_SSLMODE: ${TRACECAT__DB_SSLMODE} TRACECAT__DB_URI: ${TRACECAT__DB_URI} # Sensitive - TRACECAT__PUBLIC_RUNNER_URL: ${TRACECAT__PUBLIC_RUNNER_URL} + TRACECAT__PUBLIC_API_URL: ${TRACECAT__PUBLIC_API_URL} TRACECAT__PUBLIC_APP_URL: ${TRACECAT__PUBLIC_APP_URL} TRACECAT__SERVICE_KEY: ${TRACECAT__SERVICE_KEY} # Sensitive TRACECAT__SIGNING_SECRET: ${TRACECAT__SIGNING_SECRET} # Sensitive @@ -74,7 +74,7 @@ services: TRACECAT__DB_ENCRYPTION_KEY: ${TRACECAT__DB_ENCRYPTION_KEY} # Sensitive TRACECAT__DB_SSLMODE: ${TRACECAT__DB_SSLMODE} TRACECAT__DB_URI: ${TRACECAT__DB_URI} # Sensitive - TRACECAT__PUBLIC_RUNNER_URL: ${TRACECAT__PUBLIC_RUNNER_URL} + TRACECAT__PUBLIC_API_URL: ${TRACECAT__PUBLIC_API_URL} TRACECAT__EXECUTOR_URL: ${INTERNAL_EXECUTOR_URL} TRACECAT__SERVICE_KEY: ${TRACECAT__SERVICE_KEY} # Sensitive TRACECAT__SIGNING_SECRET: ${TRACECAT__SIGNING_SECRET} # Sensitive diff --git a/tests/conftest.py b/tests/conftest.py index e2993808e..b0bcf711c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -73,7 +73,6 @@ def env_sandbox(monkeysession: pytest.MonkeyPatch): # Needed for local unit tests monkeysession.setenv("TRACECAT__EXECUTOR_URL", "http://executor:8000") monkeysession.setenv("TRACECAT__PUBLIC_API_URL", "http://localhost/api") - monkeysession.setenv("TRACECAT__PUBLIC_RUNNER_URL", "http://localhost:8001") monkeysession.setenv("TRACECAT__SERVICE_KEY", os.environ["TRACECAT__SERVICE_KEY"]) monkeysession.setenv("TRACECAT__SIGNING_SECRET", "test-signing-secret") # When launching the worker directly in a test, use localhost diff --git a/tracecat/config.py b/tracecat/config.py index 443e72e62..c23a1f3b6 100644 --- a/tracecat/config.py +++ b/tracecat/config.py @@ -4,23 +4,12 @@ from tracecat.auth.constants import AuthType -# === Actions Config === # -HTTP_MAX_RETRIES = 10 -LLM_MAX_RETRIES = 3 - # === Internal Services === # -TRACECAT__SCHEDULE_INTERVAL_SECONDS = os.environ.get( - "TRACECAT__SCHEDULE_INTERVAL_SECONDS", 60 -) -TRACECAT__SCHEDULE_MAX_CONNECTIONS = 6 TRACECAT__APP_ENV: Literal["development", "staging", "production"] = os.environ.get( "TRACECAT__APP_ENV", "development" ) # type: ignore TRACECAT__API_URL = os.environ.get("TRACECAT__API_URL", "http://localhost:8000") TRACECAT__API_ROOT_PATH = os.environ.get("TRACECAT__API_ROOT_PATH", "/api") -TRACECAT__PUBLIC_RUNNER_URL = os.environ.get( - "TRACECAT__PUBLIC_RUNNER_URL", "http://localhost/api" -) TRACECAT__PUBLIC_API_URL = os.environ.get( "TRACECAT__PUBLIC_API_URL", "http://localhost/api" ) diff --git a/tracecat/db/schemas.py b/tracecat/db/schemas.py index 721adff0f..806f64362 100644 --- a/tracecat/db/schemas.py +++ b/tracecat/db/schemas.py @@ -342,7 +342,7 @@ def secret(self) -> str: @computed_field @property def url(self) -> str: - return f"{config.TRACECAT__PUBLIC_RUNNER_URL}/webhooks/{self.workflow_id}/{self.secret}" + return f"{config.TRACECAT__PUBLIC_API_URL}/webhooks/{self.workflow_id}/{self.secret}" class Schedule(Resource, table=True):