use of io.stackgres.common.crd.sgbackup.StackGresBackupSpec in project stackgres by ongres.
the class BackupTransformer method getResourceSpec.
private BackupSpec getResourceSpec(StackGresBackupSpec source) {
if (source == null) {
return null;
}
BackupSpec transformation = new BackupSpec();
transformation.setCluster(source.getSgCluster());
transformation.setManagedLifecycle(source.getManagedLifecycle());
return transformation;
}
use of io.stackgres.common.crd.sgbackup.StackGresBackupSpec in project stackgres by ongres.
the class BackupTransformer method getCustomResourceSpec.
private StackGresBackupSpec getCustomResourceSpec(BackupSpec source) {
if (source == null) {
return null;
}
StackGresBackupSpec transformation = new StackGresBackupSpec();
transformation.setSgCluster(source.getCluster());
transformation.setManagedLifecycle(source.getManagedLifecycle());
return transformation;
}
use of io.stackgres.common.crd.sgbackup.StackGresBackupSpec in project stackgres by ongres.
the class BackupRequiredResourcesGenerator method getRequiredResources.
@Override
public List<HasMetadata> getRequiredResources(StackGresBackup config) {
final ObjectMeta metadata = config.getMetadata();
final String dbOpsName = metadata.getName();
final String dbOpsNamespace = metadata.getNamespace();
final StackGresBackupSpec spec = config.getSpec();
final StackGresCluster cluster = clusterFinder.findByNameAndNamespace(spec.getSgCluster(), dbOpsNamespace).orElseThrow(() -> new IllegalArgumentException("SGBackup " + dbOpsNamespace + "/" + dbOpsName + " target a non existent SGCluster " + spec.getSgCluster()));
final StackGresBackupConfig backupConfig = Optional.of(cluster.getSpec()).map(StackGresClusterSpec::getConfiguration).map(StackGresClusterConfiguration::getBackupConfig).map(backupConfigName -> backupConfigFinder.findByNameAndNamespace(backupConfigName, dbOpsNamespace).orElseThrow(() -> new IllegalArgumentException("SGBackup " + dbOpsNamespace + "/" + dbOpsName + " target SGCluster " + spec.getSgCluster() + " with a non existent SGBackupConfig " + backupConfigName))).orElseThrow(() -> new IllegalArgumentException("SGBackup " + dbOpsNamespace + "/" + dbOpsName + " target SGCluster " + spec.getSgCluster() + " without a SGBackupConfig"));
StackGresBackupContext context = ImmutableStackGresBackupContext.builder().source(config).cluster(cluster).backupConfig(backupConfig).build();
final List<ResourceGenerator<StackGresBackupContext>> resourceGenerators = generators.getResourceGenerators(context);
final List<HasMetadata> resources = resourceGenerators.stream().flatMap(generator -> generator.generateResource(context)).collect(Collectors.toUnmodifiableList());
List<Decorator<StackGresBackupContext>> decorators = decoratorDiscoverer.discoverDecorator(context);
decorators.forEach(decorator -> decorator.decorate(context, resources));
return resources;
}
Aggregations