use of io.stackgres.operator.conciliation.factory.cluster.StackGresClusterContainerContext in project stackgres by ongres.
the class AbstractEnvoy method getContainer.
@Override
public Container getContainer(StackGresClusterContainerContext context) {
ContainerBuilder container = new ContainerBuilder();
container.withName(NAME).withImage(StackGresComponent.ENVOY.findLatestImageName()).withImagePullPolicy("IfNotPresent").withVolumeMounts(new VolumeMountBuilder().withName(NAME).withMountPath("/etc/envoy").withReadOnly(true).build()).addAllToVolumeMounts(getVolumeMounts(context)).withPorts(new ContainerPortBuilder().withProtocol("TCP").withContainerPort(EnvoyUtil.PG_ENTRY_PORT).build(), new ContainerPortBuilder().withProtocol("TCP").withContainerPort(EnvoyUtil.PG_REPL_ENTRY_PORT).build()).withCommand("/usr/local/bin/envoy").withArgs(Seq.of("-c", "/etc/envoy/default_envoy.yaml", "--bootstrap-version", "2").append(Seq.of(ENVOY_LOGGER.isTraceEnabled()).filter(traceEnabled -> traceEnabled).map(traceEnabled -> ImmutableList.of("-l", "debug")).flatMap(List::stream)).toArray(String[]::new));
return container.build();
}
use of io.stackgres.operator.conciliation.factory.cluster.StackGresClusterContainerContext in project stackgres by ongres.
the class ContextUtil method toPostgresContext.
public static PostgresContainerContext toPostgresContext(StackGresClusterContainerContext context) {
final StackGresClusterContext clusterContext = context.getClusterContext();
final StackGresCluster cluster = clusterContext.getSource();
ImmutablePostgresContainerContext.Builder contextBuilder = Optional.of(clusterContext.getSource()).map(StackGresCluster::getStatus).map(StackGresClusterStatus::getDbOps).map(StackGresClusterDbOpsStatus::getMajorVersionUpgrade).map(majorVersionUpgradeStatus -> {
String targetVersion = majorVersionUpgradeStatus.getTargetPostgresVersion();
String sourceVersion = majorVersionUpgradeStatus.getSourcePostgresVersion();
String sourceMajorVersion = StackGresComponent.POSTGRESQL.findMajorVersion(sourceVersion);
return ImmutablePostgresContainerContext.builder().from(context).postgresMajorVersion(StackGresComponent.POSTGRESQL.findMajorVersion(targetVersion)).oldMajorVersion(sourceMajorVersion).imageBuildMajorVersion(StackGresComponent.POSTGRESQL.findBuildMajorVersion(targetVersion)).oldImageBuildMajorVersion(StackGresComponent.POSTGRESQL.findBuildMajorVersion(sourceVersion)).postgresVersion(targetVersion).oldPostgresVersion(sourceVersion);
}).orElseGet(() -> {
final String postgresVersion = cluster.getSpec().getPostgres().getVersion();
final String majorVersion = StackGresComponent.POSTGRESQL.findMajorVersion(postgresVersion);
final String buildMajorVersion = StackGresComponent.POSTGRESQL.findBuildMajorVersion(postgresVersion);
return ImmutablePostgresContainerContext.builder().from(context).postgresVersion(postgresVersion).imageBuildMajorVersion(buildMajorVersion).postgresMajorVersion(majorVersion);
});
final List<StackGresClusterInstalledExtension> installedExtensions = Optional.ofNullable(cluster.getSpec()).map(StackGresClusterSpec::getToInstallPostgresExtensions).stream().flatMap(Collection::stream).collect(Collectors.toUnmodifiableList());
contextBuilder.addAllInstalledExtensions(installedExtensions);
return contextBuilder.build();
}
Aggregations