bitwarden-crd-operator/src/bitwardenCrdOperator.py

21 lines
603 B
Python
Raw Normal View History

2022-11-12 22:57:42 +00:00
#!/usr/bin/env python3
import os
2023-04-21 12:39:06 +00:00
import kopf
2022-11-12 22:57:42 +00:00
from utils.utils import command_wrapper, unlock_bw
2022-11-12 22:57:42 +00:00
2023-04-21 12:39:06 +00:00
2022-11-12 22:57:42 +00:00
@kopf.on.startup()
def bitwarden_signin(logger, **kwargs):
if 'BW_HOST' in os.environ:
2022-11-26 20:33:31 +00:00
try:
command_wrapper(logger, f"config server {os.getenv('BW_HOST')}")
2023-04-21 12:39:06 +00:00
except BaseException:
logger.warn("Received non-zero exit code from server config")
2022-11-26 20:33:31 +00:00
logger.warn("This is expected from startup")
pass
2022-11-12 22:57:42 +00:00
else:
2023-04-21 12:39:06 +00:00
logger.info("BW_HOST not set. Assuming SaaS installation")
command_wrapper(logger, "login --apikey")
2022-11-12 22:57:42 +00:00
unlock_bw(logger)