|
| 1 | +package dev.openfeature.contrib.providers.flagd.e2e; |
| 2 | + |
| 3 | +import org.jetbrains.annotations.NotNull; |
| 4 | +import org.testcontainers.containers.GenericContainer; |
| 5 | +import org.testcontainers.utility.DockerImageName; |
| 6 | + |
| 7 | +import java.io.IOException; |
| 8 | +import java.util.Properties; |
| 9 | + |
| 10 | +public class ContainerConfig { |
| 11 | + private static final String version; |
| 12 | + static { |
| 13 | + Properties properties = new Properties(); |
| 14 | + try { |
| 15 | + properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("flagdTestbed.properties")); |
| 16 | + version = properties.getProperty("version"); |
| 17 | + } catch (IOException e) { |
| 18 | + throw new RuntimeException(e); |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | + public static GenericContainer sync() { |
| 23 | + return sync(false); |
| 24 | + } |
| 25 | + public static GenericContainer sync(boolean unstable) { |
| 26 | + String container = generateContainerName("sync", unstable); |
| 27 | + return new GenericContainer(DockerImageName.parse(container)) |
| 28 | + .withExposedPorts(9090); |
| 29 | + } |
| 30 | + public static GenericContainer flagd() { |
| 31 | + return flagd(false); |
| 32 | + } |
| 33 | + public static GenericContainer flagd(boolean unstable) { |
| 34 | + String container = generateContainerName("flagd", unstable); |
| 35 | + return new GenericContainer(DockerImageName.parse(container)) |
| 36 | + .withExposedPorts(8013); |
| 37 | + } |
| 38 | + |
| 39 | + private static @NotNull String generateContainerName(String type, boolean unstable) { |
| 40 | + String container = "ghcr.io/open-feature/"; |
| 41 | + container += type; |
| 42 | + container += "-testbed"; |
| 43 | + if (unstable) { |
| 44 | + container += "-unstable"; |
| 45 | + } |
| 46 | + container += ":" + version; |
| 47 | + return container; |
| 48 | + } |
| 49 | +} |
0 commit comments