Skip to content

Commit

Permalink
Merge pull request #208 from scalecube/cleanup-dependencies
Browse files Browse the repository at this point in the history
Updated scalecube-parent to use jdk17. Get rid of dependency on slf4j. Cleanup and update vault-config classes.
  • Loading branch information
artem-v authored Oct 7, 2024
2 parents 6581952 + 3e7500b commit a2d19f0
Show file tree
Hide file tree
Showing 24 changed files with 439 additions and 208 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/branch-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ jobs:
name: Branch CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: 17
distribution: zulu
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
- name: Maven Build
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -Ddockerfile.skip=true -B -V
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
env:
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }}
- name: Maven Verify
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/pre-release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ jobs:
name: Pre-release CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: 17
distribution: zulu
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
Expand All @@ -33,9 +34,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }}
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: 17
distribution: zulu
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,26 @@ jobs:
name: Release CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git checkout ${{ github.event.release.target_commitish }}
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: 17
distribution: zulu
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
- name: Maven Build
run: mvn clean install -DskipTests=true -Ddockerfile.skip=true -B -V
run: mvn clean install -DskipTests=true -B -V
env:
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }}
- name: Maven Verify
Expand All @@ -41,17 +42,18 @@ jobs:
run: |
mvn -B build-helper:parse-version release:prepare \
-DreleaseVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion} \
-Darguments="-DskipTests=true -Ddockerfile.skip=true"
-Darguments="-DskipTests=true"
echo release_tag=$(git describe --tags --abbrev=0) >> $GITHUB_OUTPUT
- name: Perform release
run: mvn -B release:perform -Pdeploy2Github -Darguments="-DskipTests=true -Ddockerfile.skip=true -Pdeploy2Github"
run: mvn -B release:perform -Pdeploy2Github -Darguments="-DskipTests=true -Pdeploy2Github"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: 17
distribution: zulu
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
14 changes: 14 additions & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
"https://checkstyle.org/dtds/suppressions_1_0.dtd">


<suppressions>
<suppress checks="AbbreviationAsWordInName" files=".*"/>
<suppress checks="MissingJavadocTypeCheck" files=".*"/>
<suppress checks="MissingJavadocMethodCheck" files=".*"/>
<suppress checks="MissingSwitchDefault" files=".*"/>
<suppress checks="VariableDeclarationUsageDistance" files=".*"/>
</suppressions>
14 changes: 12 additions & 2 deletions config-examples/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +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">
<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 All @@ -16,6 +18,14 @@
<artifactId>scalecube-config</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jpl</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.scalecube.config.ConfigRegistry;
import io.scalecube.config.ConfigRegistrySettings;
import io.scalecube.config.StringConfigProperty;
import io.scalecube.config.audit.Slf4JConfigEventListener;
import io.scalecube.config.audit.LoggingConfigEventListener;
import io.scalecube.config.source.ClassPathConfigSource;
import io.scalecube.config.source.FileDirectoryConfigSource;
import java.nio.file.Path;
Expand All @@ -28,7 +28,7 @@ public static void main(String[] args) {
.addLastSource("classpath", new ClassPathConfigSource(propsPredicate))
.addLastSource(
"configDirectory", new FileDirectoryConfigSource(basePath, propsPredicate))
.addListener(new Slf4JConfigEventListener())
.addListener(new LoggingConfigEventListener())
.jmxEnabled(true)
.jmxMBeanName("config.exporter:name=ConfigRegistry")
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io.scalecube.config.ConfigRegistry;
import io.scalecube.config.ConfigRegistrySettings;
import io.scalecube.config.StringConfigProperty;
import io.scalecube.config.audit.Slf4JConfigEventListener;
import io.scalecube.config.audit.LoggingConfigEventListener;
import io.scalecube.config.source.FileDirectoryConfigSource;
import java.nio.file.Path;
import java.util.function.Predicate;
Expand Down Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) {
ConfigRegistrySettings.builder()
.addLastSource(
"ConfigDirectory", new FileDirectoryConfigSource(basePath, propsPredicate))
.addListener(new Slf4JConfigEventListener())
.addListener(new LoggingConfigEventListener())
.keepRecentConfigEvents(10)
.reloadIntervalSec(3)
.jmxEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.scalecube.config.ListConfigProperty;
import io.scalecube.config.ObjectConfigProperty;
import io.scalecube.config.StringConfigProperty;
import io.scalecube.config.audit.Slf4JConfigEventListener;
import io.scalecube.config.audit.LoggingConfigEventListener;
import io.scalecube.config.source.FileDirectoryConfigSource;
import java.io.BufferedWriter;
import java.io.File;
Expand Down Expand Up @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception {
basePath,
Stream.of(reloadablePropsPredicate, propsPredicate)
.collect(Collectors.toList())))
.addListener(new Slf4JConfigEventListener())
.addListener(new LoggingConfigEventListener())
.reloadIntervalSec(1)
.build());

Expand Down
10 changes: 3 additions & 7 deletions config-vault/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?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">
<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>
Expand All @@ -20,12 +22,6 @@
<groupId>com.bettercloud</groupId>
<artifactId>vault-java-driver</artifactId>
</dependency>
<!-- Tests -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>vault</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,19 @@ public class KubernetesVaultTokenSupplier implements VaultTokenSupplier {

private static final EnvironmentLoader ENVIRONMENT_LOADER = new EnvironmentLoader();

private String vaultRole = ENVIRONMENT_LOADER.loadVariable("VAULT_ROLE");
private final String vaultRole;
private final String vaultJwtProvider;
private final String serviceAccountTokenPath;

private String vaultJwtProvider =
Optional.ofNullable(
Optional.ofNullable(ENVIRONMENT_LOADER.loadVariable("VAULT_JWT_PROVIDER"))
.orElse(ENVIRONMENT_LOADER.loadVariable("VAULT_MOUNT_POINT")))
.orElse("kubernetes");

private String serviceAccountTokenPath =
Optional.ofNullable(ENVIRONMENT_LOADER.loadVariable("SERVICE_ACCOUNT_TOKEN_PATH"))
.orElse("/var/run/secrets/kubernetes.io/serviceaccount/token");

public KubernetesVaultTokenSupplier vaultRole(String vaultRole) {
this.vaultRole = vaultRole;
return this;
}

public KubernetesVaultTokenSupplier vaultJwtProvider(String vaultJwtProvider) {
this.vaultJwtProvider = vaultJwtProvider;
return this;
}

public KubernetesVaultTokenSupplier serviceAccountTokenPath(String serviceAccountTokenPath) {
this.serviceAccountTokenPath = serviceAccountTokenPath;
return this;
private KubernetesVaultTokenSupplier(Builder builder) {
this.vaultRole = Objects.requireNonNull(builder.vaultRole, "vault role");
this.vaultJwtProvider = Objects.requireNonNull(builder.vaultJwtProvider, "jwt provider");
this.serviceAccountTokenPath =
Objects.requireNonNull(builder.serviceAccountTokenPath, "k8s service account token path");
}

@Override
public String getToken(VaultConfig config) {
Objects.requireNonNull(vaultRole, "vault role");
Objects.requireNonNull(vaultJwtProvider, "jwt provider");
Objects.requireNonNull(serviceAccountTokenPath, "k8s service account token path");
try (Stream<String> stream = Files.lines(Paths.get(serviceAccountTokenPath))) {
String jwt = stream.collect(Collectors.joining());
return Objects.requireNonNull(
Expand All @@ -59,4 +40,40 @@ public String getToken(VaultConfig config) {
throw ThrowableUtil.propagate(e);
}
}

public static class Builder {

private String vaultRole = ENVIRONMENT_LOADER.loadVariable("VAULT_ROLE");

private String vaultJwtProvider =
Optional.ofNullable(
Optional.ofNullable(ENVIRONMENT_LOADER.loadVariable("VAULT_JWT_PROVIDER"))
.orElse(ENVIRONMENT_LOADER.loadVariable("VAULT_MOUNT_POINT")))
.orElse("kubernetes");

private String serviceAccountTokenPath =
Optional.ofNullable(ENVIRONMENT_LOADER.loadVariable("SERVICE_ACCOUNT_TOKEN_PATH"))
.orElse("/var/run/secrets/kubernetes.io/serviceaccount/token");

public Builder() {}

public Builder vaultRole(String vaultRole) {
this.vaultRole = vaultRole;
return this;
}

public Builder vaultJwtProvider(String vaultJwtProvider) {
this.vaultJwtProvider = vaultJwtProvider;
return this;
}

public Builder serviceAccountTokenPath(String serviceAccountTokenPath) {
this.serviceAccountTokenPath = serviceAccountTokenPath;
return this;
}

public KubernetesVaultTokenSupplier build() {
return new KubernetesVaultTokenSupplier(this);
}
}
}
Loading

0 comments on commit a2d19f0

Please sign in to comment.