Search in sources :

Example 1 with CustomResourceConversion

use of io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceConversion in project stackgres by ongres.

the class WebhookConfiguratorImplTest method configureWebhook_shouldNotFail.

@Test
void configureWebhook_shouldNotFail() {
    var definition = crdFinder.scanDefinitions().get(0);
    final String certificate = StringUtil.generateRandom();
    ArgumentCaptor<CustomResourceDefinition> crdCaptor = ArgumentCaptor.forClass(CustomResourceDefinition.class);
    when(crdWriter.update(crdCaptor.capture())).thenReturn(definition);
    webhookConfigurator.configureWebhook(definition.getMetadata().getName(), certificate);
    CustomResourceDefinition crd = crdCaptor.getValue();
    final CustomResourceDefinitionSpec spec = crd.getSpec();
    final CustomResourceConversion conversion = spec.getConversion();
    final WebhookClientConfig clientConfig = conversion.getWebhook().getClientConfig();
    final ServiceReference service = clientConfig.getService();
    assertEquals("Webhook", conversion.getStrategy());
    assertEquals(OPERATOR_NAME, service.getName());
    assertEquals(OPERATOR_NAMESPACE, service.getNamespace());
    assertEquals("/stackgres/conversion/" + definition.getSpec().getNames().getSingular(), service.getPath());
    assertEquals(certificate, clientConfig.getCaBundle());
    assertFalse(spec.getPreserveUnknownFields());
}
Also used : CustomResourceConversion(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceConversion) WebhookClientConfig(io.fabric8.kubernetes.api.model.apiextensions.v1.WebhookClientConfig) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) CustomResourceDefinitionSpec(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionSpec) ServiceReference(io.fabric8.kubernetes.api.model.apiextensions.v1.ServiceReference) Test(org.junit.jupiter.api.Test)

Aggregations

CustomResourceConversion (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceConversion)1 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition)1 CustomResourceDefinitionSpec (io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionSpec)1 ServiceReference (io.fabric8.kubernetes.api.model.apiextensions.v1.ServiceReference)1 WebhookClientConfig (io.fabric8.kubernetes.api.model.apiextensions.v1.WebhookClientConfig)1 Test (org.junit.jupiter.api.Test)1