Skip to content

Commit

Permalink
Use ocp token instead of password (#23)
Browse files Browse the repository at this point in the history
* Use ocp token instead of password

Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>

* Remove unused username

Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>

---------

Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
  • Loading branch information
Frawless authored Nov 13, 2023
1 parent 4609fab commit 58ed9a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
9 changes: 3 additions & 6 deletions src/main/java/io/tealc/ClusterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public static synchronized ClusterManager getInstance() {
}

Config config = new ConfigBuilder()
.withUsername(Environment.WORKER_01_USERNAME)
.withPassword(Environment.WORKER_01_PASSWORD)
.withOauthToken(Environment.WORKER_01_TOKEN)
.withMasterUrl(Environment.WORKER_01_URL)
.withDisableHostnameVerification(true)
.withTrustCerts(true)
Expand All @@ -31,8 +30,7 @@ public static synchronized ClusterManager getInstance() {
CLIENTS.put(EClusters.WORKER_01, new KubeClient(config, "default"));

config = new ConfigBuilder()
.withUsername(Environment.WORKER_02_USERNAME)
.withPassword(Environment.WORKER_02_PASSWORD)
.withOauthToken(Environment.WORKER_02_TOKEN)
.withMasterUrl(Environment.WORKER_02_URL)
.withDisableHostnameVerification(true)
.withTrustCerts(true)
Expand All @@ -41,8 +39,7 @@ public static synchronized ClusterManager getInstance() {
CLIENTS.put(EClusters.WORKER_02, new KubeClient(config, "default"));

config = new ConfigBuilder()
.withUsername(Environment.WORKER_03_USERNAME)
.withPassword(Environment.WORKER_03_PASSWORD)
.withOauthToken(Environment.WORKER_03_TOKEN)
.withMasterUrl(Environment.WORKER_03_URL)
.withDisableHostnameVerification(true)
.withTrustCerts(true)
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/io/tealc/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@ public class Environment {
private static final Logger LOGGER = LoggerFactory.getLogger(Environment.class);
private static final Map<String, String> VALUES = new HashMap<>();

public static final String WORKER_01_USERNAME_ENV = "WORKER_01_USERNAME";
public static final String WORKER_01_PASSWORD_ENV = "WORKER_01_PASSWORD";
public static final String WORKER_01_TOKEN_ENV = "WORKER_01_OCP_TOKEN";
public static final String WORKER_01_URL_ENV = "WORKER_01_URL";
public static final String WORKER_02_USERNAME_ENV = "WORKER_02_USERNAME";
public static final String WORKER_02_PASSWORD_ENV = "WORKER_02_PASSWORD";
public static final String WORKER_02_TOKEN_ENV = "WORKER_02_OCP_TOKEN";
public static final String WORKER_02_URL_ENV = "WORKER_02_URL";
public static final String WORKER_03_USERNAME_ENV = "WORKER_03_USERNAME";
public static final String WORKER_03_PASSWORD_ENV = "WORKER_03_PASSWORD";
public static final String WORKER_03_TOKEN_ENV = "WORKER_03_OCP_TOKEN";
public static final String WORKER_03_URL_ENV = "WORKER_03_URL";

/**
* Set values
*/
public static final String WORKER_01_USERNAME = getOrDefault(WORKER_01_USERNAME_ENV, null);
public static final String WORKER_01_PASSWORD = getOrDefault(WORKER_01_PASSWORD_ENV, null);
public static final String WORKER_01_TOKEN = getOrDefault(WORKER_01_TOKEN_ENV, null);
public static final String WORKER_01_URL = getOrDefault(WORKER_01_URL_ENV, null);
public static final String WORKER_02_USERNAME = getOrDefault(WORKER_02_USERNAME_ENV, null);
public static final String WORKER_02_PASSWORD = getOrDefault(WORKER_02_PASSWORD_ENV, null);
public static final String WORKER_02_TOKEN = getOrDefault(WORKER_02_TOKEN_ENV, null);
public static final String WORKER_02_URL = getOrDefault(WORKER_02_URL_ENV, null);
public static final String WORKER_03_USERNAME = getOrDefault(WORKER_03_USERNAME_ENV, null);
public static final String WORKER_03_PASSWORD = getOrDefault(WORKER_03_PASSWORD_ENV, null);
public static final String WORKER_03_TOKEN = getOrDefault(WORKER_03_TOKEN_ENV, null);
public static final String WORKER_03_URL = getOrDefault(WORKER_03_URL_ENV, null);

private Environment() { }
Expand Down

0 comments on commit 58ed9a1

Please sign in to comment.