Skip to content

Commit 2448354

Browse files
author
Fabiano Oliveira
authored
Merge pull request #5 from galhardi/feature/localstack-version
Receive localstack version as param
2 parents 34fd80e + f14cedd commit 2448354

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/main/java/xyz/fabiano/spring/localstack/LocalstackDockerBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class LocalstackDockerBuilder {
2828

2929
private boolean cborEnable = false;
3030

31+
private String version = "latest";
32+
3133
private Collection<String> options = new ArrayList<>();
3234

3335
private String region = "us-east-1";
@@ -46,6 +48,7 @@ public LocalstackDocker build() {
4648

4749
docker.setEnvironmentVariables(environmentVariables);
4850
docker.setOptions(options);
51+
docker.setVersion(version);
4952
docker.setRegion(region);
5053
return docker;
5154
}
@@ -129,6 +132,11 @@ public LocalstackDockerBuilder withOptions(Collection<String> options) {
129132
return this;
130133
}
131134

135+
public LocalstackDockerBuilder withVersion(String version) {
136+
this.version = version;
137+
return this;
138+
}
139+
132140
public LocalstackDockerBuilder withRegion(String region) {
133141
this.region = region;
134142
return this;

src/main/java/xyz/fabiano/spring/localstack/autoconfigure/LocalstackAutoConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class LocalstackAutoConfiguration {
3434
private final String services;
3535
private final boolean autoRemove;
3636
private final String extraOptions;
37+
private final String version;
3738
private final String region;
3839

3940
public LocalstackAutoConfiguration(
@@ -44,6 +45,7 @@ public LocalstackAutoConfiguration(
4445
@Value("${spring.localstack.services:}") String services,
4546
@Value("${spring.localstack.auto-remove:true}") boolean autoRemove,
4647
@Value("${spring.localstack.extra-options:}") String extraOptions,
48+
@Value("${spring.localstack.version:latest}") String version) {
4749
@Value("${spring.localstack.region:us-east-1}") String region) {
4850
this.asyncClientsEnabled = asyncClientsEnabled;
4951
this.pullNewImage = pullNewImage;
@@ -52,6 +54,7 @@ public LocalstackAutoConfiguration(
5254
this.services = services;
5355
this.autoRemove = autoRemove;
5456
this.extraOptions = extraOptions;
57+
this.version = version;
5558
this.region = region;
5659
}
5760

@@ -64,6 +67,7 @@ public LocalstackDocker localstackDocker() {
6467
.disableCBOR()
6568
.withServices(services())
6669
.withOptions(options())
70+
.withVersion(version)
6771
.withRegion(region)
6872
.build();
6973

src/main/java/xyz/fabiano/spring/localstack/legacy/Container.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ public static Container createLocalstackContainer(String externalHostName,
5050
boolean randomizePorts,
5151
Map<String, String> environmentVariables,
5252
Collection<String> options,
53+
String version,
5354
String region) {
54-
55+
String imageName = LOCALSTACK_NAME + ":" + version;
56+
5557
if(pullNewImage) {
5658
LOG.info("Pulling latest image...");
57-
new PullCommand(LOCALSTACK_NAME).execute();
59+
new PullCommand(imageName).execute();
5860
}
5961

60-
String containerId = new RunCommand(LOCALSTACK_NAME)
62+
String containerId = new RunCommand(imageName)
6163
.withOptions(options)
6264
.withExposedPorts(LOCALSTACK_PORTS, randomizePorts)
6365
.withEnvironmentVariable(LOCALSTACK_EXTERNAL_HOSTNAME, externalHostName)

src/main/java/xyz/fabiano/spring/localstack/legacy/LocalstackDocker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class LocalstackDocker {
5656
@Setter
5757
private Collection<String> options = new ArrayList<>();
5858
@Setter
59+
private String version = "latest";
5960
@Getter
6061
private String region = "us-east-1";
6162

@@ -78,6 +79,7 @@ public void startup() {
7879
randomizePorts,
7980
environmentVariables,
8081
options,
82+
version,
8183
region);
8284
loadServiceToPortMap();
8385

0 commit comments

Comments
 (0)