Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit b0bfc02

Browse files
authored
feat: added env var config, improvements (#12)
1 parent 57859ec commit b0bfc02

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<version>${bouncycastle.version}</version>
110110
</dependency>
111111
</dependencies>
112-
112+
113113
<build>
114114
<plugins>
115115
<plugin>

src/main/java/com/csviri/jenvtest/APIServerConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
public class APIServerConfig {
77

8+
public static final String JENVTEST_DOWNLOAD_BINARIES = "JENVTEST_DOWNLOAD_BINARIES";
89
public static final String JENVTEST_DIR_ENV_VAR = "JENVTEST_DIR";
10+
911
public static final String DIRECTORY_NAME = ".jenvtest";
1012

13+
1114
/**
1215
* Set directory where binaries and other assets are present. Default is ~/.jenvtest.
1316
**/
@@ -23,7 +26,6 @@ public class APIServerConfig {
2326
* If true, tries to download binaries. If the apiServerVersion is not set and some local binaries found
2427
* won't try to download them again.
2528
* */
26-
// todo config with env var
2729
private boolean downloadBinaries = true;
2830

2931
public APIServerConfig() {
@@ -33,6 +35,10 @@ public APIServerConfig() {
3335
} else {
3436
this.jenvtestDir = new File(System.getProperty("user.home"), DIRECTORY_NAME).getPath();
3537
}
38+
var downloadBinariesEnvVal = System.getenv(JENVTEST_DOWNLOAD_BINARIES);
39+
if (downloadBinariesEnvVal != null) {
40+
this.downloadBinaries = Boolean.parseBoolean(downloadBinariesEnvVal);
41+
}
3642
}
3743

3844
public String getJenvtestDirectory() {

src/main/java/com/csviri/jenvtest/CertManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void generateAPIServerCertificates() throws IOException, InterruptedExce
5959
if (cert.exists() && key.exists()) {
6060
return;
6161
}
62-
log.debug("Generating API Server certificates");
62+
log.info("Generating API Server certificates");
6363
generateKeyAndCertificate("CN=example.org", new File(jenvtestDir, API_SERVER_KEY_NAME),
6464
new File(jenvtestDir, API_SERVER_CERT_NAME),
6565
new GeneralName(GeneralName.iPAddress, "127.0.0.1"),
@@ -78,7 +78,7 @@ private void generateUserCertificates() throws IOException, InterruptedException
7878
if (cert.exists() && key.exists()) {
7979
return;
8080
}
81-
log.debug("Generating Client certificates");
81+
log.info("Generating Client certificates");
8282
generateKeyAndCertificate("O=system:masters,CN=jenvtest", new File(jenvtestDir, CLIENT_KEY_NAME),
8383
new File(jenvtestDir, CLIENT_CERT_NAME));
8484
}

src/main/java/com/csviri/jenvtest/junit/EnableAPIServer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@
1313
@Retention(RUNTIME)
1414
public @interface EnableAPIServer {
1515

16-
// version API Server
17-
// version etcd
1816
}

0 commit comments

Comments
 (0)