Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/src/main/java/io/kestra/core/app/AppBlockInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

/**
* Top-level marker interface for Kestra's plugin of type App.
*/
Expand All @@ -18,6 +20,6 @@ public interface AppBlockInterface extends io.kestra.core.models.Plugin {
)
@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
String getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

/**
* Top-level marker interface for Kestra's plugin of type App.
*/
Expand All @@ -18,6 +20,6 @@ public interface AppPluginInterface extends io.kestra.core.models.Plugin {
)
@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
String getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@io.kestra.core.models.annotations.Plugin
@SuperBuilder
@Getter
Expand All @@ -20,6 +22,6 @@
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public abstract class Condition implements Plugin, Rethrow.PredicateChecked<ConditionContext, InternalException> {
@NotNull
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
protected String type;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.Map;
import java.util.Set;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@SuperBuilder(toBuilder = true)
@Getter
@NoArgsConstructor
Expand All @@ -28,7 +30,7 @@
public abstract class DataFilter<F extends Enum<F>, C extends ColumnDescriptor<F>> implements io.kestra.core.models.Plugin, IData<F> {
@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
private String type;

private Map<String, C> columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.List;
import java.util.Set;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@SuperBuilder(toBuilder = true)
@Getter
@NoArgsConstructor
Expand All @@ -27,7 +29,7 @@
public abstract class DataFilterKPI<F extends Enum<F>, C extends ColumnDescriptor<F>> implements io.kestra.core.models.Plugin, IData<F> {
@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
private String type;

private C columns;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@SuperBuilder(toBuilder = true)
@Getter
@NoArgsConstructor
Expand All @@ -26,7 +28,7 @@ public abstract class Chart<P extends ChartOption> implements io.kestra.core.mod

@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
protected String type;

@Valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class TaskRun implements TenantInterface {

@With
@JsonInclude(JsonInclude.Include.ALWAYS)
@Nullable
Variables outputs;

@NotNull
Expand All @@ -64,7 +65,6 @@ public class TaskRun implements TenantInterface {
Boolean dynamic;

// Set it to true to force execution even if the execution is killed
@Nullable
@With
Boolean forceExecution;

Expand Down Expand Up @@ -217,7 +217,7 @@ public TaskRun onRunningResend() {
public boolean isSame(TaskRun taskRun) {
return this.getId().equals(taskRun.getId()) &&
((this.getValue() == null && taskRun.getValue() == null) || (this.getValue() != null && this.getValue().equals(taskRun.getValue()))) &&
((this.getIteration() == null && taskRun.getIteration() == null) || (this.getIteration() != null && this.getIteration().equals(taskRun.getIteration()))) ;
((this.getIteration() == null && taskRun.getIteration() == null) || (this.getIteration() != null && this.getIteration().equals(taskRun.getIteration())));
}

public String toString(boolean pretty) {
Expand Down Expand Up @@ -249,7 +249,7 @@ public String toStringState() {
* This method is used when the retry is apply on a task
* but the retry type is NEW_EXECUTION
*
* @param retry Contains the retry configuration
* @param retry Contains the retry configuration
* @param execution Contains the attempt number and original creation date
* @return The next retry date, null if maxAttempt || maxDuration is reached
*/
Expand All @@ -270,6 +270,7 @@ public Instant nextRetryDate(AbstractRetry retry, Execution execution) {

/**
* This method is used when the Retry definition comes from the flow
*
* @param retry The retry configuration
* @return The next retry date, null if maxAttempt || maxDuration is reached
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ public abstract class AbstractFlow implements FlowInterface {
Map<String, Object> variables;


@Schema(
oneOf = {
String.class, // Corresponds to 'type: string' in OpenAPI
Map.class // Corresponds to 'type: object' in OpenAPI
}
)
interface StringOrMapValue {}

@Valid
private WorkerGroup workerGroup;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ public class PluginDefault {

@Schema(
type = "object",
oneOf = {
Map.class,
String.class
},
additionalProperties = Schema.AdditionalPropertiesValue.FALSE
)
private final Map<String, Object> values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public interface TaskInterface extends Plugin, PluginVersioning {
@NotNull
Expand All @@ -17,7 +19,7 @@ public interface TaskInterface extends Plugin, PluginVersioning {

@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
@Schema(title = "The class name of this task.")
String getType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import lombok.experimental.SuperBuilder;
import reactor.core.publisher.Flux;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@Plugin
@SuperBuilder(toBuilder = true)
@Getter
Expand All @@ -22,7 +24,7 @@ public abstract class LogExporter<T extends Output> implements io.kestra.core.m
protected String id;

@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
protected String type;

public abstract T sendLogs(RunContext runContext, Flux<LogRecord> logRecords) throws Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.atomic.AtomicReference;

import static io.kestra.core.utils.WindowsUtils.windowsToUnixPath;
import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

/**
* Base class for all task runners.
Expand All @@ -36,7 +37,7 @@
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public abstract class TaskRunner<T extends TaskRunnerDetailResult> implements Plugin, PluginVersioning, WorkerJobLifecycle {
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
protected String type;

@PluginProperty(hidden = true, group = PluginProperty.CORE_GROUP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

public interface TriggerInterface extends Plugin, PluginVersioning {
@NotNull
Expand All @@ -17,7 +18,7 @@ public interface TriggerInterface extends Plugin, PluginVersioning {

@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
@Schema(title = "The class name for this current trigger.")
String getType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@io.kestra.core.models.annotations.Plugin
@SuperBuilder(toBuilder = true)
@Getter
@NoArgsConstructor
public abstract class AdditionalPlugin implements Plugin {
@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
protected String type;
}
5 changes: 5 additions & 0 deletions core/src/main/java/io/kestra/core/utils/RegexPatterns.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.kestra.core.utils;

public class RegexPatterns {
public static final String JAVA_IDENTIFIER_REGEX = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import jakarta.validation.constraints.Pattern;
import lombok.Getter;

import static io.kestra.core.utils.RegexPatterns.JAVA_IDENTIFIER_REGEX;

@Getter
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
Expand All @@ -20,6 +22,6 @@
public class MarkdownSource {
@NotNull
@NotBlank
@Pattern(regexp = "^[A-Za-z_$][A-Za-z0-9_$]*(\\.[A-Za-z_$][A-Za-z0-9_$]*)*$")
@Pattern(regexp = JAVA_IDENTIFIER_REGEX)
private String type;
}
3 changes: 2 additions & 1 deletion webserver/openapi.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Keep the name static
micronaut.openapi.filename=kestra
micronaut.openapi.filename=kestra
micronaut.openapi.constructor-arguments-as-required=false
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@
import io.kestra.webserver.responses.PagedResults;
import io.kestra.webserver.services.ExecutionDependenciesStreamingService;
import io.kestra.webserver.services.ExecutionStreamingService;
import io.kestra.core.runners.SecureVariableRendererFactory;
import io.kestra.webserver.utils.PageableUtils;
import io.kestra.webserver.utils.RequestUtils;
import io.kestra.webserver.utils.filepreview.FileRender;
import io.kestra.webserver.utils.filepreview.FileRenderBuilder;
import io.micronaut.context.ApplicationContext;
import io.micronaut.context.annotation.Value;
import io.micronaut.context.event.ApplicationEventPublisher;
import io.micronaut.core.annotation.Introspected;
Expand Down Expand Up @@ -680,6 +678,7 @@ public Publisher<ApiValidateExecutionInputsResponse> validateNewExecutionInputs(
@Post(uri = "/{namespace}/{id}", consumes = MediaType.MULTIPART_FORM_DATA)
@Operation(tags = {"Executions"}, summary = "Create a new execution for a flow")
@ApiResponse(responseCode = "409", description = "if the flow is disabled")
@ApiResponse(responseCode = "200", description = "On execution created", content = {@Content(schema = @Schema(implementation = ExecutionResponse.class))})
@SingleResult
public Publisher<ExecutionResponse> createExecution(
@Parameter(description = "The flow namespace") @PathVariable String namespace,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package io.kestra.webserver.controllers.api;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.kestra.core.docs.JsonSchemaGenerator;
import io.kestra.core.exceptions.FlowProcessingException;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.exceptions.InternalException;
import io.kestra.core.models.QueryFilter;
import io.kestra.core.models.HasSource;
import io.kestra.core.models.QueryFilter;
import io.kestra.core.models.SearchResult;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.models.flows.FlowId;
import io.kestra.core.models.flows.FlowInterface;
import io.kestra.core.models.flows.FlowScope;
import io.kestra.core.models.flows.FlowWithException;
import io.kestra.core.models.flows.FlowWithSource;
import io.kestra.core.models.flows.GenericFlow;
import io.kestra.core.models.flows.*;
import io.kestra.core.models.hierarchies.FlowGraph;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.models.topologies.FlowTopology;
Expand All @@ -24,7 +17,6 @@
import io.kestra.core.models.validations.ModelValidator;
import io.kestra.core.models.validations.ValidateConstraintViolation;
import io.kestra.core.repositories.FlowRepositoryInterface;
import io.kestra.core.repositories.FlowTopologyRepositoryInterface;
import io.kestra.core.serializers.JacksonMapper;
import io.kestra.core.serializers.YamlParser;
import io.kestra.core.services.FlowService;
Expand Down Expand Up @@ -54,6 +46,7 @@
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand Down Expand Up @@ -445,6 +438,7 @@ protected List<FlowInterface> bulkUpdateOrCreate(@Nullable String namespace, Lis
@Put(uri = "{namespace}/{id}", consumes = MediaType.APPLICATION_YAML)
@ExecuteOn(TaskExecutors.IO)
@Operation(tags = {"Flows"}, summary = "Update a flow")
@ApiResponse(responseCode = "200", description = "On success", content = {@Content(schema = @Schema(implementation = FlowWithSource.class))})
public HttpResponse<FlowWithSource> updateFlow(
@Parameter(description = "The flow namespace") @PathVariable String namespace,
@Parameter(description = "The flow id") @PathVariable String id,
Expand Down
Loading