Search in sources :

Example 1 with DistributedLogsPostgresServicesConverter

use of io.stackgres.apiweb.transformer.distributedlogs.DistributedLogsPostgresServicesConverter in project stackgres by ongres.

the class DistributedLogsTransformer method getResourceSpec.

private DistributedLogsSpec getResourceSpec(StackGresDistributedLogsSpec source) {
    DistributedLogsSpec transformation = new DistributedLogsSpec();
    transformation.setPersistentVolume(getResourcePersistentVolume(source.getPersistentVolume()));
    transformation.setNonProduction(getResourceNonProduction(source.getNonProduction()));
    transformation.setPostgresServices(new DistributedLogsPostgresServicesConverter().from(source.getPostgresServices()));
    transformation.setScheduling(Optional.ofNullable(source.getScheduling()).map(sourcePodScheduling -> {
        DistributedLogsPodScheduling podScheduling = new DistributedLogsPodScheduling();
        podScheduling.setNodeSelector(sourcePodScheduling.getNodeSelector());
        podScheduling.setTolerations(sourcePodScheduling.getTolerations());
        return podScheduling;
    }).orElse(null));
    Optional.ofNullable(source.getMetadata()).map(StackGresDistributedLogsSpecMetadata::getAnnotations).ifPresent(sourceAnnotations -> {
        transformation.setMetadata(new DistributedLogsSpecMetadata());
        final DistributedLogsSpecAnnotations targetAnnotations = new DistributedLogsSpecAnnotations();
        transformation.getMetadata().setAnnotations(targetAnnotations);
        if (sourceAnnotations.getAllResources() != null) {
            targetAnnotations.setAllResources(sourceAnnotations.getAllResources());
        }
        if (sourceAnnotations.getPods() != null) {
            targetAnnotations.setPods(sourceAnnotations.getPods());
        }
        if (sourceAnnotations.getServices() != null) {
            targetAnnotations.setServices(sourceAnnotations.getServices());
        }
    });
    if (source.getToInstallPostgresExtensions() != null) {
        transformation.setToInstallPostgresExtensions(source.getToInstallPostgresExtensions().stream().map(this::getClusterInstalledExtension).collect(ImmutableList.toImmutableList()));
    }
    return transformation;
}
Also used : StackGresDistributedLogsSpecMetadata(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecMetadata) DistributedLogsSpecMetadata(io.stackgres.apiweb.dto.distributedlogs.DistributedLogsSpecMetadata) DistributedLogsPostgresServicesConverter(io.stackgres.apiweb.transformer.distributedlogs.DistributedLogsPostgresServicesConverter) DistributedLogsSpecAnnotations(io.stackgres.apiweb.dto.distributedlogs.DistributedLogsSpecAnnotations) StackGresDistributedLogsSpecAnnotations(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecAnnotations) DistributedLogsSpec(io.stackgres.apiweb.dto.distributedlogs.DistributedLogsSpec) StackGresDistributedLogsSpec(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpec) DistributedLogsPodScheduling(io.stackgres.apiweb.dto.distributedlogs.DistributedLogsPodScheduling) StackGresDistributedLogsPodScheduling(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPodScheduling)

Example 2 with DistributedLogsPostgresServicesConverter

use of io.stackgres.apiweb.transformer.distributedlogs.DistributedLogsPostgresServicesConverter in project stackgres by ongres.

the class DistributedLogsTransformer method getCustomResourceSpec.

private StackGresDistributedLogsSpec getCustomResourceSpec(DistributedLogsSpec source) {
    StackGresDistributedLogsSpec transformation = new StackGresDistributedLogsSpec();
    transformation.setPersistentVolume(getCustomResourcePersistentVolume(source.getPersistentVolume()));
    transformation.setPostgresServices(new DistributedLogsPostgresServicesConverter().to(source.getPostgresServices()));
    transformation.setNonProduction(getCustomResourceNonProduction(source.getNonProduction()));
    transformation.setScheduling(Optional.ofNullable(source.getScheduling()).map(sourceScheduling -> {
        StackGresDistributedLogsPodScheduling targetScheduling = new StackGresDistributedLogsPodScheduling();
        targetScheduling.setNodeSelector(sourceScheduling.getNodeSelector());
        targetScheduling.setTolerations(sourceScheduling.getTolerations());
        return targetScheduling;
    }).orElse(null));
    Optional.ofNullable(source.getMetadata()).map(DistributedLogsSpecMetadata::getAnnotations).ifPresent(sourceAnnotations -> {
        transformation.setMetadata(new StackGresDistributedLogsSpecMetadata());
        final StackGresDistributedLogsSpecAnnotations targetAnnotations = new StackGresDistributedLogsSpecAnnotations();
        transformation.getMetadata().setAnnotations(targetAnnotations);
        if (sourceAnnotations.getAllResources() != null) {
            targetAnnotations.setAllResources(sourceAnnotations.getAllResources());
        }
        if (sourceAnnotations.getPods() != null) {
            targetAnnotations.setPods(sourceAnnotations.getPods());
        }
        if (sourceAnnotations.getServices() != null) {
            targetAnnotations.setServices(sourceAnnotations.getServices());
        }
    });
    return transformation;
}
Also used : DistributedLogsPostgresServicesConverter(io.stackgres.apiweb.transformer.distributedlogs.DistributedLogsPostgresServicesConverter) StackGresDistributedLogsSpec(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpec) StackGresDistributedLogsPodScheduling(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPodScheduling) StackGresDistributedLogsSpecAnnotations(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecAnnotations) StackGresDistributedLogsSpecMetadata(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecMetadata)

Aggregations

DistributedLogsPostgresServicesConverter (io.stackgres.apiweb.transformer.distributedlogs.DistributedLogsPostgresServicesConverter)2 StackGresDistributedLogsPodScheduling (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPodScheduling)2 StackGresDistributedLogsSpec (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpec)2 StackGresDistributedLogsSpecAnnotations (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecAnnotations)2 StackGresDistributedLogsSpecMetadata (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecMetadata)2 DistributedLogsPodScheduling (io.stackgres.apiweb.dto.distributedlogs.DistributedLogsPodScheduling)1 DistributedLogsSpec (io.stackgres.apiweb.dto.distributedlogs.DistributedLogsSpec)1 DistributedLogsSpecAnnotations (io.stackgres.apiweb.dto.distributedlogs.DistributedLogsSpecAnnotations)1 DistributedLogsSpecMetadata (io.stackgres.apiweb.dto.distributedlogs.DistributedLogsSpecMetadata)1