feat(system): use Property.ofValue(T) instead of Property.of(T)

This commit is contained in:
Loïc Mathieu
2025-05-20 10:38:23 +02:00
parent 05d296df34
commit 0fd8461249
114 changed files with 453 additions and 476 deletions

View File

@@ -51,7 +51,7 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
@Valid
protected TaskRunner<?> taskRunner = Docker.builder()
.type(Docker.class.getName())
.pullPolicy(Property.of(PullPolicy.IF_NOT_PRESENT))
.pullPolicy(Property.ofValue(PullPolicy.IF_NOT_PRESENT))
.build();
@Schema(
@@ -76,7 +76,7 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
)
@PluginProperty(dynamic = true)
@NotNull
protected Property<List<String>> interpreter = Property.of(List.of("/bin/sh", "-c"));
protected Property<List<String>> interpreter = Property.ofValue(List.of("/bin/sh", "-c"));
@Builder.Default
@Schema(
@@ -84,7 +84,7 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
description = "If set to `false` all commands will be executed one after the other. The final state of task execution is determined by the last command. Note that this property maybe be ignored if a non compatible interpreter is specified." +
"\nYou can also disable it if your interpreter does not support the `set -e`option."
)
protected Property<Boolean> failFast = Property.of(true);
protected Property<Boolean> failFast = Property.ofValue(true);
private NamespaceFiles namespaceFiles;
@@ -106,7 +106,7 @@ public abstract class AbstractExecScript extends Task implements RunnableTask<Sc
)
@Builder.Default
@NotNull
protected Property<TargetOS> targetOS = Property.of(TargetOS.AUTO);
protected Property<TargetOS> targetOS = Property.ofValue(TargetOS.AUTO);
@Schema(
title = "Deprecated - use the 'taskRunner' property instead.",

View File

@@ -79,7 +79,7 @@ public class DockerOptions {
protected List<String> volumes;
@Builder.Default
protected Property<PullPolicy> pullPolicy = Property.of(PullPolicy.IF_NOT_PRESENT);
protected Property<PullPolicy> pullPolicy = Property.ofValue(PullPolicy.IF_NOT_PRESENT);
@Schema(
title = "A list of device requests to be sent to device drivers."

View File

@@ -175,7 +175,7 @@ public class CommandsWrapper implements TaskCommands {
Optional.ofNullable(targetOS).orElse(TargetOS.AUTO)
);
this.commands = Property.of(finalCommands);
this.commands = Property.ofValue(finalCommands);
ScriptOutput.ScriptOutputBuilder scriptOutputBuilder = ScriptOutput.builder();

View File

@@ -241,7 +241,7 @@ public class Docker extends TaskRunner<Docker.DockerTaskRunnerDetailResult> {
even if an image with the same tag already exists."""
)
@Builder.Default
protected Property<PullPolicy> pullPolicy = Property.of(PullPolicy.IF_NOT_PRESENT);
protected Property<PullPolicy> pullPolicy = Property.ofValue(PullPolicy.IF_NOT_PRESENT);
@Schema(
title = "A list of device requests to be sent to device drivers."
@@ -289,21 +289,21 @@ public class Docker extends TaskRunner<Docker.DockerTaskRunnerDetailResult> {
)
@NotNull
@Builder.Default
private Property<FileHandlingStrategy> fileHandlingStrategy = Property.of(FileHandlingStrategy.VOLUME);
private Property<FileHandlingStrategy> fileHandlingStrategy = Property.ofValue(FileHandlingStrategy.VOLUME);
@Schema(
title = "Whether the container should be deleted upon completion."
)
@NotNull
@Builder.Default
private Property<Boolean> delete = Property.of(true);
private Property<Boolean> delete = Property.ofValue(true);
@Builder.Default
@Schema(
title = "Whether to wait for the container to exit."
)
@NotNull
private Property<Boolean> wait = Property.of(true);
private Property<Boolean> wait = Property.ofValue(true);
@Builder.Default
@NotNull

View File

@@ -9,7 +9,6 @@ import io.kestra.core.models.tasks.Task;
import io.kestra.core.queues.QueueFactoryInterface;
import io.kestra.core.queues.QueueInterface;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.core.utils.Await;
import io.kestra.core.utils.TestsUtils;
import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions;
@@ -54,7 +53,7 @@ class LogConsumerTest {
RunContext runContext = TestsUtils.mockRunContext(runContextFactory, TASK, ImmutableMap.of());
String outputValue = "a".repeat(10000);
TaskCommands taskCommands = new CommandsWrapper(runContext)
.withCommands(Property.of(List.of(
.withCommands(Property.ofValue(List.of(
"/bin/sh", "-c",
"echo \"::{\\\"outputs\\\":{\\\"someOutput\\\":\\\"" + outputValue + "\\\"}}::\"\n" +
"echo -n another line"
@@ -81,7 +80,7 @@ class LogConsumerTest {
.append(Integer.toString(i).repeat(800)).append("\r")
.append(Integer.toString(i).repeat(2000)).append("\r");
}
TaskCommands taskCommands = new CommandsWrapper(runContext).withCommands(Property.of(List.of(
TaskCommands taskCommands = new CommandsWrapper(runContext).withCommands(Property.ofValue(List.of(
"/bin/sh", "-c",
"echo " + outputValue +
"echo -n another line"
@@ -102,7 +101,7 @@ class LogConsumerTest {
Flux<LogEntry> receive = TestsUtils.receive(logQueue, l -> logs.add(l.getLeft()));
RunContext runContext = TestsUtils.mockRunContext(runContextFactory, TASK, ImmutableMap.of());
TaskCommands taskCommands = new CommandsWrapper(runContext).withCommands(Property.of(List.of(
TaskCommands taskCommands = new CommandsWrapper(runContext).withCommands(Property.ofValue(List.of(
"/bin/sh", "-c",
"""
echo '::{"logs": [{"level":"INFO","message":"Hello World"}]}::'