This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new fa37c444 Docker info
fa37c444 is described below
commit fa37c444c9eb1cf4a1ff6c1f20827f91088ecf0c
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Thu Nov 9 19:10:17 2023 -0500
Docker info
---
.../apache/camel/karavan/api/ConfigurationResource.java | 15 +++++++++++++++
.../org/apache/camel/karavan/docker/DockerService.java | 4 ++++
.../karavan-app/src/main/webui/src/api/KaravanApi.tsx | 12 +++++++++++-
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git
a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ConfigurationResource.java
b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ConfigurationResource.java
index 7cdd7012..df877078 100644
---
a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ConfigurationResource.java
+++
b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/api/ConfigurationResource.java
@@ -22,6 +22,7 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
+import org.apache.camel.karavan.docker.DockerService;
import org.apache.camel.karavan.service.ConfigService;
@Path("/api/configuration")
@@ -30,10 +31,24 @@ public class ConfigurationResource {
@Inject
ConfigService configService;
+ @Inject
+ DockerService dockerService;
+
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getConfiguration() throws Exception {
return Response.ok(configService.getConfiguration()).build();
}
+ @GET
+ @Path("/info")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getInfo() throws Exception {
+ if (ConfigService.inKubernetes()) {
+ return Response.ok().build();
+ } else {
+ return Response.ok(dockerService.getInfo()).build();
+ }
+ }
+
}
\ No newline at end of file
diff --git
a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
index 02bcf76e..6ffb3d1b 100644
---
a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
+++
b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
@@ -80,6 +80,10 @@ public class DockerService extends DockerServiceUtils {
}
}
+ public Info getInfo(){
+ return getDockerClient().infoCmd().exec();
+ }
+
public List<ContainerStatus> collectContainersStatuses() {
List<ContainerStatus> result = new ArrayList<>();
getDockerClient().listContainersCmd().withShowAll(true).exec().forEach(container
-> {
diff --git a/karavan-web/karavan-app/src/main/webui/src/api/KaravanApi.tsx
b/karavan-web/karavan-app/src/main/webui/src/api/KaravanApi.tsx
index d24ecaa7..1f34b55c 100644
--- a/karavan-web/karavan-app/src/main/webui/src/api/KaravanApi.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/api/KaravanApi.tsx
@@ -174,6 +174,17 @@ export class KaravanApi {
});
}
+ static async getInfrastructureInfo(after: (config: AppConfig) => void) {
+ instance.get('/api/configuration/info')
+ .then(res => {
+ if (res.status === 200) {
+ after(res.data);
+ }
+ }).catch(err => {
+ console.log(err);
+ });
+ }
+
static async getProject(projectId: string, after: (project: Project) =>
void) {
instance.get('/api/project/' + projectId)
.then(res => {
@@ -659,4 +670,3 @@ export class KaravanApi {
return fetchData();
}
}
-