Skip to content

Commit

Permalink
chore (quickstarts/maven/spring-boot-crd) : Update outdated methods i…
Browse files Browse the repository at this point in the history
…n Spring Boot CRD (eclipse-jkube#1985)

Spring Boot CRD seems to be broken. It seems to be inheriting
kubernetes-client from jkube but it's using outdated `customResource`
raw api calls.

Update it to use genericKubernetesResource() DSL call instead.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Jun 20, 2023
1 parent b95620d commit e57004d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Usage:
### 1.14-SNAPSHOT
* Fix #1713: Add HelidonHealthCheckEnricher to add Kubernetes health checks for Helidon applications
* Fix #1714: Add HelidonGenerator to add opinionated container image for Helidon applications
* Fix #1985: Update outdated methods in Spring Boot CRD Maven Quickstart

### 1.13.1 (2023-06-16)
* Fix #2212: Bump Kubernetes Client version to 6.7.2 (fixes issues when trace-logging OpenShift builds -regression in 6.7.1-)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
package org.eclipse.jkube.quickstart.springboot.crd;

import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -29,7 +29,7 @@ public static void main(String[] args) {

@Bean
public KubernetesClient kubernetesClient() {
return new DefaultKubernetesClient();
return new KubernetesClientBuilder().build();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
*/
package org.eclipse.jkube.quickstart.springboot.crd;

import io.fabric8.kubernetes.api.model.GenericKubernetesResource;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
Expand All @@ -35,10 +36,11 @@ public FrameworkResource(KubernetesClient kubernetesClient, CustomResourceDefini
this.crdContext = crdContext;
}

@SuppressWarnings("unchecked")
@GetMapping
public List<String> get() {
return ((List<Map<String, Object>>)kubernetesClient.customResource(crdContext).list().get("items")).stream()
.map(m -> (String)m.get("name")).collect(Collectors.toList());
return (kubernetesClient.genericKubernetesResources(crdContext).list().getItems()).stream()
.map(GenericKubernetesResource::getMetadata)
.map(ObjectMeta::getName)
.collect(Collectors.toList());
}
}

0 comments on commit e57004d

Please sign in to comment.