-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(script): move plugin-script library to Kestra itself
- Loading branch information
1 parent
a35dc85
commit e65e0a0
Showing
22 changed files
with
1,488 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
dependencies { | ||
// Kestra | ||
implementation project(':core') | ||
annotationProcessor project(':processor') | ||
|
||
implementation platform("io.micronaut.platform:micronaut-platform:$micronautVersion") | ||
implementation 'io.micronaut:micronaut-context' | ||
|
||
implementation ('com.github.docker-java:docker-java:3.3.6') { | ||
exclude group: 'com.github.docker-java', module: 'docker-java-transport-jersey' | ||
} | ||
implementation 'com.github.docker-java:docker-java-transport-zerodep:3.3.6' | ||
|
||
testImplementation project(':core').sourceSets.test.output | ||
testImplementation project(':storage-local') | ||
testImplementation project(':repository-memory') | ||
testImplementation project(':runner-memory') | ||
} |
125 changes: 125 additions & 0 deletions
125
script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/DockerOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package io.kestra.plugin.scripts.exec.scripts.models; | ||
|
||
import io.kestra.core.models.annotations.PluginProperty; | ||
import io.kestra.plugin.scripts.runner.docker.*; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
@SuperBuilder(toBuilder = true) | ||
@NoArgsConstructor | ||
@Getter | ||
public class DockerOptions { | ||
@Schema( | ||
title = "Docker API URI." | ||
) | ||
@PluginProperty(dynamic = true) | ||
private String host; | ||
|
||
@Schema( | ||
title = "Docker configuration file.", | ||
description = "Docker configuration file that can set access credentials to private container registries. Usually located in `~/.docker/config.json`.", | ||
anyOf = {String.class, Map.class} | ||
) | ||
@PluginProperty(dynamic = true) | ||
private Object config; | ||
|
||
@Schema( | ||
title = "Credentials for a private container registry." | ||
) | ||
@PluginProperty(dynamic = true) | ||
private Credentials credentials; | ||
|
||
@Schema( | ||
title = "Docker image to use." | ||
) | ||
@PluginProperty(dynamic = true) | ||
@NotNull | ||
@NotEmpty | ||
protected String image; | ||
|
||
@Schema( | ||
title = "User in the Docker container." | ||
) | ||
@PluginProperty(dynamic = true) | ||
protected String user; | ||
|
||
@Schema( | ||
title = "Docker entrypoint to use." | ||
) | ||
@PluginProperty(dynamic = true) | ||
protected List<String> entryPoint; | ||
|
||
@Schema( | ||
title = "Extra hostname mappings to the container network interface configuration." | ||
) | ||
@PluginProperty(dynamic = true) | ||
protected List<String> extraHosts; | ||
|
||
@Schema( | ||
title = "Docker network mode to use e.g. `host`, `none`, etc." | ||
) | ||
@PluginProperty(dynamic = true) | ||
protected String networkMode; | ||
|
||
@Schema( | ||
title = "List of volumes to mount.", | ||
description = "Must be a valid mount expression as string, example : `/home/user:/app`.\n\n" + | ||
"Volumes mount are disabled by default for security reasons; you must enable them on server configuration by setting `kestra.tasks.scripts.docker.volume-enabled` to `true`." | ||
) | ||
@PluginProperty(dynamic = true) | ||
protected List<String> volumes; | ||
|
||
@PluginProperty | ||
@Builder.Default | ||
protected PullPolicy pullPolicy = PullPolicy.ALWAYS; | ||
|
||
@Schema( | ||
title = "A list of device requests to be sent to device drivers." | ||
) | ||
@PluginProperty | ||
protected List<DeviceRequest> deviceRequests; | ||
|
||
@Schema( | ||
title = "Limits the CPU usage to a given maximum threshold value.", | ||
description = "By default, each container’s access to the host machine’s CPU cycles is unlimited. " + | ||
"You can set various constraints to limit a given container’s access to the host machine’s CPU cycles." | ||
) | ||
@PluginProperty | ||
protected Cpu cpu; | ||
|
||
@Schema( | ||
title = "Limits memory usage to a given maximum threshold value.", | ||
description = "Docker can enforce hard memory limits, which allow the container to use no more than a " + | ||
"given amount of user or system memory, or soft limits, which allow the container to use as much " + | ||
"memory as it needs unless certain conditions are met, such as when the kernel detects low memory " + | ||
"or contention on the host machine. Some of these options have different effects when used alone or " + | ||
"when more than one option is set." | ||
) | ||
@PluginProperty | ||
protected Memory memory; | ||
|
||
@Schema( | ||
title = "Size of `/dev/shm` in bytes.", | ||
description = "The size must be greater than 0. If omitted, the system uses 64MB." | ||
) | ||
@PluginProperty(dynamic = true) | ||
private String shmSize; | ||
|
||
@Deprecated | ||
public void setDockerHost(String host) { | ||
this.host = host; | ||
} | ||
|
||
@Deprecated | ||
public void setDockerConfig(String config) { | ||
this.config = config; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/RunnerType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.kestra.plugin.scripts.exec.scripts.models; | ||
|
||
public enum RunnerType { | ||
PROCESS, | ||
DOCKER | ||
} |
49 changes: 49 additions & 0 deletions
49
script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/ScriptOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.kestra.plugin.scripts.exec.scripts.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import io.kestra.core.models.annotations.PluginProperty; | ||
import io.kestra.core.models.flows.State; | ||
import io.kestra.core.models.tasks.Output; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.net.URI; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
@Builder | ||
@Getter | ||
public class ScriptOutput implements Output { | ||
@Schema( | ||
title = "The value extracted from the output of the executed `commands`." | ||
) | ||
private final Map<String, Object> vars; | ||
|
||
@Schema( | ||
title = "The exit code of the entire flow execution." | ||
) | ||
@NotNull | ||
private final int exitCode; | ||
|
||
@Schema( | ||
title = "The output files' URIs in Kestra's internal storage." | ||
) | ||
@PluginProperty(additionalProperties = URI.class) | ||
private final Map<String, URI> outputFiles; | ||
|
||
@JsonIgnore | ||
private final int stdOutLineCount; | ||
|
||
@JsonIgnore | ||
private final int stdErrLineCount; | ||
|
||
@JsonIgnore | ||
private Boolean warningOnStdErr; | ||
|
||
@Override | ||
public Optional<State.Type> finalState() { | ||
return this.warningOnStdErr != null && this.warningOnStdErr && this.stdErrLineCount > 0 ? Optional.of(State.Type.WARNING) : Output.super.finalState(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
script/src/main/java/io/kestra/plugin/scripts/exec/scripts/models/ScriptOutputFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.kestra.plugin.scripts.exec.scripts.models; | ||
|
||
import io.kestra.core.models.executions.AbstractMetricEntry; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@NoArgsConstructor | ||
@Data | ||
public class ScriptOutputFormat<T> { | ||
private Map<String, Object> outputs; | ||
private List<AbstractMetricEntry<T>> metrics; | ||
} |
8 changes: 8 additions & 0 deletions
8
script/src/main/java/io/kestra/plugin/scripts/exec/scripts/runners/AbstractLogConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.kestra.plugin.scripts.exec.scripts.runners; | ||
|
||
/** | ||
* @deprecated use {@link io.kestra.core.models.tasks.runners.AbstractLogConsumer} instead. | ||
*/ | ||
@Deprecated | ||
public abstract class AbstractLogConsumer extends io.kestra.core.models.tasks.runners.AbstractLogConsumer { | ||
} |
Oops, something went wrong.