@Test public void getTerraformRootModuleDirReturnsTheDefaultDirWhenTheTfSourceDirIsNotFound() throws IOException { Path tfRootModulePath = TerraformUtils.getDefaultTerraformRootModuleDir(); Assert.assertEquals(Paths.get("."), tfRootModulePath); }
public static Path getDefaultTerraformRootModuleDir() throws IOException { try { Path tfSourcePath = Paths.get("src", "main", "tf"); if (tfSourcePath.toFile().exists() && tfSourcePath.toFile().isDirectory()) { return Files.walk(tfSourcePath, 2) .filter(path -> !path.toFile().isDirectory()) .filter(path -> path.getFileName().toString().endsWith(".tf")) .findFirst().orElseThrow(() -> new IOException("Terraform root module not found")).getParent(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); LOGGER.info("Unable to determine default Terraform root module directory; using current directory."); } return Paths.get("."); }
TerraformUtils { public static Path getDefaultTerraformRootModuleDir() throws IOException { try { Path tfSourcePath = Paths.get("src", "main", "tf"); if (tfSourcePath.toFile().exists() && tfSourcePath.toFile().isDirectory()) { return Files.walk(tfSourcePath, 2) .filter(path -> !path.toFile().isDirectory()) .filter(path -> path.getFileName().toString().endsWith(".tf")) .findFirst().orElseThrow(() -> new IOException("Terraform root module not found")).getParent(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); LOGGER.info("Unable to determine default Terraform root module directory; using current directory."); } return Paths.get("."); } }
TerraformUtils { public static Path getDefaultTerraformRootModuleDir() throws IOException { try { Path tfSourcePath = Paths.get("src", "main", "tf"); if (tfSourcePath.toFile().exists() && tfSourcePath.toFile().isDirectory()) { return Files.walk(tfSourcePath, 2) .filter(path -> !path.toFile().isDirectory()) .filter(path -> path.getFileName().toString().endsWith(".tf")) .findFirst().orElseThrow(() -> new IOException("Terraform root module not found")).getParent(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); LOGGER.info("Unable to determine default Terraform root module directory; using current directory."); } return Paths.get("."); } private  TerraformUtils(); }
TerraformUtils { public static Path getDefaultTerraformRootModuleDir() throws IOException { try { Path tfSourcePath = Paths.get("src", "main", "tf"); if (tfSourcePath.toFile().exists() && tfSourcePath.toFile().isDirectory()) { return Files.walk(tfSourcePath, 2) .filter(path -> !path.toFile().isDirectory()) .filter(path -> path.getFileName().toString().endsWith(".tf")) .findFirst().orElseThrow(() -> new IOException("Terraform root module not found")).getParent(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); LOGGER.info("Unable to determine default Terraform root module directory; using current directory."); } return Paths.get("."); } private  TerraformUtils(); static Path getDefaultTerraformRootModuleDir(); static Path getTerraformRootModuleDir(String tfmodule); static Path getDefaultTfModulesDir(); }
TerraformUtils { public static Path getDefaultTerraformRootModuleDir() throws IOException { try { Path tfSourcePath = Paths.get("src", "main", "tf"); if (tfSourcePath.toFile().exists() && tfSourcePath.toFile().isDirectory()) { return Files.walk(tfSourcePath, 2) .filter(path -> !path.toFile().isDirectory()) .filter(path -> path.getFileName().toString().endsWith(".tf")) .findFirst().orElseThrow(() -> new IOException("Terraform root module not found")).getParent(); } } catch (Exception e) { LOGGER.error(e.getMessage(), e); LOGGER.info("Unable to determine default Terraform root module directory; using current directory."); } return Paths.get("."); } private  TerraformUtils(); static Path getDefaultTerraformRootModuleDir(); static Path getTerraformRootModuleDir(String tfmodule); static Path getDefaultTfModulesDir();  }