mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-26 14:00:23 -05:00
Compare commits
1 Commits
dependabot
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aee4524b7e |
@@ -36,6 +36,19 @@ import static io.kestra.core.models.Label.SYSTEM_PREFIX;
|
|||||||
@Singleton
|
@Singleton
|
||||||
@Introspected
|
@Introspected
|
||||||
public class FlowValidator implements ConstraintValidator<FlowValidation, Flow> {
|
public class FlowValidator implements ConstraintValidator<FlowValidation, Flow> {
|
||||||
|
public static List<String> RESERVED_FLOW_IDS = List.of(
|
||||||
|
"pause",
|
||||||
|
"resume",
|
||||||
|
"force-run",
|
||||||
|
"change-status",
|
||||||
|
"kill",
|
||||||
|
"executions",
|
||||||
|
"search",
|
||||||
|
"source",
|
||||||
|
"disable",
|
||||||
|
"enable"
|
||||||
|
);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private FlowService flowService;
|
private FlowService flowService;
|
||||||
|
|
||||||
@@ -50,6 +63,10 @@ public class FlowValidator implements ConstraintValidator<FlowValidation, Flow>
|
|||||||
|
|
||||||
List<String> violations = new ArrayList<>();
|
List<String> violations = new ArrayList<>();
|
||||||
|
|
||||||
|
if (RESERVED_FLOW_IDS.contains(value.getId())) {
|
||||||
|
violations.add("Flow id is a reserved keyword: " + value.getId() + ". List of reserved keywords: " + String.join(", ", RESERVED_FLOW_IDS));
|
||||||
|
}
|
||||||
|
|
||||||
if (flowService.requireExistingNamespace(value.getTenantId(), value.getNamespace())) {
|
if (flowService.requireExistingNamespace(value.getTenantId(), value.getNamespace())) {
|
||||||
violations.add("Namespace '" + value.getNamespace() + "' does not exist but is required to exist before a flow can be created in it.");
|
violations.add("Namespace '" + value.getNamespace() + "' does not exist but is required to exist before a flow can be created in it.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,4 +412,23 @@ class FlowServiceTest {
|
|||||||
"The task 'for' cannot use the 'workerGroup' property as it's only relevant for runnable tasks."
|
"The task 'for' cannot use the 'workerGroup' property as it's only relevant for runnable tasks."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReturnValidationErrorForReservedFlowId() {
|
||||||
|
// Given
|
||||||
|
String source = """
|
||||||
|
id: pause
|
||||||
|
namespace: io.kestra.unittest
|
||||||
|
tasks:
|
||||||
|
- id: task
|
||||||
|
type: io.kestra.plugin.core.log.Log
|
||||||
|
message: Reserved id test
|
||||||
|
""";
|
||||||
|
// When
|
||||||
|
List<ValidateConstraintViolation> results = flowService.validate("my-tenant", source);
|
||||||
|
|
||||||
|
// Then
|
||||||
|
assertThat(results).hasSize(1);
|
||||||
|
assertThat(results.getFirst().getConstraints()).contains("Flow id is a reserved keyword: pause");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user