variable google project id

This commit is contained in:
Andy Pack 2023-09-05 23:22:44 +01:00
parent 07d5f42f11
commit 023cdf909f
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
4 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,6 @@
from flask import Blueprint, jsonify
import os
import logging
from datetime import datetime
@ -10,7 +11,7 @@ from music.api.decorators import login_or_jwt, admin_required, no_locked_users
blueprint = Blueprint('admin-api', __name__)
tasker = tasks_v2.CloudTasksClient()
task_path = tasker.queue_path('sarsooxyz', 'europe-west2', 'spotify-executions')
task_path = tasker.queue_path(os.environ['GOOGLE_CLOUD_PROJECT'], 'europe-west2', 'spotify-executions')
logger = logging.getLogger(__name__)

View File

@ -1,4 +1,5 @@
import logging
import os
from google.cloud import pubsub_v1
publisher = pubsub_v1.PublisherClient()
@ -23,7 +24,7 @@ def update_tag(username: str, tag_id: str) -> None:
logger.error(f'less than two strings provided, {type(username)} / {type(tag_id)}')
return
publisher.publish('projects/sarsooxyz/topics/update_tag', b'', tag_id=tag_id, username=username)
publisher.publish(f'projects/{os.environ["GOOGLE_CLOUD_PROJECT"]}/topics/update_tag', b'', tag_id=tag_id, username=username)
def run_user_playlist_function(username: str, playlist_name: str) -> None:
@ -44,4 +45,4 @@ def run_user_playlist_function(username: str, playlist_name: str) -> None:
logger.error(f'less than two strings provided, {type(username)} / {type(playlist_name)}')
return
publisher.publish('projects/sarsooxyz/topics/run_user_playlist', b'', name=playlist_name, username=username)
publisher.publish(f'projects/{os.environ["GOOGLE_CLOUD_PROJECT"]}/topics/run_user_playlist', b'', name=playlist_name, username=username)

View File

@ -17,7 +17,7 @@ from music.model.playlist import Playlist
from music.model.tag import Tag
tasker = tasks_v2.CloudTasksClient()
task_path = tasker.queue_path('sarsooxyz', 'europe-west2', 'spotify-executions')
task_path = tasker.queue_path(os.environ['GOOGLE_CLOUD_PROJECT'], 'europe-west2', 'spotify-executions')
logger = logging.getLogger(__name__)

View File

@ -1,6 +1,9 @@
SPOT_CLIENT_URI = "projects/sarsooxyz/secrets/spotify-client/versions/latest"
SPOT_SECRET_URI = "projects/sarsooxyz/secrets/spotify-secret/versions/latest"
LASTFM_CLIENT_URI = "projects/sarsooxyz/secrets/lastfm-client/versions/latest"
JWT_SECRET_URI = "projects/sarsooxyz/secrets/jwt-secret/versions/latest"
COOKIE_SECRET_URI = "projects/sarsooxyz/secrets/cookie-secret/versions/latest"
APNS_SIGN_URI = "projects/sarsooxyz/secrets/apns-auth-sign-key/versions/1"
import os
project_id = os.environ.get('GOOGLE_CLOUD_PROJECT')
SPOT_CLIENT_URI = f"projects/{project_id}/secrets/spotify-client/versions/latest"
SPOT_SECRET_URI = f"projects/{project_id}/secrets/spotify-secret/versions/latest"
LASTFM_CLIENT_URI = f"projects/{project_id}/secrets/lastfm-client/versions/latest"
JWT_SECRET_URI = f"projects/{project_id}/secrets/jwt-secret/versions/latest"
COOKIE_SECRET_URI = f"projects/{project_id}/secrets/cookie-secret/versions/latest"
APNS_SIGN_URI = f"projects/{project_id}/secrets/apns-auth-sign-key/versions/1"