Search in sources :

Example 1 with Metadata

use of io.stackgres.apiweb.dto.Metadata in project stackgres by ongres.

the class ClusterResourceQuarkusTest method givenACreationWithSecretAndConfigMapScripts_shouldNotFail.

@Test
void givenACreationWithSecretAndConfigMapScripts_shouldNotFail() {
    ClusterDto cluster = getClusterInlineScripts();
    ClusterScriptEntry secretScriptEntry = getSecretScriptEntry();
    ClusterScriptEntry configMapScriptEntry = getConfigMapScriptEntry();
    cluster.getSpec().getInitData().setScripts(ImmutableList.of(secretScriptEntry, configMapScriptEntry));
    final Metadata metadata = cluster.getMetadata();
    metadata.setNamespace("test");
    given().header(AUTHENTICATION_HEADER).body(cluster).contentType(ContentType.JSON).accept(ContentType.JSON).post("/stackgres/sgclusters").then().statusCode(204);
    try (KubernetesClient client = factory.create()) {
        final ClusterScriptFrom secretScriptFrom = secretScriptEntry.getScriptFrom();
        final SecretKeySelector secretKeyRef = secretScriptFrom.getSecretKeyRef();
        Secret secret = client.secrets().inNamespace("test").withName(secretKeyRef.getName()).get();
        assertNotNull(secret);
        byte[] actualScript = Base64.getDecoder().decode(secret.getData().get(secretKeyRef.getKey()));
        assertEquals(secretScriptFrom.getSecretScript(), new String(actualScript, StandardCharsets.UTF_8));
        final ClusterScriptFrom configMapScriptFrom = configMapScriptEntry.getScriptFrom();
        final ConfigMapKeySelector configMapKeyRef = configMapScriptFrom.getConfigMapKeyRef();
        ConfigMap configMap = client.configMaps().inNamespace("test").withName(configMapKeyRef.getName()).get();
        assertNotNull(configMap);
        assertEquals(configMapScriptFrom.getConfigMapScript(), configMap.getData().get(configMapKeyRef.getKey()));
    }
}
Also used : ClusterScriptEntry(io.stackgres.apiweb.dto.cluster.ClusterScriptEntry) Secret(io.fabric8.kubernetes.api.model.Secret) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ClusterDto(io.stackgres.apiweb.dto.cluster.ClusterDto) Metadata(io.stackgres.apiweb.dto.Metadata) ClusterScriptFrom(io.stackgres.apiweb.dto.cluster.ClusterScriptFrom) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) ConfigMapKeySelector(io.stackgres.common.crd.ConfigMapKeySelector) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with Metadata

use of io.stackgres.apiweb.dto.Metadata in project stackgres by ongres.

the class ClusterResourceQuarkusTest method givenACreationWithInlineScripts_shouldNotFail.

@Test
void givenACreationWithInlineScripts_shouldNotFail() {
    ClusterDto cluster = getClusterInlineScripts();
    final Metadata metadata = cluster.getMetadata();
    metadata.setNamespace("test");
    given().header(AUTHENTICATION_HEADER).body(cluster).contentType(ContentType.JSON).accept(ContentType.JSON).post("/stackgres/sgclusters").then().statusCode(204);
}
Also used : ClusterDto(io.stackgres.apiweb.dto.cluster.ClusterDto) Metadata(io.stackgres.apiweb.dto.Metadata) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 3 with Metadata

use of io.stackgres.apiweb.dto.Metadata in project stackgres by ongres.

the class MetadataMapper method map.

public static Metadata map(ObjectMeta source) {
    Metadata metadata = new Metadata();
    metadata.setName(source.getName());
    metadata.setNamespace(source.getNamespace());
    metadata.setUid(source.getUid());
    return metadata;
}
Also used : Metadata(io.stackgres.apiweb.dto.Metadata)

Example 4 with Metadata

use of io.stackgres.apiweb.dto.Metadata in project stackgres by ongres.

the class AbstractDependencyResourceTransformer method getResourceMetadata.

protected Metadata getResourceMetadata(@NotNull R source) {
    Metadata metadata = new Metadata();
    if (source.getMetadata() != null) {
        metadata.setNamespace(source.getMetadata().getNamespace());
        metadata.setName(source.getMetadata().getName());
        metadata.setUid(source.getMetadata().getUid());
    }
    return metadata;
}
Also used : Metadata(io.stackgres.apiweb.dto.Metadata)

Example 5 with Metadata

use of io.stackgres.apiweb.dto.Metadata in project stackgres by ongres.

the class AbstractDtoTransformer method getDtoMetadata.

protected Metadata getDtoMetadata(@NotNull R source) {
    Metadata metadata = new Metadata();
    if (source.getMetadata() != null) {
        metadata.setNamespace(source.getMetadata().getNamespace());
        metadata.setName(source.getMetadata().getName());
        metadata.setUid(source.getMetadata().getUid());
    }
    return metadata;
}
Also used : Metadata(io.stackgres.apiweb.dto.Metadata)

Aggregations

Metadata (io.stackgres.apiweb.dto.Metadata)8 QuarkusTest (io.quarkus.test.junit.QuarkusTest)4 ClusterDto (io.stackgres.apiweb.dto.cluster.ClusterDto)4 ClusterScriptEntry (io.stackgres.apiweb.dto.cluster.ClusterScriptEntry)4 Test (org.junit.jupiter.api.Test)4 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)3 ClusterScriptFrom (io.stackgres.apiweb.dto.cluster.ClusterScriptFrom)3 SecretKeySelector (io.stackgres.common.crd.SecretKeySelector)3 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 Secret (io.fabric8.kubernetes.api.model.Secret)2 ConfigMapKeySelector (io.stackgres.common.crd.ConfigMapKeySelector)2 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 ClusterConfiguration (io.stackgres.apiweb.dto.cluster.ClusterConfiguration)1 ClusterInitData (io.stackgres.apiweb.dto.cluster.ClusterInitData)1 ClusterPod (io.stackgres.apiweb.dto.cluster.ClusterPod)1 ClusterPodPersistentVolume (io.stackgres.apiweb.dto.cluster.ClusterPodPersistentVolume)1 ClusterPodScheduling (io.stackgres.apiweb.dto.cluster.ClusterPodScheduling)1 ClusterRestore (io.stackgres.apiweb.dto.cluster.ClusterRestore)1 ClusterSpec (io.stackgres.apiweb.dto.cluster.ClusterSpec)1 ClusterSpecLabels (io.stackgres.apiweb.dto.cluster.ClusterSpecLabels)1