From 3e6f3330f176b155fc224eb2e24b75e9e258cab3 Mon Sep 17 00:00:00 2001 From: kimsehwan96 Date: Sat, 21 Dec 2024 01:47:56 +0900 Subject: [PATCH] Add logics to change type when argocd rollout managed object' labels and annotations are passed --- .../core/integrations/kubernetes/__init__.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/robusta_krr/core/integrations/kubernetes/__init__.py b/robusta_krr/core/integrations/kubernetes/__init__.py index f63f81b..4fe3030 100644 --- a/robusta_krr/core/integrations/kubernetes/__init__.py +++ b/robusta_krr/core/integrations/kubernetes/__init__.py @@ -201,16 +201,15 @@ def __build_scannable_object( namespace = item.metadata.namespace kind = kind or item.__class__.__name__[2:] - labels = {} - annotations = {} - if item.metadata.labels: - labels = item.metadata.labels - - if item.metadata.annotations: - if type(item.metadata.annotations) is ObjectLikeDict: - annotations = item.metadata.annotations.__dict__ - else: - annotations = item.metadata.annotations + labels = item.metadata.labels or {} + annotations = item.metadata.annotations or {} + + # NOTE: Argocd Rollouts managed object' labels and annotations are interpreted as ObjectLikeDict + if labels and type(labels) is ObjectLikeDict: + labels = labels.__dict__ + + if annotations and type(annotations) is ObjectLikeDict: + annotations = annotations.__dict__ obj = K8sObjectData( cluster=self.cluster,