use of io.stackgres.common.crd.sgdbops.StackGresDbOpsRepack in project stackgres by ongres.
the class DbOpsRepackJob method getRunEnvVars.
@Override
protected List<EnvVar> getRunEnvVars(StackGresDbOpsContext context) {
StackGresDbOps dbOps = context.getSource();
StackGresDbOpsRepack repack = dbOps.getSpec().getRepack();
List<EnvVar> runEnvVars = ImmutableList.<EnvVar>builder().add(new EnvVarBuilder().withName("CLUSTER_NAMESPACE").withValue(context.getSource().getMetadata().getNamespace()).build(), new EnvVarBuilder().withName("CLUSTER_NAME").withValue(context.getSource().getMetadata().getName()).build(), new EnvVarBuilder().withName("CLUSTER_PRIMARY_POD_LABELS").withValue(labelFactory.patroniPrimaryLabels(context.getCluster()).entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(","))).build(), new EnvVarBuilder().withName("PATRONI_CONTAINER_NAME").withValue(StackgresClusterContainers.PATRONI).build()).addAll(getRepackConfigEnvVar(repack)).add(new EnvVarBuilder().withName("DATABASES").withValue(Seq.seq(Optional.ofNullable(repack).map(StackGresDbOpsRepack::getDatabases).stream()).flatMap(List::stream).map(database -> Seq.seq(getRepackConfigEnvVar(repack)).map(envVar -> envVar.getName() + "=" + envVar.getValue()).toString(";") + " " + database.getName()).toString("\n")).build()).build();
return runEnvVars;
}
use of io.stackgres.common.crd.sgdbops.StackGresDbOpsRepack in project stackgres by ongres.
the class DbOpsTransformer method getResourceRepack.
private DbOpsRepack getResourceRepack(StackGresDbOpsRepack source) {
if (source == null) {
return null;
}
DbOpsRepack transformation = new DbOpsRepack();
setResourceRepackConfig(source, transformation);
transformation.setDatabases(Seq.seq(Optional.ofNullable(source.getDatabases()).stream()).flatMap(List::stream).map(database -> Tuple.tuple(database, new DbOpsRepackDatabase())).peek(t -> t.v2.setName(t.v1.getName())).peek(t -> setResourceRepackConfig(t.v1, t.v2)).map(Tuple2::v2).toList());
return transformation;
}
use of io.stackgres.common.crd.sgdbops.StackGresDbOpsRepack in project stackgres by ongres.
the class DbOpsTransformer method getCustomResourceRepack.
private StackGresDbOpsRepack getCustomResourceRepack(DbOpsRepack source) {
if (source == null) {
return null;
}
StackGresDbOpsRepack transformation = new StackGresDbOpsRepack();
setCustomResourceRepackConfig(source, transformation);
transformation.setDatabases(Seq.seq(Optional.ofNullable(source.getDatabases()).stream()).flatMap(List::stream).map(database -> Tuple.tuple(database, new StackGresDbOpsRepackDatabase())).peek(t -> t.v2.setName(t.v1.getName())).peek(t -> setCustomResourceRepackConfig(t.v1, t.v2)).map(Tuple2::v2).toList());
return transformation;
}
Aggregations