-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addressed remaining code review comments
- Loading branch information
Showing
8 changed files
with
107 additions
and
21 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
examples/example-kubernetes-client-openapi-java/build.gradle
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,38 @@ | ||
plugins { | ||
id 'io.micronaut.build.internal.kubernetes-examples' | ||
id 'groovy' | ||
} | ||
|
||
micronaut { | ||
version libs.versions.micronaut.platform.get() | ||
runtime("netty") | ||
testRuntime("junit5") | ||
processing { | ||
incremental(true) | ||
annotations("micronaut.client.*") | ||
} | ||
} | ||
|
||
dependencies { | ||
annotationProcessor(mnValidation.micronaut.validation.processor) | ||
annotationProcessor(mnSerde.micronaut.serde.processor) | ||
implementation(mnValidation.micronaut.validation) | ||
implementation(mnSerde.micronaut.serde.jackson) | ||
implementation(mn.micronaut.management) | ||
implementation projects.micronautKubernetesClientOpenapi | ||
compileOnly(mn.micronaut.http.client) | ||
runtimeOnly(mnLogging.logback.classic) | ||
} | ||
|
||
application { | ||
mainClass.set("micronaut.client.Application") | ||
} | ||
tasks { | ||
dockerBuild { | ||
images = ['micronaut-kubernetes-client-openapi-example'] | ||
} | ||
|
||
dockerBuildNative { | ||
images = ['micronaut-kubernetes-client-openapi-example'] | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...es/example-kubernetes-client-openapi-java/src/main/java/micronaut/client/Application.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,10 @@ | ||
package micronaut.client; | ||
|
||
import io.micronaut.runtime.Micronaut; | ||
|
||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
Micronaut.run(Application.class); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../example-kubernetes-client-openapi-java/src/main/java/micronaut/client/PodController.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,38 @@ | ||
package micronaut.client; | ||
|
||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Get; | ||
import io.micronaut.kubernetes.client.openapi.api.CoreV1Api; | ||
import io.micronaut.kubernetes.client.openapi.model.V1Pod; | ||
import io.micronaut.kubernetes.client.openapi.model.V1PodList; | ||
import io.micronaut.scheduling.TaskExecutors; | ||
import io.micronaut.scheduling.annotation.ExecuteOn; | ||
import jakarta.inject.Inject; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
@Controller("/pods") | ||
@ExecuteOn(TaskExecutors.BLOCKING) | ||
public class PodController { | ||
|
||
@Inject | ||
CoreV1Api coreV1Api; | ||
|
||
@Get("/{namespace}/{name}") | ||
public String getPod(final @NotNull String namespace, final @NotNull String name) { | ||
V1Pod v1Pod = coreV1Api.readNamespacedPod(name, namespace, null); | ||
return v1Pod.getStatus().getPhase(); | ||
} | ||
|
||
@Get("/{namespace}") | ||
public Map<String, String> getPods(final @NotNull String namespace) { | ||
V1PodList v1PodList = coreV1Api.listNamespacedPod(namespace, null, null, null, null, null, null, null, null, null, null, false); | ||
return v1PodList.getItems().stream() | ||
.filter(p -> p.getStatus() != null) | ||
.collect(Collectors.toMap( | ||
p -> p.getMetadata().getName(), | ||
p -> p.getStatus().getPhase())); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/example-kubernetes-client-openapi-java/src/main/resources/application.yml
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,5 @@ | ||
micronaut: | ||
server: | ||
port: 8082 | ||
application: | ||
name: micronaut-kubernetes-client-openapi |
10 changes: 10 additions & 0 deletions
10
examples/example-kubernetes-client-openapi-java/src/main/resources/logback.xml
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,10 @@ | ||
<configuration> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([example-client]) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
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