use of io.stackgres.apiweb.dto.cluster.ClusterScriptEntry in project stackgres by ongres.
the class ClusterResourceQuarkusTest method givenACreationWithSecretScripts_shouldNotFail.
@Test
void givenACreationWithSecretScripts_shouldNotFail() {
ClusterDto cluster = getClusterInlineScripts();
ClusterScriptEntry entry = getSecretScriptEntry();
cluster.getSpec().getInitData().setScripts(Collections.singletonList(entry));
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 scriptFrom = entry.getScriptFrom();
final SecretKeySelector secretKeyRef = scriptFrom.getSecretKeyRef();
Secret secret = client.secrets().inNamespace("test").withName(secretKeyRef.getName()).get();
assertNotNull(secret);
byte[] actualScript = Base64.getDecoder().decode(secret.getData().get(secretKeyRef.getKey()));
assertEquals(scriptFrom.getSecretScript(), new String(actualScript, StandardCharsets.UTF_8));
}
}
use of io.stackgres.apiweb.dto.cluster.ClusterScriptEntry in project stackgres by ongres.
the class ClusterResourceQuarkusTest method getSecretScriptEntry.
private ClusterScriptEntry getSecretScriptEntry() {
ClusterScriptEntry entry = new ClusterScriptEntry();
entry.setName("init");
final ClusterScriptFrom scriptFrom = new ClusterScriptFrom();
scriptFrom.setSecretScript("CREATE DATABASE test");
final SecretKeySelector secretMapKeyRef = new SecretKeySelector();
scriptFrom.setSecretKeyRef(secretMapKeyRef);
secretMapKeyRef.setKey("script");
secretMapKeyRef.setName("initScript");
entry.setScriptFrom(scriptFrom);
return entry;
}
Aggregations