added config py file that can read from env vars w/ burnettk

This commit is contained in:
jasquat 2023-02-22 10:19:14 -05:00
parent d815cfeb90
commit a68264d785
No known key found for this signature in database
7 changed files with 24 additions and 13 deletions

1
.gitignore vendored
View File

@ -64,7 +64,6 @@ db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
config.py
# Scrapy stuff:
.scrapy

12
config.py Normal file
View File

@ -0,0 +1,12 @@
from os import environ
CONNECTOR_PROXY_WAKU_BASE_URL = environ.get("CONNECTOR_PROXY_WAKU_BASE_URL", default="http://localhost:8545")
CONNECTOR_PROXY_XERO_CLIENT_ID = environ.get("CONNECTOR_PROXY_XERO_CLIENT_ID")
CONNECTOR_PROXY_XERO_CLIENT_SECRET = environ.get("CONNECTOR_PROXY_XERO_CLIENT_SECRET")
CONNECTOR_PROXY_POSTGRESQL_DB_NAME = environ.get("CONNECTOR_PROXY_POSTGRESQL_DB_NAME", default="spiffworkflow_secondary_storage_dev")
CONNECTOR_PROXY_POSTGRESQL_USER_NAME = environ.get("CONNECTOR_PROXY_POSTGRESQL_USER_NAME", default="postgres")
CONNECTOR_PROXY_POSTGRESQL_HOST = environ.get("CONNECTOR_PROXY_POSTGRESQL_HOST", default="localhost")
CONNECTOR_PROXY_POSTGRESQL_PORT = environ.get("CONNECTOR_PROXY_POSTGRESQL_PORT", default="7005")
CONNECTOR_PROXY_POSTGRESQL_PASSWORD = environ.get("CONNECTOR_PROXY_POSTGRESQL_PASSWORD")

View File

@ -69,10 +69,10 @@ class BaseCommand:
return f"WHERE {' AND '.join(columns)}", values
def _get_db_connection_str(self, config):
host = config["POSTGRESQL_HOST"]
port = config["POSTGRESQL_PORT"]
database = config["POSTGRESQL_DB_NAME"]
username = config["POSTGRESQL_USER_NAME"]
password = config["POSTGRESQL_PASSWORD"]
host = config["CONNECTOR_PROXY_POSTGRESQL_HOST"]
port = config["CONNECTOR_PROXY_POSTGRESQL_PORT"]
database = config["CONNECTOR_PROXY_POSTGRESQL_DB_NAME"]
username = config["CONNECTOR_PROXY_POSTGRESQL_USER_NAME"]
password = config["CONNECTOR_PROXY_POSTGRESQL_PASSWORD"]
return f"dbname={database} user={username} password={password} host={host} port={port}"

View File

@ -33,7 +33,7 @@ class SendMessage:
recipient: list[str]
def send_message(self, message_type_to_use: str, rec: str, message_to_send: Optional[str] = None) -> None:
url = f'{current_app.config["WAKU_BASE_URL"]}'
url = f'{current_app.config["CONNECTOR_PROXY_WAKU_BASE_URL"]}'
headers = {"Accept": "application/json", "Content-type": "application/json"}
request_body = {
"jsonrpc": "2.0",

View File

@ -12,8 +12,8 @@ class OAuth:
return {
"name": "xero",
"version": "2",
"client_id": config["XERO_CLIENT_ID"],
"client_secret": config["XERO_CLIENT_SECRET"],
"client_id": config["CONNECTOR_PROXY_XERO_CLIENT_ID"],
"client_secret": config["CONNECTOR_PROXY_XERO_CLIENT_SECRET"],
"endpoint_url": "https://api.xero.com/",
"authorization_url": "https://login.xero.com/identity/connect/authorize",
"access_token_url": "https://identity.xero.com/connect/token",

View File

@ -161,8 +161,8 @@ class CreateInvoice:
def execute(self, config, task_data):
"""Creates an invoice in xero."""
client_id = config["XERO_CLIENT_ID"]
client_secret = config["XERO_CLIENT_SECRET"]
client_id = config["CONNECTOR_PROXY_XERO_CLIENT_ID"]
client_secret = config["CONNECTOR_PROXY_XERO_CLIENT_SECRET"]
# this should be called token_set to match the docs
access_token = json.loads(self.access_token)

View File

@ -35,8 +35,8 @@ class GetCurrencies:
def execute(self, config, task_data):
"""Get currencies configured in xero."""
client_id = config["XERO_CLIENT_ID"]
client_secret = config["XERO_CLIENT_SECRET"]
client_id = config["CONNECTOR_PROXY_XERO_CLIENT_ID"]
client_secret = config["CONNECTOR_PROXY_XERO_CLIENT_SECRET"]
# this should be called token_set to match the docs
access_token = json.loads(self.access_token)