1
1
package io .javaoperatorsdk .jenvtest .process ;
2
2
3
+ import java .io .File ;
3
4
import java .io .IOException ;
5
+ import java .util .ArrayList ;
6
+ import java .util .List ;
4
7
import java .util .Scanner ;
5
8
import java .util .concurrent .atomic .AtomicBoolean ;
6
9
@@ -39,21 +42,9 @@ public int startApiServer(int etcdPort) {
39
42
throw new JenvtestException (
40
43
"Missing binary for API Server on path: " + apiServerBinary .getAbsolutePath ());
41
44
}
42
- var port = Utils .findFreePort ();
43
- apiServerProcess = new ProcessBuilder (apiServerBinary .getAbsolutePath (),
44
- "--cert-dir" , config .getJenvtestDir (),
45
- "--secure-port" , "" + port ,
46
- "--etcd-servers" , "http://0.0.0.0:" + etcdPort ,
47
- "--authorization-mode" , "RBAC" ,
48
- "--service-account-issuer" , "https://localhost" ,
49
- "--service-account-signing-key-file" , certManager .getAPIServerKeyPath (),
50
- "--service-account-signing-key-file" , certManager .getAPIServerKeyPath (),
51
- "--service-account-key-file" , certManager .getAPIServerKeyPath (),
52
- "--service-account-issuer" , certManager .getAPIServerCertPath (),
53
- "--disable-admission-plugins" , "ServiceAccount" ,
54
- "--client-ca-file" , certManager .getClientCertPath (),
55
- "--service-cluster-ip-range" , "10.0.0.0/24" ,
56
- "--allow-privileged" )
45
+ var apiServerPort = Utils .findFreePort ();
46
+ var command = createCommand (apiServerBinary , apiServerPort , etcdPort );
47
+ apiServerProcess = new ProcessBuilder (command )
57
48
.start ();
58
49
Utils .redirectProcessOutputToLogger (apiServerProcess .getInputStream (), apiLog );
59
50
Utils .redirectProcessOutputToLogger (apiServerProcess .getErrorStream (), apiLog );
@@ -66,12 +57,32 @@ public int startApiServer(int etcdPort) {
66
57
return null ;
67
58
});
68
59
log .debug ("API Server started" );
69
- return port ;
60
+ return apiServerPort ;
70
61
} catch (IOException e ) {
71
62
throw new JenvtestException (e );
72
63
}
73
64
}
74
65
66
+ private List <String > createCommand (File apiServerBinary , int apiServerPort , int etcdPort ) {
67
+ var command = new ArrayList <String >();
68
+ command .add (apiServerBinary .getAbsolutePath ());
69
+ command .addAll (config .getApiServerFlags ());
70
+ command .addAll (List .of ("--cert-dir" , config .getJenvtestDir (),
71
+ "--secure-port" , "" + apiServerPort ,
72
+ "--etcd-servers" , "http://0.0.0.0:" + etcdPort ,
73
+ "--authorization-mode" , "RBAC" ,
74
+ "--service-account-issuer" , "https://localhost" ,
75
+ "--service-account-signing-key-file" , certManager .getAPIServerKeyPath (),
76
+ "--service-account-signing-key-file" , certManager .getAPIServerKeyPath (),
77
+ "--service-account-key-file" , certManager .getAPIServerKeyPath (),
78
+ "--service-account-issuer" , certManager .getAPIServerCertPath (),
79
+ "--disable-admission-plugins" , "ServiceAccount" ,
80
+ "--client-ca-file" , certManager .getClientCertPath (),
81
+ "--service-cluster-ip-range" , "10.0.0.0/24" ,
82
+ "--allow-privileged" ));
83
+ return command ;
84
+ }
85
+
75
86
public void waitUntilDefaultNamespaceCreated () {
76
87
try {
77
88
AtomicBoolean started = new AtomicBoolean (false );
0 commit comments