Skip to content

Commit e64db24

Browse files
author
Or Noyman
authored
Vault: add a fluent API for configuring Vault's logging level (#2231)
1 parent 0ac9689 commit e64db24

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.HashMap;
1111
import java.util.List;
1212
import java.util.Map;
13+
import java.util.function.Consumer;
1314

1415
import static com.github.dockerjava.api.model.Capability.IPC_LOCK;
1516

@@ -106,6 +107,17 @@ public SELF withVaultPort(int port) {
106107
return self();
107108
}
108109

110+
/**
111+
* Sets the logging level for the Vault server in the container.
112+
* Logs can be consumed through {@link #withLogConsumer(Consumer)}.
113+
*
114+
* @param level the logging level to set for Vault.
115+
* @return this
116+
*/
117+
public SELF withLogLevel(VaultLogLevel level) {
118+
return withEnv("VAULT_LOG_LEVEL", level.config);
119+
}
120+
109121
/**
110122
* Pre-loads secrets into Vault container. User may specify one or more secrets and all will be added to each path
111123
* that is specified. Thus this can be called more than once for multiple paths to be added to Vault.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.testcontainers.vault;
2+
3+
/**
4+
* Vault preset of logging levels.
5+
*/
6+
public enum VaultLogLevel {
7+
Trace("trace"), Debug("debug"), Info("info"), Warn("warn"), Error("err");
8+
9+
public final String config;
10+
11+
VaultLogLevel(String config) {
12+
this.config = config;
13+
}
14+
}

0 commit comments

Comments
 (0)