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()));
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations