integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java
public static void copyAppFilesToPod(
      String appLocationOnHost, String appLocationInPod, String podName, String namespace)
      throws Exception {
    File appFileRoot = new File(appLocationOnHost);
    File[] appFileList = appFileRoot.listFiles();

    if (appFileList == null) {
      return;
    }

    for (File file : appFileList) {
      if (file.isDirectory()) {

        // Create the directory on the pod
        String nestedDirOnPod = appLocationInPod + "/" + file.getName();
        StringBuffer mkdirCmd =
            new StringBuffer(" -- bash -c 'mkdir -p ").append(nestedDirOnPod).append("'");
        TestUtils.kubectlexec(podName, namespace, mkdirCmd.toString());

        // Find dir recursively
        copyAppFilesToPod(file.getAbsolutePath(), nestedDirOnPod, podName, namespace);
      } else {
        LoggerHelper.getLocal().log(Level.INFO, "Copy file: "
            + file.getAbsoluteFile().toString() + " to the pod: " + podName);

        String fileParent = file.getParentFile().getName();
        LoggerHelper.getLocal().log(Level.INFO, "file Parent: " + fileParent);

        StringBuffer copyFileCmd = new StringBuffer(" -- bash -c 'cat > ");
        copyFileCmd
            .append(appLocationInPod)
            .append("/")
            .append(file.getName())
            .append("' < ")
            .append(file.getAbsoluteFile().toString());

        kubectlexecNoCheck(podName, namespace, copyFileCmd.toString());
      }
    }
  }
/**
   * Copy all App files to the k8s pod.
   *
   * @param appLocationOnHost - App location on the local host
   * @param appLocationInPod  - App location on the k8s pod
   * @param podName           - the k8s pod name
   * @param namespace         - namespace the k8s pod is in
   * @throws Exception exception
   */
Copy all App files to the k8s pod.
Copy all App files to the k8s pod .
public static void copyAppFilesToPod(
      String appLocationOnHost, String appLocationInPod, String podName, String namespace)
      throws Exception {
    File appFileRoot = new File(appLocationOnHost);
    File[] appFileList = appFileRoot.listFiles();
    if (appFileList == null) {
      return;
    }
    for (File file : appFileList) {
      if (file.isDirectory()) {
        String nestedDirOnPod = appLocationInPod + "/" + file.getName();
        StringBuffer mkdirCmd =
            new StringBuffer(" -- bash -c 'mkdir -p ").append(nestedDirOnPod).append("'");
        TestUtils.kubectlexec(podName, namespace, mkdirCmd.toString());
        copyAppFilesToPod(file.getAbsolutePath(), nestedDirOnPod, podName, namespace);
      } else {
        LoggerHelper.getLocal().log(Level.INFO, "Copy file: "
            + file.getAbsoluteFile().toString() + " to the pod: " + podName);
        String fileParent = file.getParentFile().getName();
        LoggerHelper.getLocal().log(Level.INFO, "file Parent: " + fileParent);
        StringBuffer copyFileCmd = new StringBuffer(" -- bash -c 'cat > ");
        copyFileCmd
            .append(appLocationInPod)
            .append("/")
            .append(file.getName())
            .append("' < ")
            .append(file.getAbsoluteFile().toString());
        kubectlexecNoCheck(podName, namespace, copyFileCmd.toString());
      }
    }
  }
public static void copyAppFilesToPod ( String appLocationOnHost , String appLocationInPod , String podName , String namespace ) throws Exception { File appFileRoot = new File ( appLocationOnHost ) ; File [ ] appFileList = appFileRoot . listFiles ( ) ; if ( appFileList == null ) { return ; } for ( File file : appFileList ) { if ( file . isDirectory ( ) ) { String nestedDirOnPod = appLocationInPod + "/" + file . getName ( ) ; StringBuffer mkdirCmd = new StringBuffer ( " -- bash -c 'mkdir -p " ) . append ( nestedDirOnPod ) . append ( "'" ) ; TestUtils . kubectlexec ( podName , namespace , mkdirCmd . toString ( ) ) ; copyAppFilesToPod ( file . getAbsolutePath ( ) , nestedDirOnPod , podName , namespace ) ; } else { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Copy file: " + file . getAbsoluteFile ( ) . toString ( ) + " to the pod: " + podName ) ; String fileParent = file . getParentFile ( ) . getName ( ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "file Parent: " + fileParent ) ; StringBuffer copyFileCmd = new StringBuffer ( " -- bash -c 'cat > " ) ; copyFileCmd . append ( appLocationInPod ) . append ( "/" ) . append ( file . getName ( ) ) . append ( "' < " ) . append ( file . getAbsoluteFile ( ) . toString ( ) ) ; kubectlexecNoCheck ( podName , namespace , copyFileCmd . toString ( ) ) ; } } }
Copy all App files to the k8s pod.
Copy all App files to the k8s pod .
// Create the directory on the pod // Find dir recursively