Skip to content

Commit

Permalink
fix checking for libre translate api key
Browse files Browse the repository at this point in the history
  • Loading branch information
jessebot committed Nov 17, 2024
1 parent 23f6928 commit 9069aef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
8 changes: 7 additions & 1 deletion smol_k8s_lab/k8s_apps/social/libre_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,10 @@ def refresh_bitwarden(argocd: ArgoCD,

argocd.update_appset_secret({'libretranslate_credentials_bitwarden_id': api_id})

return api_item['data']['login']['password']
print(" 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 ")
print(api_item)
print(" 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 ")
api_key = api_item['login']['password']
print(" 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 🦇 ")

return api_key
20 changes: 11 additions & 9 deletions smol_k8s_lab/k8s_apps/social/mastodon.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,21 @@ def configure_mastodon(argocd: ArgoCD,
mastodon_namespace = cfg['argo']['namespace']

if init_enabled:
# declare custom values for mastodon
init_values = init.get('values', None)

# backups are their own config.yaml section
backup_vals = process_backup_vals(cfg.get('backups', {}), 'mastodon', argocd)

# get the api key for LibreTranslate, so we can translate posts
libre_api_key = extract_secret(init_values.get('libretranslate_api_key'))
if not libre_api_key:
libre_api_key = libretranslate_api_key

if init_enabled and not app_installed:
argocd.k8s.create_namespace(mastodon_namespace)

if not restore_enabled:
# declare custom values for mastodon
init_values = init.get('values', None)
# configure the admin user credentials
mastodon_admin_username = init_values.get('admin_user', 'tootadmin')
mastodon_admin_email = init_values.get('admin_email', '')
Expand All @@ -90,11 +96,6 @@ def configure_mastodon(argocd: ArgoCD,
s3_access_id = 'mastodon'
s3_access_key = create_password()

# get the api key for LibreTranslate, so we can translate posts
libre_api_key = extract_secret(init_values.get('libretranslate_api_key'))
if not libre_api_key:
libre_api_key = libretranslate_api_key

s3_endpoint = secrets.get('s3_endpoint', "")
log.debug(f"Mastodon s3_endpoint at the start is: {s3_endpoint}")

Expand Down Expand Up @@ -272,8 +273,9 @@ def refresh_bweso(argocd: ArgoCD,
libretranslate_api_key_item = bitwarden.get_item(
f"mastodon-libretranslate-credentials-{mastodon_hostname}", False
)[0]
libretranslate_api_key_id = libretranslate_api_key_item.get('id', "")
if not libretranslate_api_key_id:
if libretranslate_api_key_item:
libretranslate_api_key_id = libretranslate_api_key_item.get('id', "")
else:
endpoint = create_custom_field('endpoint',
mastodon_libretranslate_hostname)
libretranslate_api_key_id = bitwarden.create_login(
Expand Down

0 comments on commit 9069aef

Please sign in to comment.