Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): change version property to pluginVersion #7651

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
16 changes: 16 additions & 0 deletions core/src/main/java/io/kestra/core/models/PluginVersioning.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.kestra.core.models;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;

/**
* Interface that can be implemented by classes supporting plugin versioning.
*
* @see io.kestra.core.docs.Plugin
*/
public interface PluginVersioning {

@Pattern(regexp="\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9]+)|([a-zA-Z0-9]+)")
@Schema(title = "The version of the plugin to use.")
String getPluginVersion();
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public String getType() {
}

@Override
public String getVersion() {
return ((TaskInterface) subflowTask).getVersion();
public String getPluginVersion() {
return ((TaskInterface) subflowTask).getPluginVersion();
}
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/io/kestra/core/models/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract public class Task implements TaskInterface {

protected String type;

protected String version;
protected String pluginVersion;

private String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TaskForExecution implements TaskInterface {

protected String type;

protected String version;
protected String pluginVersion;

protected List<TaskForExecution> tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import io.kestra.core.models.Plugin;
import io.kestra.core.models.PluginVersioning;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public interface TaskInterface extends Plugin {
public interface TaskInterface extends Plugin, PluginVersioning {
@NotNull
@NotBlank
@Pattern(regexp="^[a-zA-Z0-9][a-zA-Z0-9_-]*")
Expand All @@ -19,8 +20,4 @@ public interface TaskInterface extends Plugin {
@Pattern(regexp="\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*(\\.\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)*")
@Schema(title = "The class name of this task.")
String getType();

@Pattern(regexp="\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9]+)?|([a-zA-Z0-9]+)")
@Schema(title = "The class version of this task.")
String getVersion();
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract public class AbstractTrigger implements TriggerInterface {

protected String type;

protected String version;
protected String pluginVersion;

private String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AbstractTriggerForExecution implements TriggerInterface {

protected String type;

protected String version;
protected String pluginVersion;

public static AbstractTriggerForExecution of(AbstractTrigger abstractTrigger) {
return AbstractTriggerForExecution.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.kestra.core.models.triggers;

import io.kestra.core.models.Plugin;
import io.kestra.core.models.PluginVersioning;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;


public interface TriggerInterface extends Plugin {
public interface TriggerInterface extends Plugin, PluginVersioning {
@NotNull
@NotBlank
@Pattern(regexp="^[a-zA-Z0-9][a-zA-Z0-9_-]*")
Expand All @@ -20,8 +21,4 @@ public interface TriggerInterface extends Plugin {
@Schema(title = "The class name for this current trigger.")
String getType();

@Pattern(regexp="\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9]+)|([a-zA-Z0-9]+)")
@Schema(title = "The class version for this trigger.")
String getVersion();

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class PluginDeserializer<T extends Plugin> extends JsonDeserializer
private static final Logger log = LoggerFactory.getLogger(PluginDeserializer.class);

private static final String TYPE = "type";
private static final String VERSION = "version";
private static final String VERSION = "pluginVersion";

private volatile PluginRegistry pluginRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -198,7 +197,7 @@ void invalidProperty() {
() -> this.parse("flows/invalids/invalid-property.yaml")
);

assertThat(exception.getMessage(), is("Unrecognized field \"invalid\" (class io.kestra.plugin.core.debug.Return), not marked as ignorable (14 known properties: \"logLevel\", \"timeout\", \"retry\", \"allowWarning\", \"format\", \"version\", \"type\", \"id\", \"description\", \"workerGroup\", \"runIf\", \"logToFile\", \"disabled\", \"allowFailure\"])"));
assertThat(exception.getMessage(), is("Unrecognized field \"invalid\" (class io.kestra.plugin.core.debug.Return), not marked as ignorable (14 known properties: \"logLevel\", \"timeout\", \"pluginVersion\", \"retry\", \"allowWarning\", \"format\", \"type\", \"id\", \"description\", \"workerGroup\", \"runIf\", \"logToFile\", \"disabled\", \"allowFailure\"])"));
assertThat(exception.getConstraintViolations().size(), is(1));
assertThat(exception.getConstraintViolations().iterator().next().getPropertyPath().toString(), is("io.kestra.core.models.flows.Flow[\"tasks\"]->java.util.ArrayList[0]->io.kestra.plugin.core.debug.Return[\"invalid\"]"));
}
Expand Down
Loading