use of io.stackgres.common.crd.sgdbops.StackGresDbOpsVacuum in project stackgres by ongres.
the class DbOpsVacuumJob method getRunEnvVars.
@Override
protected List<EnvVar> getRunEnvVars(StackGresDbOpsContext context) {
StackGresDbOps dbOps = context.getSource();
StackGresDbOpsVacuum vacuum = dbOps.getSpec().getVacuum();
final String primaryServiceDns = PatroniServices.readWriteName(context);
List<EnvVar> runEnvVars = ImmutableList.<EnvVar>builder().add(new EnvVarBuilder().withName("PGHOST").withValue(primaryServiceDns).build(), new EnvVarBuilder().withName("PGUSER").withValue("postgres").build(), new EnvVarBuilder().withName("PGPASSWORD").withNewValueFrom().withNewSecretKeyRef().withName(PatroniSecret.name(context.getCluster())).withKey(PatroniSecret.SUPERUSER_PASSWORD_KEY).endSecretKeyRef().endValueFrom().build()).addAll(getVacuumConfigEnvVar(vacuum)).add(new EnvVarBuilder().withName("DATABASES").withValue(Seq.seq(Optional.ofNullable(vacuum).map(StackGresDbOpsVacuum::getDatabases).stream()).flatMap(List::stream).map(database -> Seq.seq(getVacuumConfigEnvVar(vacuum)).map(envVar -> envVar.getName() + "=" + envVar.getValue()).toString(";") + " " + database.getName()).toString("\n")).build()).build();
return runEnvVars;
}
use of io.stackgres.common.crd.sgdbops.StackGresDbOpsVacuum in project stackgres by ongres.
the class DbOpsTransformer method getResourceVacuum.
private DbOpsVacuum getResourceVacuum(StackGresDbOpsVacuum source) {
if (source == null) {
return null;
}
DbOpsVacuum transformation = new DbOpsVacuum();
setResourceVacuumConfig(source, transformation);
transformation.setDatabases(Seq.seq(Optional.ofNullable(source.getDatabases()).stream()).flatMap(List::stream).map(database -> Tuple.tuple(database, new DbOpsVacuumDatabase())).peek(t -> t.v2.setName(t.v1.getName())).peek(t -> setResourceVacuumConfig(t.v1, t.v2)).map(Tuple2::v2).toList());
return transformation;
}
use of io.stackgres.common.crd.sgdbops.StackGresDbOpsVacuum in project stackgres by ongres.
the class DbOpsTransformer method getCustomResourceVacuum.
private StackGresDbOpsVacuum getCustomResourceVacuum(DbOpsVacuum source) {
if (source == null) {
return null;
}
StackGresDbOpsVacuum transformation = new StackGresDbOpsVacuum();
setCustomResourceVacuumConfig(source, transformation);
transformation.setDatabases(Seq.seq(Optional.ofNullable(source.getDatabases()).stream()).flatMap(List::stream).map(database -> Tuple.tuple(database, new StackGresDbOpsVacuumDatabase())).peek(t -> t.v2.setName(t.v1.getName())).peek(t -> setCustomResourceVacuumConfig(t.v1, t.v2)).map(Tuple2::v2).toList());
return transformation;
}
Aggregations