File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 11package common ;
22
33public final class Args {
4+ public static final String ARGS_JSON = "E2E_ARGS_JSON" ;
45 public static final String ENV = "E2E_ENV" ;
56 public static final String IDENTITY_SCOPE = "E2E_IDENTITY_SCOPE" ;
67 public static final String PHONE_SUPPORT = "E2E_PHONE_SUPPORT" ;
Original file line number Diff line number Diff line change 11package common ;
22
3+ import com .fasterxml .jackson .core .JsonProcessingException ;
4+ import com .fasterxml .jackson .core .type .TypeReference ;
35import org .apache .commons .lang3 .StringUtils ;
46import org .junit .platform .commons .logging .Logger ;
57import org .junit .platform .commons .logging .LoggerFactory ;
68
9+ import java .util .HashMap ;
10+ import java .util .Map ;
11+
712public final class EnvUtil {
813 private static final Logger LOGGER = LoggerFactory .getLogger (EnvUtil .class );
14+ private static final Map <String , String > ARGS ;
15+
16+ static {
17+ try {
18+ String args = getEnv (Args .ARGS_JSON );
19+ TypeReference <HashMap <String ,String >> typeRef = new TypeReference <>() {};
20+ ARGS = Mapper .OBJECT_MAPPER .readValue (args , typeRef );
21+ } catch (JsonProcessingException e ) {
22+ throw new RuntimeException (e );
23+ }
24+ }
925
1026 private EnvUtil () {
1127 }
1228
1329 public static String getEnv (String env ) {
1430 String value = System .getenv (env );
31+ if (StringUtils .isBlank (value )) {
32+ value = ARGS .get (env );
33+ }
34+
1535 if (StringUtils .isBlank (value )) {
1636 LOGGER .error (() -> "Missing environment variable: " + env );
1737 System .exit (1 );
1838 }
39+
1940 return value ;
2041 }
2142}
You can’t perform that action at this time.
0 commit comments