Skip to content

Commit

Permalink
fix(core): make flow repository an optional bean
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois committed Aug 5, 2024
1 parent 4e7298a commit 0cc8ada
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/src/main/java/io/kestra/core/services/NamespaceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import java.util.List;
import java.util.Objects;
import java.util.Optional;

@Singleton
public class NamespaceService {

private final FlowRepositoryInterface flowRepository;
private final Optional<FlowRepositoryInterface> flowRepository;

@Inject
public NamespaceService(FlowRepositoryInterface flowRepository) {
public NamespaceService(Optional<FlowRepositoryInterface> flowRepository) {
this.flowRepository = flowRepository;
}

Expand All @@ -27,8 +28,10 @@ public NamespaceService(FlowRepositoryInterface flowRepository) {
public boolean isNamespaceExists(String tenant, String namespace) {
Objects.requireNonNull(namespace, "namespace cannot be null");

List<String> namespaces = flowRepository.findDistinctNamespace(tenant);
return namespaces.stream().anyMatch(ns -> ns.equals(namespace));
if (flowRepository.isPresent()) {
List<String> namespaces = flowRepository.get().findDistinctNamespace(tenant);
return namespaces.stream().anyMatch(ns -> ns.equals(namespace));
}
return false;
}

}

0 comments on commit 0cc8ada

Please sign in to comment.