-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Strongly typed Datastore configuration - Fixes #2088
- Updates from review - Update datastore config checks touse isBlank() - Update docs
1 parent
9038d5c
commit c34af61
Showing
24 changed files
with
909 additions
and
509 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
Binary file modified
BIN
-1.17 KB
(96%)
docs/site/content/en/docs/Integrations/elasticsearch/modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
40 changes: 36 additions & 4 deletions
40
...-api/src/main/java/io/hyperfoil/tools/horreum/api/data/datastore/BaseDatastoreConfig.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 |
---|---|---|
@@ -1,19 +1,51 @@ | ||
package io.hyperfoil.tools.horreum.api.data.datastore; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.DiscriminatorMapping; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
import io.hyperfoil.tools.horreum.api.data.datastore.auth.APIKeyAuth; | ||
import io.hyperfoil.tools.horreum.api.data.datastore.auth.NoAuth; | ||
import io.hyperfoil.tools.horreum.api.data.datastore.auth.UsernamePassAuth; | ||
|
||
public abstract class BaseDatastoreConfig { | ||
|
||
@Schema(type = SchemaType.BOOLEAN, required = true, description = "Built In") | ||
public Boolean builtIn = true; | ||
@NotNull | ||
@JsonProperty(required = true) | ||
@Schema(type = SchemaType.OBJECT, discriminatorProperty = "type", discriminatorMapping = { | ||
@DiscriminatorMapping(schema = NoAuth.class, value = NoAuth._TYPE), | ||
@DiscriminatorMapping(schema = APIKeyAuth.class, value = APIKeyAuth._TYPE), | ||
@DiscriminatorMapping(schema = UsernamePassAuth.class, value = UsernamePassAuth._TYPE) | ||
}, oneOf = { //subtype mapping for openapi | ||
NoAuth.class, | ||
APIKeyAuth.class, | ||
UsernamePassAuth.class | ||
}) | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | ||
@JsonSubTypes({ //subtype mapping for jackson | ||
@JsonSubTypes.Type(value = NoAuth.class, name = NoAuth._TYPE), | ||
@JsonSubTypes.Type(value = APIKeyAuth.class, name = APIKeyAuth._TYPE), | ||
@JsonSubTypes.Type(value = UsernamePassAuth.class, name = UsernamePassAuth._TYPE) | ||
}) | ||
public Object authentication; //the python generator is failing if this is a concrete type | ||
|
||
public BaseDatastoreConfig() { | ||
} | ||
@Schema(type = SchemaType.BOOLEAN, required = true, description = "Built In") | ||
public Boolean builtIn; | ||
|
||
public BaseDatastoreConfig(Boolean builtIn) { | ||
this.builtIn = builtIn; | ||
} | ||
|
||
public BaseDatastoreConfig() { | ||
this.builtIn = false; | ||
} | ||
|
||
public abstract String validateConfig(); | ||
|
||
} |
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
62 changes: 22 additions & 40 deletions
62
...main/java/io/hyperfoil/tools/horreum/api/data/datastore/ElasticsearchDatastoreConfig.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
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
18 changes: 18 additions & 0 deletions
18
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/datastore/auth/APIKeyAuth.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,18 @@ | ||
package io.hyperfoil.tools.horreum.api.data.datastore.auth; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
public class APIKeyAuth { | ||
public static final String _TYPE = "api-key"; | ||
|
||
@Schema(type = SchemaType.STRING, description = "type") | ||
public String type; | ||
|
||
@Schema(type = SchemaType.STRING, description = "Api key") | ||
public String apiKey; | ||
|
||
public APIKeyAuth() { | ||
this.type = _TYPE; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/datastore/auth/NoAuth.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,15 @@ | ||
package io.hyperfoil.tools.horreum.api.data.datastore.auth; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
public class NoAuth { | ||
public static final String _TYPE = "none"; | ||
|
||
@Schema(type = SchemaType.STRING, description = "type") | ||
public String type; | ||
|
||
public NoAuth() { | ||
this.type = _TYPE; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...pi/src/main/java/io/hyperfoil/tools/horreum/api/data/datastore/auth/UsernamePassAuth.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,21 @@ | ||
package io.hyperfoil.tools.horreum.api.data.datastore.auth; | ||
|
||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
public class UsernamePassAuth { | ||
public static final String _TYPE = "username"; | ||
|
||
@Schema(type = SchemaType.STRING, description = "type") | ||
public String type; | ||
|
||
@Schema(type = SchemaType.STRING, description = "Username") | ||
public String username; | ||
|
||
@Schema(type = SchemaType.STRING, description = "Password") | ||
public String password; | ||
|
||
public UsernamePassAuth() { | ||
this.type = _TYPE; | ||
} | ||
} |
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
24 changes: 0 additions & 24 deletions
24
horreum-backend/src/main/java/io/hyperfoil/tools/horreum/datastore/BackendResolver.java
This file was deleted.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
horreum-backend/src/main/java/io/hyperfoil/tools/horreum/datastore/DatastoreResolver.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,46 @@ | ||
package io.hyperfoil.tools.horreum.datastore; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import io.hyperfoil.tools.horreum.api.data.datastore.DatastoreType; | ||
import io.hyperfoil.tools.horreum.svc.ServiceException; | ||
import io.quarkus.arc.All; | ||
|
||
@ApplicationScoped | ||
public class DatastoreResolver { | ||
@Inject | ||
@All | ||
List<Datastore> datastores; | ||
|
||
public Datastore getDatastore(DatastoreType type) { | ||
return datastores.stream() | ||
.filter(store -> store.type().equals(type)) | ||
.findFirst() | ||
.orElseThrow(() -> new IllegalStateException("Unknown datastore type: " + type)); | ||
} | ||
|
||
public void validatedDatastoreConfig(DatastoreType type, Object config) { | ||
io.hyperfoil.tools.horreum.datastore.Datastore datastoreImpl; | ||
try { | ||
datastoreImpl = this.getDatastore(type); | ||
} catch (IllegalStateException e) { | ||
throw ServiceException.badRequest("Unknown datastore type: " + type | ||
+ ". Please try again, if the problem persists please contact the system administrator."); | ||
} | ||
|
||
if (datastoreImpl == null) { | ||
throw ServiceException.badRequest("Unknown datastore type: " + type); | ||
} | ||
|
||
String error = datastoreImpl.validateConfig(config); | ||
|
||
if (error != null) { | ||
throw ServiceException.badRequest(error); | ||
} | ||
|
||
} | ||
|
||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.
308 changes: 184 additions & 124 deletions
308
horreum-web/src/domain/admin/datastore/ModifyDatastoreModal.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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