Search in sources :

Example 1 with StackGresClusterRestorePitr

use of io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr in project stackgres by ongres.

the class ClusterPatroniEnvVarFactory method createResource.

@Override
public List<EnvVar> createResource(StackGresClusterContext context) {
    StackGresCluster cluster = context.getSource();
    List<EnvVar> additionalEnvVars = Optional.ofNullable(cluster.getSpec()).map(StackGresClusterSpec::getInitData).map(StackGresClusterInitData::getRestore).map(StackGresClusterRestore::getFromBackup).map(StackGresClusterRestoreFromBackup::getPointInTimeRecovery).map(StackGresClusterRestorePitr::getRestoreToTimestamp).map(Instant::parse).map(restoreToTimestamp -> new EnvVarBuilder().withName("RECOVERY_TARGET_TIME").withValue(DateTimeFormatter.ISO_LOCAL_DATE.withZone(ZoneId.from(ZoneOffset.UTC)).format(restoreToTimestamp) + " " + DateTimeFormatter.ISO_LOCAL_TIME.withZone(ZoneId.from(ZoneOffset.UTC)).format(restoreToTimestamp)).build()).map(List::of).orElse(List.of());
    List<EnvVar> patroniEnvVars = createPatroniEnvVars(cluster);
    return ImmutableList.<EnvVar>builder().add(new EnvVarBuilder().withName("PATRONI_RESTAPI_LISTEN").withValue("0.0.0.0:" + EnvoyUtil.PATRONI_PORT).build()).addAll(patroniEnvVars).addAll(additionalEnvVars).build();
}
Also used : StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) StackGresClusterRestorePitr(io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr) StackGresClusterSpec(io.stackgres.common.crd.sgcluster.StackGresClusterSpec) StackGresClusterRestore(io.stackgres.common.crd.sgcluster.StackGresClusterRestore) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder)

Example 2 with StackGresClusterRestorePitr

use of io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr in project stackgres by ongres.

the class ClusterTransformer method getResourceRestorePitr.

private ClusterRestorePitr getResourceRestorePitr(StackGresClusterRestorePitr source) {
    if (source == null) {
        return null;
    }
    ClusterRestorePitr transformation = new ClusterRestorePitr();
    transformation.setRestoreToTimestamp(source.getRestoreToTimestamp());
    return transformation;
}
Also used : StackGresClusterRestorePitr(io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr) ClusterRestorePitr(io.stackgres.apiweb.dto.cluster.ClusterRestorePitr)

Example 3 with StackGresClusterRestorePitr

use of io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr in project stackgres by ongres.

the class ClusterTransformer method getCustomResourceRestorePitr.

private StackGresClusterRestorePitr getCustomResourceRestorePitr(ClusterRestorePitr source) {
    if (source == null) {
        return null;
    }
    StackGresClusterRestorePitr transformation = new StackGresClusterRestorePitr();
    transformation.setRestoreToTimestamp(source.getRestoreToTimestamp());
    return transformation;
}
Also used : StackGresClusterRestorePitr(io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr)

Aggregations

StackGresClusterRestorePitr (io.stackgres.common.crd.sgcluster.StackGresClusterRestorePitr)3 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)1 ClusterRestorePitr (io.stackgres.apiweb.dto.cluster.ClusterRestorePitr)1 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)1 StackGresClusterRestore (io.stackgres.common.crd.sgcluster.StackGresClusterRestore)1 StackGresClusterSpec (io.stackgres.common.crd.sgcluster.StackGresClusterSpec)1