-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate/use pull secrets when possible
- Loading branch information
Showing
16 changed files
with
209 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...s/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/BaseWithRemoteRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.api.model.KubernetesList; | ||
import io.fabric8.kubernetes.api.model.KubernetesListBuilder; | ||
import io.fabric8.kubernetes.api.model.LocalObjectReference; | ||
import io.fabric8.kubernetes.api.model.PodSpecFluent; | ||
import io.fabric8.kubernetes.api.model.Secret; | ||
|
||
public class BaseWithRemoteRegistry { | ||
|
||
public void assertGeneratedResources(String name, String target, Path buildDir) throws IOException { | ||
List<HasMetadata> resourceList = getResources(target, buildDir); | ||
assertGeneratedResources(name, resourceList); | ||
} | ||
|
||
List<HasMetadata> getResources(String target, Path buildDir) throws IOException { | ||
Path kubernetesDir = buildDir.resolve("kubernetes"); | ||
|
||
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith(target + ".json")) | ||
.isDirectoryContaining(p -> p.getFileName().endsWith(target + ".yml")); | ||
return DeserializationUtil.deserializeAsList(kubernetesDir.resolve(target + ".yml")); | ||
} | ||
|
||
public void assertGeneratedResources(String name, List<HasMetadata> resourceList) { | ||
assertThat(resourceList).satisfies(r -> { | ||
KubernetesList kubernetesList = new KubernetesListBuilder() | ||
.addAllToItems(resourceList) | ||
.accept(PodSpecFluent.class, spec -> { | ||
assertThat(spec.buildImagePullSecrets()).singleElement().satisfies(e -> { | ||
assertThat(e).isInstanceOfSatisfying(LocalObjectReference.class, l -> { | ||
assertThat(l.getName()).isEqualTo(name + "-pull-secret"); | ||
}); | ||
}); | ||
|
||
}).build(); | ||
}); | ||
|
||
assertThat(resourceList) | ||
.filteredOn( | ||
h -> "Secret".equals(h.getKind()) && h.getMetadata().getName().equals(name + "-pull-secret")) | ||
.singleElement().satisfies(h -> { | ||
assertThat(h).isInstanceOfSatisfying(Secret.class, s -> { | ||
assertThat(s.getType()).isEqualTo("kubernetes.io/dockerconfigjson"); | ||
assertThat(s.getData()).containsKey(".dockerconfigjson"); | ||
}); | ||
}); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...rkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithImagePushTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkus.it.kubernetes; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.builder.Version; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class KubernetesWithImagePushTest extends BaseWithRemoteRegistry { | ||
|
||
private static final String APP_NAME = "kubernetes-with-remote-image-push"; | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) | ||
.setApplicationName(APP_NAME) | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.overrideConfigKey("quarkus.container-image.group", "user") | ||
.overrideConfigKey("quarkus.container-image.image", "quay.io/user/" + APP_NAME + ":1.0") | ||
.overrideConfigKey("quarkus.container-image.username", "me") | ||
.overrideConfigKey("quarkus.container-image.password", "pass") | ||
.overrideConfigKey("quarkus.kubernetes.generate-image-pull-secret", "true") | ||
.setForcedDependencies(List.of( | ||
Dependency.of("io.quarkus", "quarkus-kubernetes", Version.getVersion()), | ||
Dependency.of("io.quarkus", "quarkus-container-image-docker", Version.getVersion()))); | ||
|
||
@ProdBuildResults | ||
private ProdModeTestResults prodModeTestResults; | ||
|
||
@Test | ||
public void assertGeneratedResources() throws IOException { | ||
assertGeneratedResources(APP_NAME, "kubernetes", prodModeTestResults.getBuildDir()); | ||
} | ||
} |
Oops, something went wrong.