fixed secret creation \o/
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
122f623bc8
commit
a1287a1a6d
@ -21,7 +21,7 @@ def command_wrapper(logger, command):
|
|||||||
out, err = sp.communicate()
|
out, err = sp.communicate()
|
||||||
if err:
|
if err:
|
||||||
logger.warn(f"Error during bw cli invokement: {err}")
|
logger.warn(f"Error during bw cli invokement: {err}")
|
||||||
return str(out)
|
return out.decode(encoding='UTF-8')
|
||||||
|
|
||||||
@kopf.on.startup()
|
@kopf.on.startup()
|
||||||
def bitwarden_signin(logger, **kwargs):
|
def bitwarden_signin(logger, **kwargs):
|
||||||
@ -42,22 +42,20 @@ def create_fn(spec, name, namespace, logger, **kwargs):
|
|||||||
|
|
||||||
unlock_bw(logger)
|
unlock_bw(logger)
|
||||||
|
|
||||||
secret_json_string = get_secret_from_bitwarden(logger, id)
|
secret_json_object = json.loads(get_secret_from_bitwarden(logger, id))
|
||||||
|
|
||||||
secret_json_object = json.loads(secret_json_string)
|
|
||||||
|
|
||||||
api = kubernetes.client.CoreV1Api()
|
api = kubernetes.client.CoreV1Api()
|
||||||
|
|
||||||
annotations = {
|
annotations = {
|
||||||
"managed": "bitwarden-secrets.lerentis.uploadfilter24.eu",
|
"managed": "bitwarden-secrets.lerentis.uploadfilter24.eu",
|
||||||
"managedObject": name
|
"managedObject": f"{namespace}/{name}"
|
||||||
}
|
}
|
||||||
secret = kubernetes.client.V1Secret()
|
secret = kubernetes.client.V1Secret()
|
||||||
secret.metadata = kubernetes.client.V1ObjectMeta(name=secret_name, annotations=annotations)
|
secret.metadata = kubernetes.client.V1ObjectMeta(name=secret_name, annotations=annotations)
|
||||||
secret.type = "Opaque"
|
secret.type = "Opaque"
|
||||||
secret.data = {
|
secret.data = {
|
||||||
'username': str(base64.b64encode(secret_json_object["login.username"].encode("utf-8")), "utf-8"),
|
'username': str(base64.b64encode(secret_json_object["login"]["username"].encode("utf-8")), "utf-8"),
|
||||||
'password': str(base64.b64encode(secret_json_object["login.password"].encode("utf-8")), "utf-8")
|
'password': str(base64.b64encode(secret_json_object["login"]["password"].encode("utf-8")), "utf-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = api.create_namespaced_secret(
|
obj = api.create_namespaced_secret(
|
||||||
|
Loading…
Reference in New Issue
Block a user