use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig in project stackgres by ongres.
the class PgConfigDefaultStateMutator method mutate.
@Override
public List<JsonPatchOperation> mutate(PgConfigReview review) {
List<JsonPatchOperation> operations = new ArrayList<>();
StackGresPostgresConfig pgConfig = review.getRequest().getObject();
if (pgConfig.getStatus() == null) {
pgConfig.setStatus(new StackGresPostgresConfigStatus());
operations.add(buildAddOperation(PG_CONFIG_DEFAULT_PARAMETERS_POINTER.parent(), MAPPER.createObjectNode()));
}
operations.addAll(mutate(PG_CONFIG_DEFAULT_PARAMETERS_POINTER, pgConfig));
return operations;
}
use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig in project stackgres by ongres.
the class PgConfigDefaultValuesMutator method mutate.
@Override
public List<JsonPatchOperation> mutate(PgConfigReview review) {
ImmutableList.Builder<JsonPatchOperation> operations = ImmutableList.builder();
StackGresPostgresConfig pgConfig = review.getRequest().getObject();
StackGresPostgresConfigSpec spec = pgConfig.getSpec();
if (spec == null) {
spec = new StackGresPostgresConfigSpec();
pgConfig.setSpec(spec);
operations.add(new AddOperation(PG_CONFIG_POINTER.parent(), FACTORY.objectNode()));
}
if (spec.getPostgresqlConf() == null) {
pgConfig.getSpec().setPostgresqlConf(ImmutableMap.of());
operations.add(new AddOperation(PG_CONFIG_POINTER, FACTORY.objectNode()));
}
operations.addAll(mutate(PG_CONFIG_POINTER, pgConfig));
return operations.build();
}
use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig in project stackgres by ongres.
the class DefaultPostgresFactory method buildResource.
@Override
StackGresPostgresConfig buildResource(String namespace) {
StackGresPostgresConfigSpec spec = new StackGresPostgresConfigSpec();
spec.setPostgresVersion(postgresVersion);
spec.setPostgresqlConf(getDefaultValues());
StackGresPostgresConfig profile = new StackGresPostgresConfig();
profile.getMetadata().setName(generateDefaultName());
profile.getMetadata().setNamespace(namespace);
profile.setSpec(spec);
return profile;
}
use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig in project stackgres by ongres.
the class PostgresConfigTransformerTest method emptyConfig_shouldBeTransformerd.
@Test
void emptyConfig_shouldBeTransformerd() {
List<String> clusters = ImmutableList.of("test");
StackGresPostgresConfig source = createEmptyConfig();
PostgresConfigDto transformed = transformer.toResource(source, clusters);
Assertions.assertNotNull(transformed.getMetadata());
Assertions.assertEquals("default", transformed.getMetadata().getNamespace());
Assertions.assertEquals("test", transformed.getMetadata().getName());
Assertions.assertEquals("test", transformed.getMetadata().getUid());
Assertions.assertNotNull(transformed.getSpec());
Assertions.assertEquals("11", transformed.getSpec().getPostgresVersion());
Assertions.assertNotNull(transformed.getSpec().getPostgresqlConf());
Assertions.assertEquals("", transformed.getSpec().getPostgresqlConf());
Assertions.assertNotNull(transformed.getStatus());
Assertions.assertNotNull(transformed.getStatus().getDefaultParameters());
Assertions.assertEquals(0, transformed.getStatus().getDefaultParameters().size());
Assertions.assertNotNull(transformed.getStatus().getPostgresqlConf());
Assertions.assertEquals(0, transformed.getStatus().getPostgresqlConf().size());
Assertions.assertNotNull(transformed.getStatus().getClusters());
Assertions.assertEquals(clusters, transformed.getStatus().getClusters());
}
use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig in project stackgres by ongres.
the class PostgresConfigTransformerTest method simpleConfigDto_shouldBeTransformerd.
@Test
void simpleConfigDto_shouldBeTransformerd() {
StackGresPostgresConfig original = createOriginal();
PostgresConfigDto source = createEmptyConfigDto();
source.getSpec().setPostgresqlConf("test=1");
StackGresPostgresConfig transformed = transformer.toCustomResource(source, original);
Assertions.assertNotNull(transformed.getMetadata());
Assertions.assertEquals("default", transformed.getMetadata().getNamespace());
Assertions.assertEquals("test", transformed.getMetadata().getName());
Assertions.assertEquals("test", transformed.getMetadata().getUid());
Assertions.assertNotNull(transformed.getSpec());
Assertions.assertEquals("11", transformed.getSpec().getPostgresVersion());
Assertions.assertEquals(ImmutableMap.of("test", "1"), transformed.getSpec().getPostgresqlConf());
}
Aggregations