Skip to content

Commit

Permalink
fix(core): change version property to pluginVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois committed Mar 3, 2025
1 parent fa07cbd commit e36160e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 18 deletions.
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 @@ -198,7 +198,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\", \"retry\", \"allowWarning\", \"format\", \"pluginVersion\", \"type\", \"id\", \"description\", \"workerGroup\", \"runIf\", \"logToFile\", \"disabled\", \"allowFailure\"])"));

Check failure on line 201 in core/src/test/java/io/kestra/core/serializers/YamlParserTest.java

View workflow job for this annotation

GitHub Actions / Java Tests Report

io.kestra.core.serializers.YamlParserTest ► invalidProperty()

Failed test found in: core/build/test-results/test/TEST-io.kestra.core.serializers.YamlParserTest.xml Error: java.lang.AssertionError:
Raw output
java.lang.AssertionError: 
Expected: is "Unrecognized field \"invalid\" (class io.kestra.plugin.core.debug.Return), not marked as ignorable (14 known properties: \"logLevel\", \"timeout\", \"retry\", \"allowWarning\", \"format\", \"pluginVersion\", \"type\", \"id\", \"description\", \"workerGroup\", \"runIf\", \"logToFile\", \"disabled\", \"allowFailure\"])"
     but: was "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\"])"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at io.kestra.core.serializers.YamlParserTest.invalidProperty(YamlParserTest.java:201)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension$2.proceed(MicronautJunit5Extension.java:142)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptEach(AbstractMicronautExtension.java:162)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptTest(AbstractMicronautExtension.java:119)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension.interceptTestMethod(MicronautJunit5Extension.java:129)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
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

0 comments on commit e36160e

Please sign in to comment.