From 6977d98bd4153a0a865a0c8f91fe8b49d26b315d Mon Sep 17 00:00:00 2001 From: Jesus Zazueta Date: Sun, 25 Aug 2024 04:50:00 -0400 Subject: [PATCH] - Initial API server based implementation. --- .../java/io/vacco/beleth/rt/impl/BlKubeApi.java | 15 ++++++++++----- bl-k8s-test/src/test/java/BlKubeRtTest.java | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bl-k8s-rt/src/main/java/io/vacco/beleth/rt/impl/BlKubeApi.java b/bl-k8s-rt/src/main/java/io/vacco/beleth/rt/impl/BlKubeApi.java index d554688..e1ca1bd 100644 --- a/bl-k8s-rt/src/main/java/io/vacco/beleth/rt/impl/BlKubeApi.java +++ b/bl-k8s-rt/src/main/java/io/vacco/beleth/rt/impl/BlKubeApi.java @@ -15,6 +15,7 @@ import static io.vacco.beleth.rt.util.BlIo.*; import static io.vacco.beleth.rt.util.BlResources.*; import static io.vacco.beleth.rt.util.BlResourceTypes.internalTypes; +import static io.vacco.beleth.rt.impl.BlLogging.onError; public class BlKubeApi { @@ -70,11 +71,15 @@ public void loadResourceTypes() { for (var versionElement : versions) { var version = versionElement.getAsJsonObject().get("version").getAsString(); var resourceListUri = format("/apis/%s/%s", groupName, version); - var resourceListContent = load(uri(apiServerUri, resourceListUri)); - var resourceList = parseString(resourceListContent).getAsJsonObject(); - var resources = resourceList.getAsJsonArray("resources"); - for (var resourceElement : resources) { - addResource(resourceListUri, resourceElement); + try { + var resourceListContent = load(uri(apiServerUri, resourceListUri)); + var resourceList = parseString(resourceListContent).getAsJsonObject(); + var resources = resourceList.getAsJsonArray("resources"); + for (var resourceElement : resources) { + addResource(resourceListUri, resourceElement); + } + } catch (Exception e) { + onError(log, "Unable to load resource list [{}]", e, resourceListUri); } } } diff --git a/bl-k8s-test/src/test/java/BlKubeRtTest.java b/bl-k8s-test/src/test/java/BlKubeRtTest.java index 21e813d..709860b 100644 --- a/bl-k8s-test/src/test/java/BlKubeRtTest.java +++ b/bl-k8s-test/src/test/java/BlKubeRtTest.java @@ -19,10 +19,10 @@ public class BlKubeRtTest { static { it("Synchronizes resources with a cluster", () -> runLocal(() -> { var apiServer = "https://k8s.xio.vacco.li:6443"; - var token = "eyJhbGciOiJSUzI1NiIsImtpZCI6Iko3Y05nQlVFMG5nQXVDRG1TcGdZX1B2SjVzVElBR0x2aUJDc2RicDBZNVkifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJjbHVzdGVyLWFkbWluLXNhLXRva2VuIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImNsdXN0ZXItYWRtaW4tc2EiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJkNWNjODMxNS03MzgxLTRlNTgtOGE1Ny02OTg2NzNjMzE4OTUiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06Y2x1c3Rlci1hZG1pbi1zYSJ9.Gi0CseM5bGpFjSajD_ByLNFg5pwB19JZ87l2BgZvGmkZ_ibIoeEOTyCJ0tT11dv8TKmd_GSlHVvgHNMRi3WtjeOlcxXFtbplvR-gZKSru-SCYPMouM5zHwcoA6nTV8gQDxY3TfMqpbm9XEwdqGD9dh_5CtYSwILqJ9wlTDKiuGIBSp67fmp4U2aUgW-clyAhKVDcCjThlHh0gzYfvq25LPJZ6GfFvosOitIrn9J22Pp8-msnkTwfkVg-RY3XYExtzB1gM4_iKJqWYRTZ5eJCplIBgshuI_AhyLpCYel3gb88jTV_HfO3-pcoFrBPjHfsGpyg9_QboBytdpJHdrB1l1E93SFJHngueXy786e5g1CHgn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2xk1s695m8tdlwmYpGmu1FzHcf2wVDS49IVA1J0SC_DxbSN3rXjyio51aMkmXcVYHluZKMRZy1cS_xttO1qZULRMPOrV4QYQUryW7Hc9n4qq26eWsygFed6F9uVb8fchFcgz8cM0XkygtkUZQKN36vghgX2WzOp1sO1TuGXFNi02L-oCCHCt8hVt4gacNosAl3OYcP2gREj6qcBRNwdXcWvOXJUIVddf_fjNBJ_VxjCk4lZZIviwG-1OY9OrutCZ7f9f65YL8WPzJrlAoBbecm7oyIfqup2oJl8oJHNS3fjhhSIuD6blB2_JuzhI0FD_MGQyJWXdsGMMC8oT2x5hhDmaM1C0MxqQ6o-0--hkxq6K0xhPVO6SBq6-ETScGX1YsB2LqEf5VPUBXIP52hXhgAHa7r4pQJbt1VjgWdPSiRZJ5aXD4ILdEraO1YptQTMUIkuttBqM0WoiZ7xiMy4JVlqbeP4nhwPNOHoYl-DGCu6E9h-la-xhvaB4p_wQWz3-7BCDQTbIm4mGUE8"; var rt = new BlKubeRt(apiServer, token); - var add = true; + var add = false; if (add) { rt .add(BlTestManifests.nameSpace)