Skip to content

Commit 3b59fcc

Browse files
committed
allow empty object digest generation for annotations
1 parent 1bf14b6 commit 3b59fcc

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

charts/fluent-bit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ existingConfigMap: fluent-bit
66

77
podAnnotations:
88
checksum/config: '__slot__:salt:metalk8s_kubernetes.get_object_digest(kind="ConfigMap", apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit", path="data:fluent-bit.conf")'
9-
checksum/secret: '__slot__:salt:metalk8s_kubernetes.get_object_digest(kind="Secret", apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit-certs")'
9+
checksum/secret: '__slot__:salt:metalk8s_kubernetes.get_object_digest(kind="Secret", apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit-certs", allow_empty=True)'
1010

1111
resources: '__var__(fluent_bit.spec.deployment.resources)'
1212

salt/_modules/metalk8s_kubernetes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def list_objects(
410410
return result.to_dict()["items"]
411411

412412

413-
def get_object_digest(path=None, checksum="sha256", *args, **kwargs):
413+
def get_object_digest(allow_empty=False, path=None, checksum="sha256", *args, **kwargs):
414414
"""
415415
Helper to get the digest of one kubernetes object or from a specific key
416416
of this object using a path
@@ -432,7 +432,11 @@ def get_object_digest(path=None, checksum="sha256", *args, **kwargs):
432432
obj = salt.utils.data.traverse_dict_and_list(obj, path, delimiter=":")
433433

434434
if not obj:
435-
raise CommandExecutionError(f'Unable to find key "{path}" in the object')
435+
if not allow_empty:
436+
raise CommandExecutionError(
437+
f'Unable to find key "{path}" in the object'
438+
)
439+
return ""
436440

437441
if isinstance(obj, dict):
438442
obj = json.dumps(obj, sort_keys=True)

salt/metalk8s/addons/logging/fluent-bit/deployed/secret.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Create metalk8s-fluent-bit-certs Secret:
1919
metadata:
2020
name: fluent-bit-certs
2121
namespace: metalk8s-logging
22+
data: {}
2223

2324
{%- else %}
2425

0 commit comments

Comments
 (0)