-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): only allow KV to be created for an existing namespace (#4522)
Fix: #4522
- Loading branch information
1 parent
3e7f059
commit 6b6b01d
Showing
19 changed files
with
380 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core/src/main/java/io/kestra/core/services/NamespaceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.kestra.core.services; | ||
|
||
import io.kestra.core.repositories.FlowRepositoryInterface; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@Singleton | ||
public class NamespaceService { | ||
|
||
private final FlowRepositoryInterface flowRepository; | ||
|
||
@Inject | ||
public NamespaceService(FlowRepositoryInterface flowRepository) { | ||
this.flowRepository = flowRepository; | ||
} | ||
|
||
/** | ||
* Checks whether a given namespace exists. | ||
* | ||
* @param tenant The tenant ID | ||
* @param namespace The namespace - cannot be null. | ||
* @return {@code true} if the namespace exist. Otherwise {@link false}. | ||
*/ | ||
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)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.