From 163c9d53ad922ed34b271da445a91b871a6eb5f0 Mon Sep 17 00:00:00 2001 From: YannC Date: Thu, 14 Mar 2024 12:47:54 +0100 Subject: [PATCH] feat(core): ExecutionLabelsCondition closes #2720 --- .../types/ExecutionLabelsCondition.java | 67 ++++++++++++++ .../types/ExecutionLabelsConditionTest.java | 91 +++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 core/src/main/java/io/kestra/core/models/conditions/types/ExecutionLabelsCondition.java create mode 100644 core/src/test/java/io/kestra/core/models/conditions/types/ExecutionLabelsConditionTest.java diff --git a/core/src/main/java/io/kestra/core/models/conditions/types/ExecutionLabelsCondition.java b/core/src/main/java/io/kestra/core/models/conditions/types/ExecutionLabelsCondition.java new file mode 100644 index 00000000000..ea0083aefa1 --- /dev/null +++ b/core/src/main/java/io/kestra/core/models/conditions/types/ExecutionLabelsCondition.java @@ -0,0 +1,67 @@ +package io.kestra.core.models.conditions.types; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.kestra.core.exceptions.InternalException; +import io.kestra.core.models.Label; +import io.kestra.core.models.annotations.Example; +import io.kestra.core.models.annotations.Plugin; +import io.kestra.core.models.annotations.PluginProperty; +import io.kestra.core.models.conditions.Condition; +import io.kestra.core.models.conditions.ConditionContext; +import io.kestra.core.serializers.ListOrMapOfLabelDeserializer; +import io.kestra.core.serializers.ListOrMapOfLabelSerializer; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +import java.util.List; +import java.util.Map; + +@SuperBuilder +@ToString +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Schema( + title = "Condition for a specific flow. Note that this condition is deprecated, use `ExecutionFlowCondition` instead." +) +@Plugin( + examples = { + @Example( + full = true, + code = { + "- conditions:", + " - type: io.kestra.core.models.conditions.types.ExecutionLabelsCondition", + " labels:", + " owner: john.doe" + } + ) + } +) +public class ExecutionLabelsCondition extends Condition { + + @JsonSerialize(using = ListOrMapOfLabelSerializer.class) + @JsonDeserialize(using = ListOrMapOfLabelDeserializer.class) + @NotNull + @Schema( + description = "String against which to match the execution namespace depending on the provided comparison.", + implementation = Object.class, anyOf = {List.class, Map.class} + ) + @PluginProperty + List