Skip to content

Commit 217b6b7

Browse files
author
Julien Ruaux
committed
build: Fixed Docker image env variables
1 parent 77527a8 commit 217b6b7

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

docker/template/redisearch.properties.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
connector.name=redisearch
2-
redisearch.uri=${REDISEARCH_USERNAME}
2+
redisearch.uri=${REDISEARCH_URI}
33
redisearch.username=${REDISEARCH_USERNAME}
44
redisearch.password=${REDISEARCH_PASSWORD}
55
redisearch.cluster=${REDISEARCH_CLUSTER}

src/main/java/com/redis/trino/RediSearchConfig.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
package com.redis.trino;
2525

26-
import java.io.File;
2726
import java.time.Duration;
2827
import java.util.Optional;
2928

@@ -34,7 +33,6 @@
3433
import io.airlift.configuration.Config;
3534
import io.airlift.configuration.ConfigDescription;
3635
import io.airlift.configuration.ConfigSecuritySensitive;
37-
import io.airlift.configuration.validation.FileExists;
3836

3937
public class RediSearchConfig {
4038

@@ -55,9 +53,9 @@ public class RediSearchConfig {
5553
private long tableCacheExpiration = DEFAULT_TABLE_CACHE_EXPIRATION.toSeconds();
5654
private long tableCacheRefresh = DEFAULT_TABLE_CACHE_REFRESH.toSeconds();
5755
private boolean cluster;
58-
private File caCertPath;
59-
private File keyPath;
60-
private File certPath;
56+
private String caCertPath;
57+
private String keyPath;
58+
private String certPath;
6159
private String keyPassword;
6260

6361
@Min(0)
@@ -186,25 +184,32 @@ public RediSearchConfig setInsecure(boolean insecure) {
186184
return this;
187185
}
188186

189-
public Optional<@FileExists File> getCaCertPath() {
190-
return Optional.ofNullable(caCertPath);
187+
public Optional<String> getCaCertPath() {
188+
return optionalPath(caCertPath);
189+
}
190+
191+
private Optional<String> optionalPath(String path) {
192+
if (path == null || path.isEmpty()) {
193+
return Optional.empty();
194+
}
195+
return Optional.of(path);
191196
}
192197

193198
@Config("redisearch.cacert-path")
194199
@ConfigDescription("X.509 CA certificate file to verify with")
195-
public RediSearchConfig setCaCertPath(File path) {
196-
this.caCertPath = path;
200+
public RediSearchConfig setCaCertPath(String caCertPath) {
201+
this.caCertPath = caCertPath;
197202
return this;
198203
}
199204

200-
public Optional<@FileExists File> getKeyPath() {
201-
return Optional.ofNullable(keyPath);
205+
public Optional<String> getKeyPath() {
206+
return optionalPath(keyPath);
202207
}
203208

204209
@Config("redisearch.key-path")
205210
@ConfigDescription("PKCS#8 private key file to authenticate with (PEM format)")
206-
public RediSearchConfig setKeyPath(File path) {
207-
this.keyPath = path;
211+
public RediSearchConfig setKeyPath(String keyPath) {
212+
this.keyPath = keyPath;
208213
return this;
209214
}
210215

@@ -215,19 +220,19 @@ public Optional<String> getKeyPassword() {
215220
@Config("redisearch.key-password")
216221
@ConfigSecuritySensitive
217222
@ConfigDescription("Password of the private key file, or null if it's not password-protected")
218-
public RediSearchConfig setKeyPassword(String password) {
219-
this.keyPassword = password;
223+
public RediSearchConfig setKeyPassword(String keyPassword) {
224+
this.keyPassword = keyPassword;
220225
return this;
221226
}
222227

223-
public Optional<@FileExists File> getCertPath() {
224-
return Optional.ofNullable(certPath);
228+
public Optional<String> getCertPath() {
229+
return optionalPath(certPath);
225230
}
226231

227232
@Config("redisearch.cert-path")
228233
@ConfigDescription("X.509 certificate chain file to authenticate with (PEM format)")
229-
public RediSearchConfig setCertPath(File path) {
230-
this.certPath = path;
234+
public RediSearchConfig setCertPath(String certPath) {
235+
this.certPath = certPath;
231236
return this;
232237
}
233238

src/main/java/com/redis/trino/RediSearchSession.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import static java.util.Locale.ENGLISH;
3333
import static java.util.Objects.requireNonNull;
3434

35+
import java.io.File;
3536
import java.util.Collections;
3637
import java.util.HashSet;
3738
import java.util.List;
@@ -113,10 +114,10 @@ public RediSearchSession(TypeManager typeManager, RediSearchConfig config) {
113114
private AbstractRedisClient client(RediSearchConfig config) {
114115
ClientBuilder builder = ClientBuilder.create(redisURI(config));
115116
builder.cluster(config.isCluster());
116-
builder.key(config.getKeyPath());
117-
config.getCertPath().ifPresent(builder::keyCert);
117+
config.getKeyPath().map(File::new).ifPresent(builder::key);
118+
config.getCertPath().map(File::new).ifPresent(builder::keyCert);
118119
config.getKeyPassword().ifPresent(p -> builder.keyPassword(p.toCharArray()));
119-
builder.trustManager(config.getCaCertPath());
120+
config.getCaCertPath().map(File::new).ifPresent(builder::trustManager);
120121
return builder.build();
121122
}
122123

0 commit comments

Comments
 (0)