@Test public void dockerfileToCommandListTest_empty() throws Exception { File testFile = this.folder.newFile(); List<DockerfileParser.DockerCommand> ldc = DockerfileParser.dockerfileToCommandList( testFile ); Assert.assertEquals( 0, ldc.size()); }
public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException { List<DockerCommand> result = new ArrayList<>(); FileInputStream in = new FileInputStream( dockerfile ); Logger logger = Logger.getLogger( DockerfileParser.class.getName()); BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 )); String line; while((line = br.readLine()) != null) { DockerCommand cmd = DockerCommand.guess(line); if( cmd != null ) result.add( cmd ); else logger.fine("Ignoring unsupported Docker instruction: " + line ); } } finally { Utils.closeQuietly( br ); Utils.closeQuietly( in ); } return result; }
DockerfileParser { public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException { List<DockerCommand> result = new ArrayList<>(); FileInputStream in = new FileInputStream( dockerfile ); Logger logger = Logger.getLogger( DockerfileParser.class.getName()); BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 )); String line; while((line = br.readLine()) != null) { DockerCommand cmd = DockerCommand.guess(line); if( cmd != null ) result.add( cmd ); else logger.fine("Ignoring unsupported Docker instruction: " + line ); } } finally { Utils.closeQuietly( br ); Utils.closeQuietly( in ); } return result; } }
DockerfileParser { public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException { List<DockerCommand> result = new ArrayList<>(); FileInputStream in = new FileInputStream( dockerfile ); Logger logger = Logger.getLogger( DockerfileParser.class.getName()); BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 )); String line; while((line = br.readLine()) != null) { DockerCommand cmd = DockerCommand.guess(line); if( cmd != null ) result.add( cmd ); else logger.fine("Ignoring unsupported Docker instruction: " + line ); } } finally { Utils.closeQuietly( br ); Utils.closeQuietly( in ); } return result; } private  DockerfileParser(); }
DockerfileParser { public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException { List<DockerCommand> result = new ArrayList<>(); FileInputStream in = new FileInputStream( dockerfile ); Logger logger = Logger.getLogger( DockerfileParser.class.getName()); BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 )); String line; while((line = br.readLine()) != null) { DockerCommand cmd = DockerCommand.guess(line); if( cmd != null ) result.add( cmd ); else logger.fine("Ignoring unsupported Docker instruction: " + line ); } } finally { Utils.closeQuietly( br ); Utils.closeQuietly( in ); } return result; } private  DockerfileParser(); static List<DockerCommand> dockerfileToCommandList( File dockerfile ); }
DockerfileParser { public static List<DockerCommand> dockerfileToCommandList( File dockerfile ) throws IOException { List<DockerCommand> result = new ArrayList<>(); FileInputStream in = new FileInputStream( dockerfile ); Logger logger = Logger.getLogger( DockerfileParser.class.getName()); BufferedReader br = null; try { br = new BufferedReader( new InputStreamReader( in, StandardCharsets.UTF_8 )); String line; while((line = br.readLine()) != null) { DockerCommand cmd = DockerCommand.guess(line); if( cmd != null ) result.add( cmd ); else logger.fine("Ignoring unsupported Docker instruction: " + line ); } } finally { Utils.closeQuietly( br ); Utils.closeQuietly( in ); } return result; } private  DockerfileParser(); static List<DockerCommand> dockerfileToCommandList( File dockerfile );  }