Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRILL-8428: ElasticSearch Config Missing Getters #2797

Merged
merged 1 commit into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -39,6 +41,7 @@
import java.util.Optional;

@JsonTypeName(ElasticsearchStorageConfig.NAME)
@JsonInclude(Include.NON_EMPTY)
public class ElasticsearchStorageConfig extends StoragePluginConfig {
public static final String NAME = "elastic";

Expand All @@ -65,18 +68,18 @@ public class ElasticsearchStorageConfig extends StoragePluginConfig {

@JsonCreator
public ElasticsearchStorageConfig(
@JsonProperty(HOSTS) List<String> hosts,
@JsonProperty("hosts") List<String> hosts,
@JsonProperty(USERNAME) String username,
@JsonProperty(PASSWORD) String password,
@JsonProperty(PATH_PREFIX) String pathPrefix,
@JsonProperty("pathPrefix") String pathPrefix,
@JsonProperty("authMode") String authMode,
@JsonProperty("disableSSLVerification") Boolean disableSSLVerification,
@JsonProperty("disableSSLVerification") boolean disableSSLVerification,
@JsonProperty(CREDENTIALS_PROVIDER) CredentialsProvider credentialsProvider) {
super(CredentialProviderUtils.getCredentialsProvider(username, password, credentialsProvider),
credentialsProvider == null, AuthMode.parseOrDefault(authMode, AuthMode.SHARED_USER));
this.hosts = hosts;
this.pathPrefix = pathPrefix;
this.disableSSLVerification = disableSSLVerification == null ? false : disableSSLVerification;
this.disableSSLVerification = disableSSLVerification;
}

private ElasticsearchStorageConfig(ElasticsearchStorageConfig that, CredentialsProvider credentialsProvider) {
Expand All @@ -91,6 +94,21 @@ public ElasticsearchStorageConfig updateCredentialProvider(CredentialsProvider c
return new ElasticsearchStorageConfig(this, credentialsProvider);
}

@JsonProperty("hosts")
public List<String> getHosts() {
return hosts;
}

@JsonProperty("pathPrefix")
public String getPathPrefix() {
return pathPrefix;
}

@JsonProperty("disableSSLVerification")
public boolean getDisableSSLVerification() {
return disableSSLVerification;
}

private static CredentialsProvider getCredentialsProvider(CredentialsProvider credentialsProvider) {
return credentialsProvider != null ? credentialsProvider : PlainCredentialsProvider.EMPTY_CREDENTIALS_PROVIDER;
}
Expand Down Expand Up @@ -123,6 +141,7 @@ public Map<String, Object> toConfigMap()
builder.put(PATH_PREFIX, pathPrefix != null ? pathPrefix : EMPTY_STRING);
builder.put(USERNAME, credentials.getOrDefault(USERNAME, EMPTY_STRING));
builder.put(PASSWORD, credentials.getOrDefault(PASSWORD, EMPTY_STRING));
builder.put(DISABLE_SSL_VERIFICATION, Boolean.valueOf(disableSSLVerification).toString());

credentials.remove(USERNAME);
credentials.remove(PASSWORD);
Expand Down