Skip to content

Commit

Permalink
Updated parent pom, clean up vault-config classes
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-v committed Oct 6, 2024
1 parent 19aa382 commit 6d753c3
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 40 deletions.
2 changes: 1 addition & 1 deletion config-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-config-parent</artifactId>
<version>0.4.21-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>scalecube-config-examples</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ private KubernetesVaultTokenSupplier(Builder builder) {
Objects.requireNonNull(builder.serviceAccountTokenPath, "k8s service account token path");
}

public static Builder builder() {
return new Builder();
}

@Override
public String getToken(VaultConfig config) {
try (Stream<String> stream = Files.lines(Paths.get(serviceAccountTokenPath))) {
Expand Down Expand Up @@ -59,7 +55,7 @@ public static class Builder {
Optional.ofNullable(ENVIRONMENT_LOADER.loadVariable("SERVICE_ACCOUNT_TOKEN_PATH"))
.orElse("/var/run/secrets/kubernetes.io/serviceaccount/token");

private Builder() {}
public Builder() {}

public Builder vaultRole(String vaultRole) {
this.vaultRole = vaultRole;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ private String getToken0() {
+ "ignoring EnvironmentVaultTokenSupplier "
+ "(specify either vaultToken or vaultRole, not both)");
}
vaultTokenSupplier = KubernetesVaultTokenSupplier.builder().vaultRole(vaultRole).build();
vaultTokenSupplier =
new KubernetesVaultTokenSupplier.Builder().vaultRole(vaultRole).build();
vaultConfig = new VaultConfig().address(vaultAddress).build();
} else {
vaultTokenSupplier = new EnvironmentVaultTokenSupplier();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public Map<String, ConfigProperty> loadConfig() {
return result;
}

public static Builder builder() {
return new Builder();
}

public static final class Builder {

private Function<VaultInvoker.Builder, VaultInvoker.Builder> builderFunction =
Expand All @@ -90,7 +86,7 @@ public static final class Builder {
.map(HashSet::new)
.orElseGet(HashSet::new);

private Builder() {}
public Builder() {}

/**
* Appends {@code secretsPath} to {@code secretsPaths}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public class VaultInvoker {
private Vault vault;
private Timer timer;

public static Builder builder() {
return new Builder();
}

private VaultInvoker(Builder builder) {
this.builder = builder;
}
Expand Down Expand Up @@ -221,6 +217,8 @@ public static class Builder {

private VaultTokenSupplier tokenSupplier = new EnvironmentVaultTokenSupplier();

public Builder() {}

public Builder options(UnaryOperator<VaultConfig> config) {
this.options = this.options.andThen(config);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static VaultInvoker newVaultInvoker() {
}

final VaultInvoker.Builder builder =
VaultInvoker.builder()
new VaultInvoker.Builder()
.options(config -> config.address(vaultAddr).engineVersion(vaultEngineVersion));

if (!isNullOrNone(vaultRole)) {
Expand All @@ -72,7 +72,7 @@ public static VaultInvoker newVaultInvoker() {
+ "ignoring EnvironmentVaultTokenSupplier "
+ "(specify either VAULT_ROLE or VAULT_TOKEN, not both)");
}
builder.tokenSupplier(KubernetesVaultTokenSupplier.builder().build());
builder.tokenSupplier(new KubernetesVaultTokenSupplier.Builder().build());
} else {
builder.tokenSupplier(new EnvironmentVaultTokenSupplier());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void beforeAll() {
@Test
void testFirstTenant() {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand All @@ -70,7 +70,7 @@ void testFirstTenant() {
@Test
void testSecondTenant() {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH2)
Expand All @@ -87,7 +87,7 @@ void testSecondTenant() {
@Test
void testMultiplePathsEnv() {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1 + ":" + VAULT_SECRETS_PATH2)
Expand Down Expand Up @@ -120,7 +120,7 @@ void testMultiplePathsEnv() {
@Test
void testMissingProperty() {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH3)
Expand All @@ -135,7 +135,7 @@ void testMissingProperty() {

@Test
void testMissingTenant() {
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath("secrets/unknown/path")
Expand All @@ -145,7 +145,7 @@ void testMissingTenant() {
@Test
void testInvalidAddress() {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address("http://invalid.host.local:8200"))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand All @@ -157,7 +157,7 @@ void testInvalidAddress() {
@Test
void testInvalidToken() {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token("zzzzzz"))
.config(c -> c.address("http://invalid.host.local:8200"))
.addSecretsPath("secrets/unknown/path")
Expand All @@ -178,7 +178,7 @@ void shouldWorkWhenRegistryIsReloadedAndVaultIsRunning() throws InterruptedExcep
ConfigRegistrySettings.builder()
.addLastSource(
"vault",
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(vaultConfig -> vaultConfig.address(address).token(rootToken))
.addSecretsPath(VAULT_SECRETS_PATH1)
.build())
Expand Down Expand Up @@ -212,7 +212,7 @@ void shouldWorkWhenRegistryIsReloadedAndVaultIsDown() {
ConfigRegistrySettings.builder()
.addLastSource(
"vault",
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(vaultConfig -> vaultConfig.address(address).token(rootToken))
.addSecretsPath(VAULT_SECRETS_PATH1)
.build())
Expand Down Expand Up @@ -244,7 +244,7 @@ void testSealed() throws Throwable {
vault.seal().seal();
assumeTrue(vault.seal().sealStatus().getSealed(), "vault seal status");

VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token("ROOT"))
.config(c -> c.address(vaultInstance.address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand All @@ -271,7 +271,7 @@ void shouldWorkWhenRegistryIsReloadedAndVaultIsUnSealed() throws InterruptedExce
ConfigRegistrySettings.builder()
.addLastSource(
"vault",
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(vaultConfig -> vaultConfig.address(address).token(rootToken))
.secretsPath(VAULT_SECRETS_PATH1)
.build())
Expand Down Expand Up @@ -319,7 +319,7 @@ void testRenewableToken() throws InterruptedException {
.getAuthClientToken();

VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand Down Expand Up @@ -347,7 +347,7 @@ void testNonrenewableToken() {
.getAuthClientToken();

VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand Down Expand Up @@ -385,7 +385,7 @@ void testRenewableTokenWithExplicitMaxTtl() {
.getAuthClientToken();

VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand Down Expand Up @@ -423,7 +423,7 @@ void testRenewableTokenWithUseLimit() {
.getAuthClientToken();

VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand All @@ -449,7 +449,7 @@ void testRenewableTokenWithUseLimit() {
@Test
void testTokenSupplierGeneratesNewRenewableTokenWithExplicitMaxTtl() throws Exception {
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand Down Expand Up @@ -482,7 +482,7 @@ void testRenewableTokenWhichWillBeRevoked() {
.getAuthClientToken();

VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand Down Expand Up @@ -515,7 +515,7 @@ void testRenewableTokenWhichWillBeRevoked() {
void testTokenSupplierGeneratesNewRenewableTokenWhichWillBeRevoked() throws Exception {
AtomicReference<String> tokenRef = new AtomicReference<>();
VaultConfigSource vaultConfigSource =
VaultConfigSource.builder()
new VaultConfigSource.Builder()
.config(c -> c.token(vaultContainerExtension.vaultInstance().rootToken()))
.config(c -> c.address(vaultContainerExtension.vaultInstance().address()))
.addSecretsPath(VAULT_SECRETS_PATH1)
Expand Down
6 changes: 3 additions & 3 deletions config/pom.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-config-parent</artifactId>
<version>0.4.21-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>scalecube-config</artifactId>

Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.scalecube</groupId>
<artifactId>scalecube-parent</artifactId>
<version>0.2.21.test.rc3</version>
<version>0.2.21.test.rc4</version>
</parent>

<artifactId>scalecube-config-parent</artifactId>
Expand Down Expand Up @@ -52,6 +52,7 @@

<distributionManagement.url>https://maven.pkg.github.com/scalecube/scalecube-config
</distributionManagement.url>
<checkstyle.suppressions.location>checkstyle-suppressions.xml</checkstyle.suppressions.location>
</properties>

<modules>
Expand Down

0 comments on commit 6d753c3

Please sign in to comment.