Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat committed Dec 12, 2024
1 parent 008bf6c commit 3597178
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions hooks/moduleconfig_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def generate_config(self) -> dict:
"nameSelector": {
"matchNames": [self.module_name]
},
"group": "main",
"includeSnapshotsFrom": [self.SNAPSHOT_NAME],
"jqFilter": '{"labels": .metadata.labels}',
"queue": f"/modules/{self.module_name}/{self.SNAPSHOT_NAME}",
"keepFullObjectsInMemory": False
Expand All @@ -52,14 +52,18 @@ def generate_config(self) -> dict:
def reconcile(self) -> Callable[[hook.Context], None]:
def r(ctx: hook.Context):
labels = {}
if (snaps := ctx.snapshots.get(self.SNAPSHOT_NAME, [])) and len(snaps) > 0:
labels = snaps[0]["filterResult"]["labels"]
try:
if (l := ctx.snapshots[self.SNAPSHOT_NAME][0]["filterResult"]["labels"]) and l is not None:
labels = l
except (IndexError, KeyError):
pass

if labels.get(self.LABEL, "") == self.module_name:
return

ctx.kubernetes.merge_patch(
kind=self.KIND,
namespace="",
name=self.module_name,
patch={
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ webhooks:
service:
namespace: d8-{{ .Chart.Name }}
name: virtualization-controller
path: /validate-deckhouse-io-v1alpha1-moduleconfigs
path: /validate-deckhouse-io-v1alpha1-moduleconfig
port: 443
caBundle: |
{{ .Values.virtualization.internal.controller.cert.ca }}
Expand Down

0 comments on commit 3597178

Please sign in to comment.