From 6f69dbbad454d1cf1a59ef596dd80b0e23150d71 Mon Sep 17 00:00:00 2001 From: Florian Hussonnois Date: Fri, 17 Jan 2025 14:34:15 +0100 Subject: [PATCH] fix(core): fix some labels are lost when having same prefix key This commit fix an issue where only a single system label was injected in the run context fix: kestra-io/kestra-ee#2697 --- .../java/io/kestra/core/models/Label.java | 16 ++++++++ .../io/kestra/core/runners/RunVariables.java | 27 +------------- .../java/io/kestra/core/models/LabelTest.java | 37 +++++++++++++++++++ 3 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 core/src/test/java/io/kestra/core/models/LabelTest.java diff --git a/core/src/main/java/io/kestra/core/models/Label.java b/core/src/main/java/io/kestra/core/models/Label.java index 9e8fa87f092..1db12b6488e 100644 --- a/core/src/main/java/io/kestra/core/models/Label.java +++ b/core/src/main/java/io/kestra/core/models/Label.java @@ -1,9 +1,11 @@ package io.kestra.core.models; +import io.kestra.core.utils.MapUtils; import jakarta.validation.constraints.NotNull; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public record Label(@NotNull String key, @NotNull String value) { public static final String SYSTEM_PREFIX = "system."; @@ -14,6 +16,20 @@ public record Label(@NotNull String key, @NotNull String value) { public static final String APP = SYSTEM_PREFIX + "app"; public static final String READ_ONLY = SYSTEM_PREFIX + "readOnly"; + /** + * Static helper method for converting a list of labels to a nested map. + * + * @param labels The list of {@link Label} to be converted. + * @return the nested {@link Map}. + */ + public static Map toNestedMap(List