Search in sources :

Example 1 with StackGresBackupSpec

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;
}
Also used : BackupSpec(io.stackgres.apiweb.dto.backup.BackupSpec) StackGresBackupSpec(io.stackgres.common.crd.sgbackup.StackGresBackupSpec)

Example 2 with StackGresBackupSpec

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;
}
Also used : StackGresBackupSpec(io.stackgres.common.crd.sgbackup.StackGresBackupSpec)

Example 3 with StackGresBackupSpec

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;
}
Also used : StackGresBackupConfig(io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig) Logger(org.slf4j.Logger) StackGresClusterConfiguration(io.stackgres.common.crd.sgcluster.StackGresClusterConfiguration) StackGresBackup(io.stackgres.common.crd.sgbackup.StackGresBackup) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) RequiredResourceGenerator(io.stackgres.operator.conciliation.RequiredResourceGenerator) Inject(javax.inject.Inject) StackGresClusterSpec(io.stackgres.common.crd.sgcluster.StackGresClusterSpec) List(java.util.List) ResourceGenerationDiscoverer(io.stackgres.operator.conciliation.ResourceGenerationDiscoverer) ResourceGenerator(io.stackgres.operator.conciliation.ResourceGenerator) DecoratorDiscoverer(io.stackgres.operator.conciliation.factory.DecoratorDiscoverer) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) Optional(java.util.Optional) StackGresBackupSpec(io.stackgres.common.crd.sgbackup.StackGresBackupSpec) CustomResourceFinder(io.stackgres.common.resource.CustomResourceFinder) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Decorator(io.stackgres.operator.conciliation.factory.Decorator) RequiredResourceGenerator(io.stackgres.operator.conciliation.RequiredResourceGenerator) ResourceGenerator(io.stackgres.operator.conciliation.ResourceGenerator) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) StackGresBackupConfig(io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig) Decorator(io.stackgres.operator.conciliation.factory.Decorator) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) StackGresBackupSpec(io.stackgres.common.crd.sgbackup.StackGresBackupSpec) StackGresClusterConfiguration(io.stackgres.common.crd.sgcluster.StackGresClusterConfiguration)

Aggregations

StackGresBackupSpec (io.stackgres.common.crd.sgbackup.StackGresBackupSpec)3 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 BackupSpec (io.stackgres.apiweb.dto.backup.BackupSpec)1 StackGresBackup (io.stackgres.common.crd.sgbackup.StackGresBackup)1 StackGresBackupConfig (io.stackgres.common.crd.sgbackupconfig.StackGresBackupConfig)1 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)1 StackGresClusterConfiguration (io.stackgres.common.crd.sgcluster.StackGresClusterConfiguration)1 StackGresClusterSpec (io.stackgres.common.crd.sgcluster.StackGresClusterSpec)1 CustomResourceFinder (io.stackgres.common.resource.CustomResourceFinder)1 RequiredResourceGenerator (io.stackgres.operator.conciliation.RequiredResourceGenerator)1 ResourceGenerationDiscoverer (io.stackgres.operator.conciliation.ResourceGenerationDiscoverer)1 ResourceGenerator (io.stackgres.operator.conciliation.ResourceGenerator)1 Decorator (io.stackgres.operator.conciliation.factory.Decorator)1 DecoratorDiscoverer (io.stackgres.operator.conciliation.factory.DecoratorDiscoverer)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1