Skip to content

Commit

Permalink
feat(core): add namespaceFiles props
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Nov 14, 2023
1 parent 89c3aa1 commit 10af6d9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/java/io/kestra/plugin/docker/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import io.kestra.core.models.annotations.Plugin;
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.models.executions.metrics.Counter;
import io.kestra.core.models.tasks.NamespaceFiles;
import io.kestra.core.models.tasks.NamespaceFilesInterface;
import io.kestra.core.models.tasks.RunnableTask;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.runners.NamespaceFilesService;
import io.kestra.core.runners.RunContext;
import io.kestra.plugin.scripts.exec.scripts.models.DockerOptions;
import io.kestra.plugin.scripts.exec.scripts.runners.DockerService;
Expand Down Expand Up @@ -60,7 +63,7 @@
),
}
)
public class Build extends Task implements RunnableTask<Build.Output> {
public class Build extends Task implements RunnableTask<Build.Output>, NamespaceFilesInterface {
@Schema(
title = "The URI of your Docker host e.g. localhost"
)
Expand Down Expand Up @@ -124,6 +127,9 @@ public class Build extends Task implements RunnableTask<Build.Output> {
)
protected Map<String, String> labels;


private NamespaceFiles namespaceFiles;

@Override
public Output run(RunContext runContext) throws Exception {
DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder()
Expand All @@ -141,6 +147,20 @@ public Output run(RunContext runContext) throws Exception {
builder.withDockerConfig(config.toFile().getAbsolutePath());
}

if (this.namespaceFiles != null ) {
String tenantId = ((Map<String, String>) runContext.getVariables().get("flow")).get("tenantId");
String namespace = ((Map<String, String>) runContext.getVariables().get("flow")).get("namespace");

NamespaceFilesService namespaceFilesService = runContext.getApplicationContext().getBean(NamespaceFilesService.class);
namespaceFilesService.inject(
runContext,
tenantId,
namespace,
runContext.tempDir(),
this.namespaceFiles
);
}

try (DockerClient dockerClient = DockerService.client(builder.build())) {
BuildImageCmd buildImageCmd = dockerClient.buildImageCmd()
.withPull(this.pull);
Expand Down

0 comments on commit 10af6d9

Please sign in to comment.