Search in sources :

Example 1 with StackGresDistributedLogsSpecAnnotations

use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecAnnotations 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)1 StackGresDistributedLogsPodScheduling (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPodScheduling)1 StackGresDistributedLogsSpec (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpec)1 StackGresDistributedLogsSpecAnnotations (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecAnnotations)1 StackGresDistributedLogsSpecMetadata (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpecMetadata)1