8
8
import java .nio .file .Path ;
9
9
import java .nio .file .Paths ;
10
10
import java .util .ArrayList ;
11
- import java .util .HashMap ;
12
- import java .util .List ;
13
11
import java .util .Map ;
14
12
import java .util .logging .Logger ;
15
13
import oracle .kubernetes .operator .BaseTest ;
@@ -95,7 +93,7 @@ public Operator(
95
93
RESTCertType restCertType )
96
94
throws Exception {
97
95
this .restCertType = restCertType ;
98
- initializeCustom (inputMap , opNS , opSA , targetdomainNS );
96
+ initialize (inputMap , opNS , opSA , targetdomainNS );
99
97
generateInputYaml ();
100
98
}
101
99
/**
@@ -107,7 +105,7 @@ public Operator(
107
105
*/
108
106
public Operator (Map <String , Object > inputMap , RESTCertType restCertType ) throws Exception {
109
107
this .restCertType = restCertType ;
110
- initializeCustom (inputMap , true , true , true );
108
+ initialize (inputMap , true , true , true );
111
109
generateInputYaml ();
112
110
}
113
111
@@ -390,101 +388,10 @@ private void runCommandInLoop(String command) throws Exception {
390
388
}
391
389
392
390
private void initialize (String inputYaml ) throws Exception {
393
- operatorMap = TestUtils .loadYaml (inputYaml );
394
- userProjectsDir = BaseTest .getUserProjectsDir ();
395
- operatorNS = (String ) operatorMap .getOrDefault ("namespace" , operatorNS );
396
-
397
- if (operatorMap .get ("releaseName" ) == null ) {
398
- throw new RuntimeException ("FAILURE: releaseName cann't be null" );
399
- }
400
- // customize the inputs yaml file to generate a self-signed cert for the external Operator REST
401
- // https port
402
- externalRestEnabled =
403
- (boolean ) operatorMap .getOrDefault ("externalRestEnabled" , externalRestEnabled );
404
- if (externalRestEnabled ) {
405
- if (operatorMap .get ("externalRestHttpsPort" ) != null ) {
406
- try {
407
- externalRestHttpsPort = ((Integer ) operatorMap .get ("externalRestHttpsPort" )).intValue ();
408
-
409
- } catch (NumberFormatException nfe ) {
410
- throw new IllegalArgumentException (
411
- "FAILURE: Invalid value for " + "externalRestHttpsPort " + externalRestHttpsPort );
412
- }
413
- } else {
414
- operatorMap .put ("externalRestHttpsPort" , externalRestHttpsPort );
415
- }
416
- }
417
-
418
- // customize the inputs yaml file to use our pre-built docker image
419
- // IMAGE_NAME_OPERATOR & IMAGE_TAG_OPERATOR variables are used for wercker
420
- if (System .getenv ("IMAGE_NAME_OPERATOR" ) != null
421
- && System .getenv ("IMAGE_TAG_OPERATOR" ) != null ) {
422
- operatorMap .put (
423
- "image" ,
424
- System .getenv ("IMAGE_NAME_OPERATOR" ) + ":" + System .getenv ("IMAGE_TAG_OPERATOR" ));
425
- } else {
426
- operatorMap .put (
427
- "image" ,
428
- "wlsldi-v2.docker.oraclecorp.com/weblogic-operator"
429
- + ":test_"
430
- + BaseTest .getBranchName ().replaceAll ("/" , "_" ));
431
- }
432
-
433
- if (System .getenv ("IMAGE_PULL_POLICY_OPERATOR" ) != null ) {
434
- operatorMap .put ("imagePullPolicy" , System .getenv ("IMAGE_PULL_POLICY_OPERATOR" ));
435
- }
436
-
437
- ExecCommand .exec ("kubectl delete namespace " + operatorNS );
438
-
439
- // create opeartor namespace
440
- ExecCommand .exec ("kubectl create namespace " + operatorNS );
441
-
442
- // create operator service account
443
- String serviceAccount = (String ) operatorMap .get ("serviceAccount" );
444
- if (serviceAccount != null && !serviceAccount .equals ("default" )) {
445
- ExecResult result =
446
- ExecCommand .exec ("kubectl create serviceaccount " + serviceAccount + " -n " + operatorNS );
447
- if (result .exitValue () != 0 ) {
448
- throw new RuntimeException (
449
- "FAILURE: Couldn't create serviceaccount "
450
- + serviceAccount
451
- + ". Cmd returned "
452
- + result .stdout ()
453
- + "\n "
454
- + result .stderr ());
455
- }
456
- }
457
-
458
- // create domain namespaces
459
-
460
- ArrayList <String > domainNamespaces = (ArrayList <String >) operatorMap .get ("domainNamespaces" );
461
- for (int i = 0 ; i < domainNamespaces .size (); i ++) {
462
- String domainNS = domainNamespaces .get (i );
463
- logger .info ("domainNamespace " + domainNS );
464
- if (!domainNS .equals ("default" )) {
465
- logger .info ("Creating domain namespace " + domainNS );
466
- ExecCommand .exec ("kubectl create namespace " + domainNS );
467
- }
468
- }
469
-
470
- if (System .getenv ("IMAGE_PULL_SECRET_OPERATOR" ) != null ) {
471
- Map <String , String > m = new HashMap <>();
472
- m .put ("name" , System .getenv ("IMAGE_PULL_SECRET_OPERATOR" ));
473
- List <Map <String , String >> l = new ArrayList <>();
474
- l .add (m );
475
- operatorMap .put ("imagePullSecrets" , l );
476
- // create docker registry secrets
477
- TestUtils .createDockerRegistrySecret (
478
- System .getenv ("IMAGE_PULL_SECRET_OPERATOR" ),
479
- System .getenv ("REPO_SERVER" ),
480
- System .getenv ("REPO_USERNAME" ),
481
- System .getenv ("REPO_PASSWORD" ),
482
- System .getenv ("REPO_EMAIL" ),
483
- operatorNS );
484
- }
391
+ initialize (TestUtils .loadYaml (inputYaml ), true , true , true );
485
392
}
486
393
487
- private void initializeCustom (
394
+ private void initialize (
488
395
Map <String , Object > inputMap , boolean opNS , boolean opSA , boolean targetdomainNS )
489
396
throws Exception {
490
397
operatorMap = inputMap ;
0 commit comments