Skip to content

Commit 2dc7540

Browse files
chore: merge origin/development into main
2 parents 2a0e089 + 5e381d4 commit 2dc7540

5 files changed

Lines changed: 68 additions & 68 deletions

File tree

‎src/test/java/io/github/intisy/docker/unit/ImageAssemblerTest.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ private static Layer layer() {
3333

3434
private static ImageConfigOverrides overrides() {
3535
return new ImageConfigOverrides()
36-
.withEntrypoint(Arrays.asList("/opt/spisor/launcher/bin/launcher",
37-
"--registry=/var/lib/spisor/registry"))
36+
.withEntrypoint(Arrays.asList("/opt/app/launcher/bin/launcher",
37+
"--registry=/var/lib/app/registry"))
3838
.withCmd(null)
39-
.withWorkingDir("/var/lib/spisor");
39+
.withWorkingDir("/var/lib/app");
4040
}
4141

4242
private static ImageAssembler.Assembled assemble() throws IOException {
@@ -69,20 +69,20 @@ public void entrypointAndWorkingDirAreStampedAndCmdIsCleared() throws IOExceptio
6969
JsonObject config = GSON.fromJson(assemble().configJson(), JsonObject.class)
7070
.getAsJsonObject("config");
7171

72-
assertEquals("/opt/spisor/launcher/bin/launcher",
72+
assertEquals("/opt/app/launcher/bin/launcher",
7373
config.getAsJsonArray("Entrypoint").get(0).getAsString());
74-
assertEquals("--registry=/var/lib/spisor/registry",
74+
assertEquals("--registry=/var/lib/app/registry",
7575
config.getAsJsonArray("Entrypoint").get(1).getAsString());
76-
assertEquals("/var/lib/spisor", config.get("WorkingDir").getAsString());
76+
assertEquals("/var/lib/app", config.get("WorkingDir").getAsString());
7777
assertTrue(config.get("Cmd") == null || config.get("Cmd").isJsonNull(),
7878
"a base Cmd left in place would run jshell instead of the launcher");
7979
}
8080

8181
@Test
8282
public void notCallingWithCmdLeavesTheBaseCmdInPlace() throws IOException {
8383
ImageConfigOverrides overrides = new ImageConfigOverrides()
84-
.withEntrypoint(Arrays.asList("/opt/spisor/launcher/bin/launcher"))
85-
.withWorkingDir("/var/lib/spisor");
84+
.withEntrypoint(Arrays.asList("/opt/app/launcher/bin/launcher"))
85+
.withWorkingDir("/var/lib/app");
8686

8787
JsonObject config = GSON.fromJson(
8888
ImageAssembler.append(fixture("base-config.json"), fixture("base-manifest.json"),
@@ -183,7 +183,7 @@ public void aBaseConfigWithNoInnerConfigObjectGetsOneCreated() throws IOExceptio
183183
layer(), overrides()).configJson(),
184184
JsonObject.class).getAsJsonObject("config");
185185

186-
assertEquals("/opt/spisor/launcher/bin/launcher", config.getAsJsonArray("Entrypoint").get(0).getAsString());
186+
assertEquals("/opt/app/launcher/bin/launcher", config.getAsJsonArray("Entrypoint").get(0).getAsString());
187187
}
188188

189189
private static String fixture(String name) throws IOException {

‎src/test/java/io/github/intisy/docker/unit/ImagePublisherTest.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private RegistryClient source() {
6363

6464
private RegistryClient target(boolean baseLayerAlreadyPresent) {
6565
targetHttp = new FakeRegistryHttp();
66-
String root = "http://registry.spisor.internal/v2/spisor/core";
66+
String root = "http://registry.example.internal/v2/myorg/app";
6767
targetHttp.answer("HEAD " + root + "/blobs/" + BASE_LAYER_DIGEST, new RegistryResponse(
6868
baseLayerAlreadyPresent ? 200 : 404, new HashMap<String, String>(), new byte[0]));
6969
targetHttp.answer("HEAD " + root + "/blobs/" + NEW_LAYER_DIGEST,
@@ -78,7 +78,7 @@ private RegistryClient target(boolean baseLayerAlreadyPresent) {
7878
new RegistryResponse(201, new HashMap<String, String>(), new byte[0]));
7979
targetHttp.answerMissingHeadsAs404();
8080
targetHttp.acceptAnyBlobUpload();
81-
return new RegistryClient(targetHttp, "registry.spisor.internal", true);
81+
return new RegistryClient(targetHttp, "registry.example.internal", true);
8282
}
8383

8484
private static java.util.Map<String, String> location(String value) {
@@ -100,19 +100,19 @@ private Layer layer(Path tmp) throws IOException {
100100
}
101101

102102
private static ImageConfigOverrides overrides() {
103-
List<String> entrypoint = Arrays.asList("/opt/spisor/launcher/bin/launcher");
103+
List<String> entrypoint = Arrays.asList("/opt/app/launcher/bin/launcher");
104104
return new ImageConfigOverrides().withEntrypoint(entrypoint).withCmd(null);
105105
}
106106

107107
@Test
108108
public void publishesConfigLayerAndManifestAndReturnsTheManifestDigest(@TempDir Path tmp) throws IOException {
109109
String digest = ImagePublisher.publish(source(), ImageReference.parse("eclipse-temurin:21-jre"),
110-
target(false), ImageReference.parse("registry.spisor.internal/spisor/core:0.1.0"),
110+
target(false), ImageReference.parse("registry.example.internal/myorg/app:0.1.0"),
111111
layer(tmp), overrides());
112112

113113
assertTrue(digest.startsWith("sha256:"), digest);
114114
List<String> calls = targetHttp.calls();
115-
assertTrue(calls.contains("PUT http://registry.spisor.internal/v2/spisor/core/manifests/0.1.0"),
115+
assertTrue(calls.contains("PUT http://registry.example.internal/v2/myorg/app/manifests/0.1.0"),
116116
calls.toString());
117117
}
118118

@@ -124,11 +124,11 @@ public void publishesConfigLayerAndManifestAndReturnsTheManifestDigest(@TempDir
124124
@Test
125125
public void theManifestIsPushedLast(@TempDir Path tmp) throws IOException {
126126
ImagePublisher.publish(source(), ImageReference.parse("eclipse-temurin:21-jre"),
127-
target(false), ImageReference.parse("registry.spisor.internal/spisor/core:0.1.0"),
127+
target(false), ImageReference.parse("registry.example.internal/myorg/app:0.1.0"),
128128
layer(tmp), overrides());
129129

130130
List<String> calls = targetHttp.calls();
131-
assertEquals("PUT http://registry.spisor.internal/v2/spisor/core/manifests/0.1.0",
131+
assertEquals("PUT http://registry.example.internal/v2/myorg/app/manifests/0.1.0",
132132
calls.get(calls.size() - 1));
133133
}
134134

@@ -139,7 +139,7 @@ public void theManifestIsPushedLast(@TempDir Path tmp) throws IOException {
139139
@Test
140140
public void aBaseLayerAlreadyInTheTargetIsNotReUploaded(@TempDir Path tmp) throws IOException {
141141
ImagePublisher.publish(source(), ImageReference.parse("eclipse-temurin:21-jre"),
142-
target(true), ImageReference.parse("registry.spisor.internal/spisor/core:0.1.0"),
142+
target(true), ImageReference.parse("registry.example.internal/myorg/app:0.1.0"),
143143
layer(tmp), overrides());
144144

145145
assertFalse(sourceHttp.calls().contains("GET https://registry-1.docker.io/v2/library/eclipse-temurin/blobs/"
@@ -150,7 +150,7 @@ public void aBaseLayerAlreadyInTheTargetIsNotReUploaded(@TempDir Path tmp) throw
150150
@Test
151151
public void theIndexIsResolvedToTheAmd64ManifestBeforeAnythingIsRead(@TempDir Path tmp) throws IOException {
152152
ImagePublisher.publish(source(), ImageReference.parse("eclipse-temurin:21-jre"),
153-
target(false), ImageReference.parse("registry.spisor.internal/spisor/core:0.1.0"),
153+
target(false), ImageReference.parse("registry.example.internal/myorg/app:0.1.0"),
154154
layer(tmp), overrides());
155155

156156
assertEquals("GET https://registry-1.docker.io/v2/library/eclipse-temurin/manifests/21-jre",

‎src/test/java/io/github/intisy/docker/unit/ImageReferenceTest.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public void namespacedImageKeepsItsNamespaceAndGetsNoLibraryPrefix() {
3939

4040
@Test
4141
public void explicitRegistryIsRecognisedByItsDot() {
42-
ImageReference reference = ImageReference.parse("registry.spisor.internal/spisor/core:0.1.0");
43-
assertEquals("registry.spisor.internal", reference.registry());
44-
assertEquals("registry.spisor.internal", reference.host());
45-
assertEquals("spisor/core", reference.repository());
42+
ImageReference reference = ImageReference.parse("registry.example.internal/myorg/app:0.1.0");
43+
assertEquals("registry.example.internal", reference.registry());
44+
assertEquals("registry.example.internal", reference.host());
45+
assertEquals("myorg/app", reference.repository());
4646
assertEquals("0.1.0", reference.reference());
4747
}
4848

@@ -52,17 +52,17 @@ public void explicitRegistryIsRecognisedByItsDot() {
5252
*/
5353
@Test
5454
public void registryPortIsNotATag() {
55-
ImageReference reference = ImageReference.parse("localhost:5000/spisor/core:0.1.0");
55+
ImageReference reference = ImageReference.parse("localhost:5000/myorg/app:0.1.0");
5656
assertEquals("localhost:5000", reference.registry());
57-
assertEquals("spisor/core", reference.repository());
57+
assertEquals("myorg/app", reference.repository());
5858
assertEquals("0.1.0", reference.reference());
5959
}
6060

6161
@Test
6262
public void registryPortWithNoTagStillParses() {
63-
ImageReference reference = ImageReference.parse("localhost:5000/spisor/core");
63+
ImageReference reference = ImageReference.parse("localhost:5000/myorg/app");
6464
assertEquals("localhost:5000", reference.registry());
65-
assertEquals("spisor/core", reference.repository());
65+
assertEquals("myorg/app", reference.repository());
6666
assertEquals("latest", reference.reference());
6767
}
6868

@@ -78,15 +78,15 @@ public void digestReferenceIsRecognised() {
7878
@Test
7979
public void withRegistryRetargetsAndKeepsTheRest() {
8080
ImageReference retargeted = ImageReference.parse("eclipse-temurin:21-jre")
81-
.withRegistry("registry.spisor.internal");
82-
assertEquals("registry.spisor.internal", retargeted.registry());
81+
.withRegistry("registry.example.internal");
82+
assertEquals("registry.example.internal", retargeted.registry());
8383
assertEquals("library/eclipse-temurin", retargeted.repository());
8484
assertEquals("21-jre", retargeted.reference());
8585
}
8686

8787
@Test
8888
public void roundTripsThroughToString() {
89-
String text = "registry.spisor.internal/spisor/core:0.1.0";
89+
String text = "registry.example.internal/myorg/app:0.1.0";
9090
assertEquals(text, ImageReference.parse(text).toString());
9191
}
9292

‎src/test/java/io/github/intisy/docker/unit/LayerBuilderTest.java‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@ private static Path launcherLikeTree(Path root) throws IOException {
3939
@Test
4040
public void entriesAreRootedAtThePathInImage(@TempDir Path tmp) throws IOException {
4141
Layer layer = LayerBuilder.fromDirectory(
42-
launcherLikeTree(tmp), "/opt/spisor/launcher", tmp.resolve("layer.tar.gz"));
42+
launcherLikeTree(tmp), "/opt/app/launcher", tmp.resolve("layer.tar.gz"));
4343

4444
List<String> names = entryNames(layer.file());
45-
assertTrue(names.contains("opt/spisor/launcher/bin/launcher"), names.toString());
46-
assertTrue(names.contains("opt/spisor/launcher/lib/launcher.jar"), names.toString());
45+
assertTrue(names.contains("opt/app/launcher/bin/launcher"), names.toString());
46+
assertTrue(names.contains("opt/app/launcher/lib/launcher.jar"), names.toString());
4747
}
4848

4949
@Test
5050
public void filesUnderBinAreExecutableAndOthersAreNot(@TempDir Path tmp) throws IOException {
5151
Layer layer = LayerBuilder.fromDirectory(
52-
launcherLikeTree(tmp), "/opt/spisor/launcher", tmp.resolve("layer.tar.gz"));
52+
launcherLikeTree(tmp), "/opt/app/launcher", tmp.resolve("layer.tar.gz"));
5353

54-
assertEquals(0755, modeOf(layer.file(), "opt/spisor/launcher/bin/launcher"));
55-
assertEquals(0644, modeOf(layer.file(), "opt/spisor/launcher/lib/launcher.jar"));
54+
assertEquals(0755, modeOf(layer.file(), "opt/app/launcher/bin/launcher"));
55+
assertEquals(0644, modeOf(layer.file(), "opt/app/launcher/lib/launcher.jar"));
5656
}
5757

5858
@Test
5959
public void twoBuildsOfTheSameTreeProduceTheSameDigest(@TempDir Path tmp) throws IOException {
6060
Path source = launcherLikeTree(tmp);
61-
Layer first = LayerBuilder.fromDirectory(source, "/opt/spisor/launcher", tmp.resolve("a.tar.gz"));
62-
Layer second = LayerBuilder.fromDirectory(source, "/opt/spisor/launcher", tmp.resolve("b.tar.gz"));
61+
Layer first = LayerBuilder.fromDirectory(source, "/opt/app/launcher", tmp.resolve("a.tar.gz"));
62+
Layer second = LayerBuilder.fromDirectory(source, "/opt/app/launcher", tmp.resolve("b.tar.gz"));
6363

6464
assertEquals(first.diffId(), second.diffId());
6565
assertEquals(first.digest(), second.digest());
@@ -68,9 +68,9 @@ public void twoBuildsOfTheSameTreeProduceTheSameDigest(@TempDir Path tmp) throws
6868
@Test
6969
public void changingAFileChangesTheDigest(@TempDir Path tmp) throws IOException {
7070
Path source = launcherLikeTree(tmp);
71-
Layer before = LayerBuilder.fromDirectory(source, "/opt/spisor/launcher", tmp.resolve("a.tar.gz"));
71+
Layer before = LayerBuilder.fromDirectory(source, "/opt/app/launcher", tmp.resolve("a.tar.gz"));
7272
Files.write(source.resolve("lib/launcher.jar"), new byte[] {0x50, 0x4b, 0x03, 0x05});
73-
Layer after = LayerBuilder.fromDirectory(source, "/opt/spisor/launcher", tmp.resolve("b.tar.gz"));
73+
Layer after = LayerBuilder.fromDirectory(source, "/opt/app/launcher", tmp.resolve("b.tar.gz"));
7474

7575
assertNotEquals(before.diffId(), after.diffId());
7676
}
@@ -83,7 +83,7 @@ public void changingAFileChangesTheDigest(@TempDir Path tmp) throws IOException
8383
@Test
8484
public void diffIdIsTheUncompressedDigestAndDigestIsTheCompressedOne(@TempDir Path tmp) throws IOException {
8585
Layer layer = LayerBuilder.fromDirectory(
86-
launcherLikeTree(tmp), "/opt/spisor/launcher", tmp.resolve("layer.tar.gz"));
86+
launcherLikeTree(tmp), "/opt/app/launcher", tmp.resolve("layer.tar.gz"));
8787

8888
assertNotEquals(layer.diffId(), layer.digest());
8989
assertEquals(layer.digest(), sha256Closing(new FileInputStream(layer.file().toFile())));
@@ -101,7 +101,7 @@ public void diffIdIsTheUncompressedDigestAndDigestIsTheCompressedOne(@TempDir Pa
101101
@Test
102102
public void everyEntryHasItsVaryingMetadataPinned(@TempDir Path tmp) throws IOException {
103103
Layer layer = LayerBuilder.fromDirectory(
104-
launcherLikeTree(tmp), "/opt/spisor/launcher", tmp.resolve("layer.tar.gz"));
104+
launcherLikeTree(tmp), "/opt/app/launcher", tmp.resolve("layer.tar.gz"));
105105

106106
TarArchiveInputStream tar = openTar(layer.file());
107107
try {
@@ -135,11 +135,11 @@ public void entriesAreOrderedByTheArchiveNameNotThePlatformPathOrdering(@TempDir
135135
Files.write(dist.resolve("Zeta.txt"), new byte[] {1});
136136
Files.write(dist.resolve("apple.txt"), new byte[] {1});
137137

138-
Layer layer = LayerBuilder.fromDirectory(dist, "/opt/spisor/launcher", tmp.resolve("layer.tar.gz"));
138+
Layer layer = LayerBuilder.fromDirectory(dist, "/opt/app/launcher", tmp.resolve("layer.tar.gz"));
139139

140140
List<String> names = entryNames(layer.file());
141-
int zeta = names.indexOf("opt/spisor/launcher/Zeta.txt");
142-
int apple = names.indexOf("opt/spisor/launcher/apple.txt");
141+
int zeta = names.indexOf("opt/app/launcher/Zeta.txt");
142+
int apple = names.indexOf("opt/app/launcher/apple.txt");
143143
assertTrue(zeta >= 0 && apple >= 0, names.toString());
144144
assertEquals("Zeta.txt".compareTo("apple.txt") < 0, zeta < apple, names.toString());
145145
}

0 commit comments

Comments
 (0)