Skip to content

Commit

Permalink
feat(core): add a pullImage for docker bash runner
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Aug 19, 2022
1 parent 8fd23ed commit 64e9001
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,5 +374,13 @@ public static class DockerOptions {
)
@PluginProperty(dynamic = true)
protected List<String> volumes;

@Schema(
title = "Is a pull of image must be done before starting the container",
description = "Mostly used for local image with registry"
)
@PluginProperty(dynamic = false)
@Builder.Default
protected Boolean pullImage = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,27 @@ public RunResult run(
.withAttachStdout(true);

// pull image
retryUtils.<Boolean, InternalServerErrorException>of(
Exponential.builder()
.delayFactor(2.0)
.interval(Duration.ofSeconds(5))
.maxInterval(Duration.ofSeconds(120))
.maxAttempt(5)
.build()
).run(
(bool, throwable) -> throwable instanceof InternalServerErrorException ||
throwable.getCause() instanceof ConnectionClosedException,
() -> {
pull
.withTag(!imageParse.tag.equals("") ? imageParse.tag : "latest")
.exec(new PullImageResultCallback())
.awaitCompletion();
logger.debug("Image pulled [{}:{}]", pull.getRepository(), pull.getTag());
return true;
}
);
if (abstractBash.getDockerOptions().getPullImage()) {
retryUtils.<Boolean, InternalServerErrorException>of(
Exponential.builder()
.delayFactor(2.0)
.interval(Duration.ofSeconds(5))
.maxInterval(Duration.ofSeconds(120))
.maxAttempt(5)
.build()
).run(
(bool, throwable) -> throwable instanceof InternalServerErrorException ||
throwable.getCause() instanceof ConnectionClosedException,
() -> {
pull
.withTag(!imageParse.tag.equals("") ? imageParse.tag : "latest")
.exec(new PullImageResultCallback())
.awaitCompletion();
logger.debug("Image pulled [{}:{}]", pull.getRepository(), pull.getTag());
return true;
}
);
}

// start container
CreateContainerResponse exec = container.exec();
Expand Down

0 comments on commit 64e9001

Please sign in to comment.