use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ExtensionsMutatorTest method clusterWithExtensionInstalledWithExtraMountsAddSimilarExtension_shouldReplaceToInstall.
@Test
void clusterWithExtensionInstalledWithExtraMountsAddSimilarExtension_shouldReplaceToInstall() throws Exception {
final StackGresClusterInstalledExtension installedExtension = getInstalledExtension();
final StackGresClusterExtension extension = getExtension();
extension.setVersion(installedExtension.getVersion());
review.getRequest().getObject().getSpec().getPostgres().setExtensions(ImmutableList.of(extension));
review.getRequest().getObject().getSpec().setToInstallPostgresExtensions(new ArrayList<>());
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().addAll(defaultExtensions);
final StackGresClusterInstalledExtension installedTestExtension = getInstalledExtension();
installedTestExtension.setName("test");
installedTestExtension.setExtraMounts(ImmutableList.of("test"));
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension);
final StackGresExtensionMetadata extensionMetadata = getExtensionMetadata();
extensionMetadata.getVersion().setExtraMounts(ImmutableList.of("test"));
when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(extension))).thenReturn(extensionMetadata);
final List<JsonPatchOperation> operations = mutator.mutate(review);
assertEquals(1, operations.size());
assertEquals(1, operations.stream().filter(o -> o instanceof ReplaceOperation).count());
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ContextUtil method toPostgresContext.
public static PostgresContainerContext toPostgresContext(DistributedLogsContainerContext context) {
StackGresDistributedLogs distributedLogs = context.getDistributedLogsContext().getSource();
List<StackGresClusterInstalledExtension> installedExtensions = Optional.ofNullable(distributedLogs.getSpec()).map(StackGresDistributedLogsSpec::getToInstallPostgresExtensions).stream().flatMap(Collection::stream).collect(Collectors.toUnmodifiableList());
return ImmutablePostgresContainerContext.builder().from(context).postgresMajorVersion(StackGresDistributedLogsUtil.getPostgresMajorVersion()).postgresVersion(StackGresDistributedLogsUtil.getPostgresVersion()).imageBuildMajorVersion(StackGresDistributedLogsUtil.getPostgresBuildMajorVersion()).addAllInstalledExtensions(installedExtensions).build();
}
Aggregations