wip but at least i get the correct dict values now
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
63fcf5b05f
commit
fb33e28cd7
@ -6,6 +6,8 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
def get_secret_from_bitwarden(logger, id):
|
def get_secret_from_bitwarden(logger, id):
|
||||||
return command_wrapper(logger, f"get item {id}")
|
return command_wrapper(logger, f"get item {id}")
|
||||||
|
|
||||||
@ -33,15 +35,12 @@ def bitwarden_signin(logger, **kwargs):
|
|||||||
unlock_bw(logger)
|
unlock_bw(logger)
|
||||||
|
|
||||||
@kopf.on.create('bitwarden-secrets.lerentis.uploadfilter24.eu')
|
@kopf.on.create('bitwarden-secrets.lerentis.uploadfilter24.eu')
|
||||||
def create_fn(spec, name, namespace, logger, **kwargs):
|
def create_fn(spec, name, namespace, logger, body, **kwargs):
|
||||||
|
|
||||||
|
logger.info(f"Type of spec: {type(body)}")
|
||||||
|
scope = body['spec']['scope']
|
||||||
|
logger.info(f"spec: {scope}")
|
||||||
|
|
||||||
scope = spec.get('scope')
|
|
||||||
items = []
|
|
||||||
for index in range(len(scope)):
|
|
||||||
for element in scope[index]:
|
|
||||||
logger.info(f"Type: {type(element)}")
|
|
||||||
for test in element:
|
|
||||||
logger.info(f"Key: {test}")
|
|
||||||
|
|
||||||
|
|
||||||
id = spec.get('id')
|
id = spec.get('id')
|
||||||
@ -61,10 +60,13 @@ def create_fn(spec, name, namespace, logger, **kwargs):
|
|||||||
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"),
|
for elemw in scope:
|
||||||
'password': str(base64.b64encode(secret_json_object["login"]["password"].encode("utf-8")), "utf-8")
|
for k, elem in elemw.items():
|
||||||
}
|
for key,value in elem.items():
|
||||||
|
logger.info(f"key: {key} value: {value}")
|
||||||
|
secret.data["username"] = str(base64.b64encode(secret_json_object["login"]["username"].encode("utf-8")), "utf-8")
|
||||||
|
secret.data["password"] = str(base64.b64encode(secret_json_object["login"]["password"].encode("utf-8")), "utf-8")
|
||||||
|
|
||||||
obj = api.create_namespaced_secret(
|
obj = api.create_namespaced_secret(
|
||||||
secret_namespace, secret
|
secret_namespace, secret
|
||||||
|
Loading…
Reference in New Issue
Block a user