@Test public void testCreateImage_noGenerateFrom() throws Exception { final String imageId = "toto"; this.configurator.createImage( imageId ); Mockito.verifyZeroInteractions( this.dockerClient ); }
void createImage( String imageId ) throws TargetException { File targetDirectory = this.parameters.getTargetPropertiesDirectory(); String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM ); if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) { this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." ); File dockerFile = new File( targetDirectory, dockerFilePath ); if( ! dockerFile.exists()) throw new TargetException( "No Dockerfile was found at " + dockerFile ); String builtImageId; this.logger.fine( "Asking Docker to build the image from our Dockerfile." ); try { builtImageId = this.dockerClient .buildImageCmd( dockerFile ) .withTags( Sets.newHashSet( imageId )) .withPull( true ) .exec( new RoboconfBuildImageResultCallback()) .awaitImageId(); } catch( Exception e ) { Utils.logException( this.logger, e ); throw new TargetException( e ); } this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." ); } }
DockerMachineConfigurator implements MachineConfigurator { void createImage( String imageId ) throws TargetException { File targetDirectory = this.parameters.getTargetPropertiesDirectory(); String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM ); if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) { this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." ); File dockerFile = new File( targetDirectory, dockerFilePath ); if( ! dockerFile.exists()) throw new TargetException( "No Dockerfile was found at " + dockerFile ); String builtImageId; this.logger.fine( "Asking Docker to build the image from our Dockerfile." ); try { builtImageId = this.dockerClient .buildImageCmd( dockerFile ) .withTags( Sets.newHashSet( imageId )) .withPull( true ) .exec( new RoboconfBuildImageResultCallback()) .awaitImageId(); } catch( Exception e ) { Utils.logException( this.logger, e ); throw new TargetException( e ); } this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." ); } } }
DockerMachineConfigurator implements MachineConfigurator { void createImage( String imageId ) throws TargetException { File targetDirectory = this.parameters.getTargetPropertiesDirectory(); String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM ); if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) { this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." ); File dockerFile = new File( targetDirectory, dockerFilePath ); if( ! dockerFile.exists()) throw new TargetException( "No Dockerfile was found at " + dockerFile ); String builtImageId; this.logger.fine( "Asking Docker to build the image from our Dockerfile." ); try { builtImageId = this.dockerClient .buildImageCmd( dockerFile ) .withTags( Sets.newHashSet( imageId )) .withPull( true ) .exec( new RoboconfBuildImageResultCallback()) .awaitImageId(); } catch( Exception e ) { Utils.logException( this.logger, e ); throw new TargetException( e ); } this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." ); } } DockerMachineConfigurator(
			TargetHandlerParameters parameters,
			String machineId,
			File userDataVolume,
			Map<String,File> containerIdToVolume ); }
DockerMachineConfigurator implements MachineConfigurator { void createImage( String imageId ) throws TargetException { File targetDirectory = this.parameters.getTargetPropertiesDirectory(); String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM ); if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) { this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." ); File dockerFile = new File( targetDirectory, dockerFilePath ); if( ! dockerFile.exists()) throw new TargetException( "No Dockerfile was found at " + dockerFile ); String builtImageId; this.logger.fine( "Asking Docker to build the image from our Dockerfile." ); try { builtImageId = this.dockerClient .buildImageCmd( dockerFile ) .withTags( Sets.newHashSet( imageId )) .withPull( true ) .exec( new RoboconfBuildImageResultCallback()) .awaitImageId(); } catch( Exception e ) { Utils.logException( this.logger, e ); throw new TargetException( e ); } this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." ); } } DockerMachineConfigurator(
			TargetHandlerParameters parameters,
			String machineId,
			File userDataVolume,
			Map<String,File> containerIdToVolume ); TargetHandlerParameters getParameters(); @Override Instance getScopedInstance(); @Override void close(); @Override boolean configure(); }
DockerMachineConfigurator implements MachineConfigurator { void createImage( String imageId ) throws TargetException { File targetDirectory = this.parameters.getTargetPropertiesDirectory(); String dockerFilePath = this.parameters.getTargetProperties().get( GENERATE_IMAGE_FROM ); if( ! Utils.isEmptyOrWhitespaces( dockerFilePath ) && targetDirectory != null ) { this.logger.fine( "Trying to create image " + imageId + " from a Dockerfile." ); File dockerFile = new File( targetDirectory, dockerFilePath ); if( ! dockerFile.exists()) throw new TargetException( "No Dockerfile was found at " + dockerFile ); String builtImageId; this.logger.fine( "Asking Docker to build the image from our Dockerfile." ); try { builtImageId = this.dockerClient .buildImageCmd( dockerFile ) .withTags( Sets.newHashSet( imageId )) .withPull( true ) .exec( new RoboconfBuildImageResultCallback()) .awaitImageId(); } catch( Exception e ) { Utils.logException( this.logger, e ); throw new TargetException( e ); } this.logger.fine( "Image '" + builtImageId + "' was succesfully generated by Roboconf." ); } } DockerMachineConfigurator(
			TargetHandlerParameters parameters,
			String machineId,
			File userDataVolume,
			Map<String,File> containerIdToVolume ); TargetHandlerParameters getParameters(); @Override Instance getScopedInstance(); @Override void close(); @Override boolean configure();  }