use of io.stackgres.operator.conciliation.DeployedResourceDecorator in project stackgres by ongres.
the class DbOpsDeployedResourceScanner method getDeployedResources.
@Override
public List<HasMetadata> getDeployedResources(StackGresDbOps config) {
try (KubernetesClient client = clientFactory.create()) {
final Map<String, String> genericLabels = labelFactory.genericLabels(config);
Stream<HasMetadata> inNamespace = IN_NAMESPACE_RESOURCE_OPERATIONS.values().stream().flatMap(resourceOperationGetter -> resourceOperationGetter.apply(client).inNamespace(config.getMetadata().getNamespace()).withLabels(genericLabels).list().getItems().stream());
List<HasMetadata> deployedResources = inNamespace.filter(resource -> resource.getMetadata().getOwnerReferences().stream().anyMatch(ownerReference -> ownerReference.getKind().equals(StackGresDbOps.KIND) && ownerReference.getName().equals(config.getMetadata().getName()) && ownerReference.getUid().equals(config.getMetadata().getUid()))).collect(Collectors.toUnmodifiableList());
deployedResources.forEach(resource -> {
Instance<DeployedResourceDecorator> decorator = decorators.select(new ReconciliationScopeLiteral(StackGresDbOps.class, resource.getKind()));
if (decorator.isResolvable()) {
decorator.get().decorate(resource);
}
});
return deployedResources;
}
}
use of io.stackgres.operator.conciliation.DeployedResourceDecorator in project stackgres by ongres.
the class BackupDeployedResourceScanner method getDeployedResources.
@Override
public List<HasMetadata> getDeployedResources(StackGresBackup config) {
try (KubernetesClient client = clientFactory.create()) {
final Map<String, String> genericLabels = labelFactory.genericLabels(config);
Stream<HasMetadata> inNamespace = IN_NAMESPACE_RESOURCE_OPERATIONS.values().stream().flatMap(resourceOperationGetter -> resourceOperationGetter.apply(client).inNamespace(config.getMetadata().getNamespace()).withLabels(genericLabels).list().getItems().stream());
List<HasMetadata> deployedResources = inNamespace.filter(resource -> resource.getMetadata().getOwnerReferences().stream().anyMatch(ownerReference -> ownerReference.getKind().equals(StackGresBackup.KIND) && ownerReference.getName().equals(config.getMetadata().getName()) && ownerReference.getUid().equals(config.getMetadata().getUid()))).collect(Collectors.toUnmodifiableList());
deployedResources.forEach(resource -> {
Instance<DeployedResourceDecorator> decorator = decorators.select(new ReconciliationScopeLiteral(StackGresBackup.class, resource.getKind()));
if (decorator.isResolvable()) {
decorator.get().decorate(resource);
}
});
return deployedResources;
}
}
use of io.stackgres.operator.conciliation.DeployedResourceDecorator in project stackgres by ongres.
the class ClusterDeployedResourceScanner method getDeployedResources.
@Override
public List<HasMetadata> getDeployedResources(StackGresCluster config) {
try (KubernetesClient client = clientFactory.create()) {
final Map<String, String> genericClusterLabels = labelFactory.genericLabels(config);
Stream<HasMetadata> inNamespace = IN_NAMESPACE_RESOURCE_OPERATIONS.values().stream().flatMap(resourceOperationGetter -> resourceOperationGetter.apply(client).inNamespace(config.getMetadata().getNamespace()).withLabels(genericClusterLabels).list().getItems().stream());
Stream<HasMetadata> anyNamespace = ANY_NAMESPACE_RESOURCE_OPERATIONS.values().stream().flatMap(resourceOperationGetter -> resourceOperationGetter.apply(client, genericClusterLabels).stream());
List<HasMetadata> deployedResources = Stream.concat(inNamespace, anyNamespace).filter(resource1 -> resource1.getMetadata().getOwnerReferences().stream().anyMatch(ownerReference -> ownerReference.getKind().equals(StackGresCluster.KIND) && ownerReference.getName().equals(config.getMetadata().getName()) && ownerReference.getUid().equals(config.getMetadata().getUid()))).collect(Collectors.toUnmodifiableList());
deployedResources.forEach(resource -> {
Instance<DeployedResourceDecorator> decorator = decorators.select(new ReconciliationScopeLiteral(StackGresCluster.class, resource.getKind()));
if (decorator.isResolvable()) {
decorator.get().decorate(resource);
}
});
return deployedResources;
}
}
Aggregations