Compare commits

...

1 Commits

Author SHA1 Message Date
Roman Acevedo
834d3d6b14 feat(core): forward execution labels in Flow Trigger 2025-04-17 15:27:51 +02:00
2 changed files with 9 additions and 0 deletions

View File

@@ -277,6 +277,7 @@ public class Flow extends AbstractTrigger implements TriggerOutput<Flow.Output>
this,
Output.builder()
.executionId(current.getId())
.executionLabels(Label.toNestedMap(current.getLabels().stream().filter(label -> !label.key().equals(Label.CORRELATION_ID)).collect(Collectors.toList())))
.namespace(current.getNamespace())
.flowId(current.getFlowId())
.flowRevision(current.getFlowRevision())
@@ -579,6 +580,10 @@ public class Flow extends AbstractTrigger implements TriggerOutput<Flow.Output>
@NotNull
private String executionId;
@Schema(title = "The execution labels that triggered the current flow.")
@NotNull
private Map<String, Object> executionLabels;
@Schema(title = "The execution state.")
@NotNull
private State.Type state;

View File

@@ -2,6 +2,7 @@ package io.kestra.plugin.core.trigger;
import io.kestra.core.models.Label;
import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.executions.ExecutionTrigger;
import io.kestra.core.models.flows.State;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface;
@@ -14,6 +15,7 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
@@ -173,5 +175,7 @@ class FlowTest {
assertThat(evaluate.get().getLabels()).contains(new Label("trigger-label-2", "trigger-label-2"));
assertThat(evaluate.get().getLabels()).contains(new Label("trigger-label-3", ""));
assertThat(evaluate.get().getLabels()).contains(new Label(Label.CORRELATION_ID, "correlationId"));
assertThat(evaluate.get().getTrigger()).extracting(ExecutionTrigger::getVariables).hasFieldOrProperty("executionLabels");
assertThat(evaluate.get().getTrigger().getVariables().get("executionLabels")).isEqualTo(Map.of("execution-label", "execution"));
}
}