Skip to content

Commit a92f25c

Browse files
Created secrets.
1 parent 650c657 commit a92f25c

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

src/main/java/io/swaglabs/portal/qa/utils/WebConfigLoader.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package io.swaglabs.portal.qa.utils;
22

3+
import lombok.extern.slf4j.Slf4j;
4+
35
import java.util.Objects;
46
import java.util.Properties;
57

8+
@Slf4j
69
public class WebConfigLoader {
710

811
private static WebConfigLoader instance;
@@ -24,15 +27,33 @@ public static WebConfigLoader getInstance() {
2427
}
2528

2629
public String getSwagLabsUrl() {
27-
return getPropertyValue("swaglabs.url");
30+
String url = System.getenv("SWAGLABS_URL");
31+
if (url == null || url.isEmpty()) {
32+
log.info("Environment variable SWAGLABS_URL is not set, falling back to properties file.");
33+
url = getPropertyValue("swaglabs.url");
34+
}
35+
log.info("SwagLabs URL picked from github secrets.");
36+
return url;
2837
}
2938

3039
public String getSwagLabsUserName() {
31-
return getPropertyValue("swaglabs.username");
40+
String username = System.getenv("SWAGLABS_USERNAME");
41+
if (username == null || username.isEmpty()) {
42+
log.info("Environment variable SWAGLABS_USERNAME is not set, falling back to properties file.");
43+
username = getPropertyValue("swaglabs.username");
44+
}
45+
log.info("SwagLabs Username picked from github secrets.");
46+
return username;
3247
}
3348

3449
public String getSwagLabsPassword() {
35-
return getPropertyValue("swaglabs.password");
50+
String password = System.getenv("SWAGLABS_PASSWORD");
51+
if (password == null || password.isEmpty()) {
52+
log.info("Environment variable SWAGLABS_PASSWORD is not set, falling back to properties file.");
53+
password = getPropertyValue("swaglabs.password");
54+
}
55+
log.info("SwagLabs Password picked from github secrets.");
56+
return password;
3657
}
3758

3859
private String getPropertyValue(String propertyKey) {

0 commit comments

Comments
 (0)