Skip to content

Commit

Permalink
remove not longer required workaround of calling register custom kind
Browse files Browse the repository at this point in the history
  • Loading branch information
a-schnapp committed Sep 26, 2023
1 parent 53bc8dd commit 86398e5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import de.koudingspawn.vault.crd.Vault;
import de.koudingspawn.vault.crd.VaultList;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.client.*;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.internal.KubernetesDeserializer;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -38,15 +39,8 @@ public KubernetesClient client() {
@Bean
public MixedOperation<Vault, VaultList, Resource<Vault>> customResource(
KubernetesClient client,
KubernetesDeserializer kubernetesDeserializer,
@Value("${kubernetes.crd.name}") String crdName) {
Resource<CustomResourceDefinition> crdResource = client.apiextensions().v1().customResourceDefinitions().withName(crdName);

// Hack for bug in Kubernetes-Client for CRDs https://github.com/fabric8io/kubernetes-client/issues/1099
String kind = "Vault";
String version = StringUtils.substringAfter(crdName, ".") + "/v1";
kubernetesDeserializer.registerCustomKind(version, kind, Vault.class);

CustomResourceDefinition customResourceDefinition = crdResource.get();
if (customResourceDefinition == null) {
log.error("Please first apply custom resource definition and then restart vault-crd");
Expand All @@ -55,10 +49,4 @@ public MixedOperation<Vault, VaultList, Resource<Vault>> customResource(

return client.resources(Vault.class, VaultList.class);
}

@Bean
public KubernetesDeserializer kubernetesDeserializer() {
return new KubernetesDeserializer();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import de.koudingspawn.vault.vault.communication.SecretNotAccessibleException;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.internal.KubernetesDeserializer;
import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
Expand Down Expand Up @@ -49,14 +46,6 @@ public class AdmissionReviewTest {
@Autowired
private MockMvc mvc;

@Before
public void setup() {
KubernetesDeserializer kubernetesDeserializer = new KubernetesDeserializer();
String version = StringUtils.substringAfter("vault.koudingspawn.de", ".") + "/v1";
String kind = "Vault";
kubernetesDeserializer.registerCustomKind(version, kind, Vault.class);
}

@Test
public void shouldFailWithInvalidRequest() throws Exception {
SecretNotAccessibleException secretException = new SecretNotAccessibleException("Secret is not accessible");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import de.koudingspawn.vault.kubernetes.cache.SecretCache;
import de.koudingspawn.vault.vault.VaultSecret;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import org.junit.After;
Expand Down

0 comments on commit 86398e5

Please sign in to comment.