From 2e15826f58d570790c6f535140cba09b623397ef Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 11:49:16 +0100 Subject: [PATCH 1/6] Remove Airtable hardcoded default values --- changelog/items/other/airtable-env-vars.md | 2 ++ setup-scripts/blocklist-airtable.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog/items/other/airtable-env-vars.md diff --git a/changelog/items/other/airtable-env-vars.md b/changelog/items/other/airtable-env-vars.md new file mode 100644 index 00000000..dc287984 --- /dev/null +++ b/changelog/items/other/airtable-env-vars.md @@ -0,0 +1,2 @@ +- Remove hardcoded Airtable default values from blocklist script. Portal + operators need to define their own values in portal common config (LastPass). \ No newline at end of file diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index 3dbce3ed..e6563901 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -14,9 +14,9 @@ import json setup() AIRTABLE_API_KEY = os.getenv("AIRTABLE_API_KEY") -AIRTABLE_BASE = os.getenv("AIRTABLE_BASE", "app89plJvA9EqTJEc") -AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE", "Table%201") -AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD", "Link") +AIRTABLE_BASE = os.getenv("AIRTABLE_BASE") +AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE") +AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD") async def run_checks(): From d68f8969886e5929242e2c31aa2fabbd42c3f2cd Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 13:46:43 +0100 Subject: [PATCH 2/6] Add check if Airtable vars are defined --- setup-scripts/blocklist-airtable.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index e6563901..1173a90f 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -6,6 +6,7 @@ from time import sleep import traceback import os +import sys import re import asyncio import requests @@ -13,10 +14,17 @@ import json setup() -AIRTABLE_API_KEY = os.getenv("AIRTABLE_API_KEY") -AIRTABLE_BASE = os.getenv("AIRTABLE_BASE") -AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE") -AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD") + +# Check and load Airtable environment variables +airtable_env_vars = ["AIRTABLE_API_KEY", "AIRTABLE_BASE", "AIRTABLE_TABLE", "AIRTABLE_FIELD"] + +for e in airtable_env_vars: + # Check environment variable is defined + gete = os.getenv(e) + if not gete: + sys.exit("Configuration error: Environment variable " + e + " is not defined") + # Set variable + exec(e + " = \"" +gete + "\"") async def run_checks(): From 07b99b8192f9afee949d28b82a23890b8411b0e4 Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 13:52:32 +0100 Subject: [PATCH 3/6] Add check if Airtable vars are defined --- setup-scripts/blocklist-airtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index 1173a90f..d5bd360e 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -24,7 +24,7 @@ for e in airtable_env_vars: if not gete: sys.exit("Configuration error: Environment variable " + e + " is not defined") # Set variable - exec(e + " = \"" +gete + "\"") + exec(e + " = \"" + gete + "\"") async def run_checks(): From efeddd6c70e9de9d0b4204fd2d70d70f778829f2 Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 14:22:00 +0100 Subject: [PATCH 4/6] Add check if Airtable vars are defined --- setup-scripts/blocklist-airtable.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index d5bd360e..d0279e5f 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -15,16 +15,15 @@ import json setup() -# Check and load Airtable environment variables -airtable_env_vars = ["AIRTABLE_API_KEY", "AIRTABLE_BASE", "AIRTABLE_TABLE", "AIRTABLE_FIELD"] +AIRTABLE_API_KEY = os.getenv("AIRTABLE_API_KEY") +AIRTABLE_BASE = os.getenv("AIRTABLE_BASE") +AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE") +AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD") -for e in airtable_env_vars: - # Check environment variable is defined - gete = os.getenv(e) - if not gete: - sys.exit("Configuration error: Environment variable " + e + " is not defined") - # Set variable - exec(e + " = \"" + gete + "\"") +# Check environment variables are defined +for e in [AIRTABLE_API_KEY, AIRTABLE_BASE, AIRTABLE_TABLE, AIRTABLE_FIELD] + if not e: + sys.exit("Configuration error: Missing AirTable environment variable.") async def run_checks(): From c3d3f2b0e53d9fa7a103ec6a68cc00d643420352 Mon Sep 17 00:00:00 2001 From: firyx <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 14:32:08 +0100 Subject: [PATCH 5/6] Update setup-scripts/blocklist-airtable.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Karol Wypchło --- setup-scripts/blocklist-airtable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index d0279e5f..43858483 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -21,8 +21,8 @@ AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE") AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD") # Check environment variables are defined -for e in [AIRTABLE_API_KEY, AIRTABLE_BASE, AIRTABLE_TABLE, AIRTABLE_FIELD] - if not e: +for value in [AIRTABLE_API_KEY, AIRTABLE_BASE, AIRTABLE_TABLE, AIRTABLE_FIELD] + if not value: sys.exit("Configuration error: Missing AirTable environment variable.") From e99fdfe4601c16aae18e5cf39d8531dbbc5ce658 Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 15:10:28 +0100 Subject: [PATCH 6/6] Fix missing colon --- setup-scripts/blocklist-airtable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index d0279e5f..028b18ee 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -21,7 +21,7 @@ AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE") AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD") # Check environment variables are defined -for e in [AIRTABLE_API_KEY, AIRTABLE_BASE, AIRTABLE_TABLE, AIRTABLE_FIELD] +for e in [AIRTABLE_API_KEY, AIRTABLE_BASE, AIRTABLE_TABLE, AIRTABLE_FIELD]: if not e: sys.exit("Configuration error: Missing AirTable environment variable.")