Search in sources :

Example 1 with StackGresPostgresConfigStatus

use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus in project stackgres by ongres.

the class PostgresConfigTransformerTest method createEmptyConfig.

StackGresPostgresConfig createEmptyConfig() {
    StackGresPostgresConfig source = new StackGresPostgresConfig();
    source.setMetadata(new ObjectMeta());
    source.getMetadata().setNamespace("default");
    source.getMetadata().setName("test");
    source.getMetadata().setUid("test");
    source.setSpec(new StackGresPostgresConfigSpec());
    source.getSpec().setPostgresVersion("11");
    source.getSpec().setPostgresqlConf(ImmutableMap.of());
    source.setStatus(new StackGresPostgresConfigStatus());
    source.getStatus().setDefaultParameters(ImmutableMap.of());
    return source;
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) StackGresPostgresConfigSpec(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigSpec) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus)

Example 2 with StackGresPostgresConfigStatus

use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus in project stackgres by ongres.

the class PatroniConfigEndpointsTest method setUp.

@BeforeEach
void setUp() {
    generator = new PatroniConfigEndpoints(MAPPER, labelFactory);
    cluster = JsonUtil.readFromJson("stackgres_cluster/default.json", StackGresCluster.class);
    backupConfig = JsonUtil.readFromJson("backup_config/default.json", StackGresBackupConfig.class);
    postgresConfig = JsonUtil.readFromJson("postgres_config/default_postgres.json", StackGresPostgresConfig.class);
    postgresConfig.setStatus(new StackGresPostgresConfigStatus());
    postgresConfig.getStatus().setDefaultParameters(PostgresDefaultValues.getDefaultValues());
    lenient().when(context.getBackupConfig()).thenReturn(Optional.of(backupConfig));
    lenient().when(context.getPostgresConfig()).thenReturn(postgresConfig);
}
Also used : StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) StackGresBackupConfig(io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with StackGresPostgresConfigStatus

use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus 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;
}
Also used : ArrayList(java.util.ArrayList) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus) JsonPatchOperation(com.github.fge.jsonpatch.JsonPatchOperation)

Example 4 with StackGresPostgresConfigStatus

use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus in project stackgres by ongres.

the class PostgresConfigTransformer method getResourceStatus.

private PostgresConfigStatus getResourceStatus(List<String> clusters, StackGresPostgresConfigStatus source, StackGresPostgresConfigSpec sourceSpec) {
    PostgresConfigStatus transformation = new PostgresConfigStatus();
    transformation.setClusters(clusters);
    if (sourceSpec != null) {
        transformation.setPostgresqlConf(Seq.seq(sourceSpec.getPostgresqlConf()).map(t -> t.concat(new PostgresqlConfParameter())).peek(t -> t.v3.setParameter(t.v1)).peek(t -> t.v3.setValue(t.v2)).peek(t -> {
            if (!t.v1.contains(".")) {
                t.v3.setDocumentationLink(String.format(POSTGRESQLCO_NF_URL, t.v1, sourceSpec.getPostgresVersion()));
            }
        }).map(Tuple3::v3).toList());
    }
    if (source != null) {
        transformation.setDefaultParameters(source.getDefaultParameters());
    }
    return transformation;
}
Also used : PostgresConfigStatus(io.stackgres.apiweb.dto.pgconfig.PostgresConfigStatus) PostgresqlConfParameter(io.stackgres.apiweb.dto.pgconfig.PostgresqlConfParameter) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus) ImmutableMap(com.google.common.collect.ImmutableMap) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) Seq(org.jooq.lambda.Seq) PostgresConfigSpec(io.stackgres.apiweb.dto.pgconfig.PostgresConfigSpec) List(java.util.List) Tuple2(org.jooq.lambda.tuple.Tuple2) Matcher(java.util.regex.Matcher) PostgresConfigDto(io.stackgres.apiweb.dto.pgconfig.PostgresConfigDto) Tuple(org.jooq.lambda.tuple.Tuple) Tuple3(org.jooq.lambda.tuple.Tuple3) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) StackGresPostgresConfigSpec(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigSpec) Pattern(java.util.regex.Pattern) Tuple3(org.jooq.lambda.tuple.Tuple3) PostgresqlConfParameter(io.stackgres.apiweb.dto.pgconfig.PostgresqlConfParameter) PostgresConfigStatus(io.stackgres.apiweb.dto.pgconfig.PostgresConfigStatus) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus)

Example 5 with StackGresPostgresConfigStatus

use of io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus in project stackgres by ongres.

the class ClusterRequiredResourcesGeneratorTest method setUp.

@BeforeEach
void setUp() {
    cluster = JsonUtil.readFromJson("stackgres_cluster/default.json", StackGresCluster.class);
    cluster.getSpec().getPostgres().setVersion(StackGresComponent.POSTGRESQL.findLatestVersion());
    final String namespace = cluster.getMetadata().getNamespace();
    backupConfig = JsonUtil.readFromJson("backup_config/default.json", StackGresBackupConfig.class);
    setNamespace(backupConfig);
    postgresConfig = JsonUtil.readFromJson("postgres_config/default_postgres.json", StackGresPostgresConfig.class);
    postgresConfig.getSpec().setPostgresVersion(StackGresComponent.POSTGRESQL.findLatestMajorVersion());
    setNamespace(postgresConfig);
    postgresConfig.setStatus(new StackGresPostgresConfigStatus());
    postgresConfig.getStatus().setDefaultParameters(PostgresDefaultValues.getDefaultValues());
    poolingConfig = JsonUtil.readFromJson("pooling_config/default.json", StackGresPoolingConfig.class);
    setNamespace(poolingConfig);
    poolingConfig.setStatus(new StackGresPoolingConfigStatus());
    poolingConfig.getStatus().setPgBouncer(new StackGresPoolingConfigPgBouncerStatus());
    poolingConfig.getStatus().getPgBouncer().setDefaultParameters(PgBouncerDefaultValues.getDefaultValues());
    instanceProfile = JsonUtil.readFromJson("stackgres_profiles/size-s.json", StackGresProfile.class);
    instanceProfile.getMetadata().setNamespace(namespace);
    setNamespace(instanceProfile);
    backups = JsonUtil.readFromJson("backup/list.json", StackGresBackupList.class).getItems();
    backups.forEach(this::setNamespace);
    minioSecret = JsonUtil.readFromJson("secret/minio.json", Secret.class);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) StackGresPoolingConfig(io.stackgres.common.crd.sgpooling.StackGresPoolingConfig) StackGresProfile(io.stackgres.common.crd.sgprofile.StackGresProfile) StackGresPoolingConfigPgBouncerStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerStatus) StackGresBackupConfig(io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig) StackGresPostgresConfig(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig) StackGresPostgresConfigStatus(io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus) StackGresPoolingConfigStatus(io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

StackGresPostgresConfig (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfig)5 StackGresPostgresConfigStatus (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigStatus)5 StackGresBackupConfig (io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig)2 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)2 StackGresPostgresConfigSpec (io.stackgres.common.crd.sgpgconfig.StackGresPostgresConfigSpec)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 JsonPatchOperation (com.github.fge.jsonpatch.JsonPatchOperation)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 Secret (io.fabric8.kubernetes.api.model.Secret)1 PostgresConfigDto (io.stackgres.apiweb.dto.pgconfig.PostgresConfigDto)1 PostgresConfigSpec (io.stackgres.apiweb.dto.pgconfig.PostgresConfigSpec)1 PostgresConfigStatus (io.stackgres.apiweb.dto.pgconfig.PostgresConfigStatus)1 PostgresqlConfParameter (io.stackgres.apiweb.dto.pgconfig.PostgresqlConfParameter)1 StackGresPoolingConfig (io.stackgres.common.crd.sgpooling.StackGresPoolingConfig)1 StackGresPoolingConfigPgBouncerStatus (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigPgBouncerStatus)1 StackGresPoolingConfigStatus (io.stackgres.common.crd.sgpooling.StackGresPoolingConfigStatus)1 StackGresProfile (io.stackgres.common.crd.sgprofile.StackGresProfile)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1