Skip to content

Commit 248316d

Browse files
authored
Merge pull request #75 from WolfeLogix/FireStore-Test
Refactor credentials system
2 parents 49f41c9 + 5797380 commit 248316d

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

.github/workflows/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ jobs:
6565
--region "${{ secrets.GCP_REGION }}" \
6666
--allow-unauthenticated \
6767
--project "${{ secrets.GCP_PROJECT_ID }}" \
68-
--update-secrets="PRINTIFY_API_KEY=PRINTIFY_API_KEY:latest,OPENAI_API_KEY=OPENAI_API_KEY:latest,GH_PAT=GH_PAT:latest,GH_UPLOAD_REPO=GH_UPLOAD_REPO:latest,GH_CONTENT_PREFIX=GH_CONTENT_PREFIX:latest,API_KEY=API_KEY:latest,SHOPIFY_API_KEY=SHOPIFY_API_KEY:latest,SHOPIFY_API_ACCESS_TOKEN=SHOPIFY_API_ACCESS_TOKEN:latest,SHOPIFY_SHOP_NAME=SHOPIFY_SHOP_NAME:latest,FIRESTORE_USER=FIRESTORE_USER:latest"
68+
--update-secrets="PRINTIFY_API_KEY=PRINTIFY_API_KEY:latest,OPENAI_API_KEY=OPENAI_API_KEY:latest,GH_PAT=GH_PAT:latest,GH_UPLOAD_REPO=GH_UPLOAD_REPO:latest,GH_CONTENT_PREFIX=GH_CONTENT_PREFIX:latest,API_KEY=API_KEY:latest,SHOPIFY_API_KEY=SHOPIFY_API_KEY:latest,SHOPIFY_API_ACCESS_TOKEN=SHOPIFY_API_ACCESS_TOKEN:latest,SHOPIFY_SHOP_NAME=SHOPIFY_SHOP_NAME:latest"
6969
env:
7070
CLOUD_RUN_SERVICE: ${{ github.event.repository.name }}

app/database/firebase.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,10 @@ def __init__(self):
1010
"""Initialize Firestore."""
1111
try:
1212
# Get the Firestore key from the environment variable
13-
credentials_content = os.getenv("FIRESTORE_USER")
14-
if not credentials_content:
15-
raise EnvironmentError(
16-
"FIRESTORE_USER environment variable not set.")
17-
18-
# Determine if it's a JSON string or a file path
19-
# Likely a JSON string
20-
if credentials_content.strip().startswith("{"):
21-
cred_dict = json.loads(credentials_content)
22-
cred = credentials.Certificate(cred_dict)
23-
elif os.path.exists(credentials_content): # It's a file path
24-
cred = credentials.Certificate(credentials_content)
25-
else:
26-
raise ValueError(
27-
"FIRESTORE_USER environment variable contains invalid content. "
28-
"Ensure it is either a valid JSON string or a file path."
29-
)
13+
credentials_path = os.getenv("FIRESTORE_USER", None)
14+
cred = None
15+
if credentials_path:
16+
cred = credentials.Certificate(credentials_path)
3017

3118
# Initialize Firestore
3219
initialize_app(cred)

0 commit comments

Comments
 (0)