File tree Expand file tree Collapse file tree 1 file changed +26
-9
lines changed
integration-tests/src/test/java/oracle/weblogic/kubernetes/utils Expand file tree Collapse file tree 1 file changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -21,18 +21,35 @@ public class SampleUtils {
21
21
* @param envMap - envMap for running the docker command
22
22
*/
23
23
public static void createPVHostPathAndChangePermissionInKindCluster (String hostPath , Map <String , String > envMap ) {
24
- String command = WLSIMG_BUILDER
25
- + " exec kind-worker sh -c \" mkdir "
26
- + hostPath
27
- + " && chmod g+w "
28
- + hostPath
29
- + "\" " ;
30
-
31
- Command .withParams (
24
+ if (!pathExistsInKindCluster (hostPath , envMap )) {
25
+ String command = WLSIMG_BUILDER
26
+ + " exec kind-worker sh -c \" mkdir "
27
+ + hostPath
28
+ + " && chmod g+w "
29
+ + hostPath
30
+ + "\" " ;
31
+
32
+ Command .withParams (
33
+ new CommandParams ()
34
+ .command (command )
35
+ .env (envMap )
36
+ .redirect (true )
37
+ ).execute ();
38
+ }
39
+ }
40
+
41
+ private static boolean pathExistsInKindCluster (String hostPath , Map <String , String > envMap ) {
42
+ String command = WLSIMG_BUILDER + " exec kind-worker sh -c \" ls / \" " ;
43
+ ExecResult result = Command .withParams (
32
44
new CommandParams ()
33
45
.command (command )
34
46
.env (envMap )
35
47
.redirect (true )
36
- ).execute ();
48
+ ).executeAndReturnResult ();
49
+
50
+ if (result .stdout ().contains (hostPath .substring (1 ))) {
51
+ return true ;
52
+ }
53
+ return false ;
37
54
}
38
55
}
You can’t perform that action at this time.
0 commit comments