use of io.fabric8.maven.docker.service.ServiceHub in project docker-maven-plugin by fabric8io.
the class SourceMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
MojoParameters params = createMojoParameters();
List<ImageConfiguration> imageConfigs = new ArrayList<>();
for (ImageConfiguration imageConfig : getResolvedImages()) {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
if (buildConfig != null) {
if (buildConfig.skip()) {
log.info("%s: Skipped creating source", imageConfig.getDescription());
} else {
imageConfigs.add(imageConfig);
}
}
}
if (sourceMode == BuildImageSelectMode.first && imageConfigs.size() > 0) {
ImageConfiguration imageConfig = imageConfigs.get(0);
File dockerTar = hub.getArchiveService().createDockerBuildArchive(imageConfig, params);
projectHelper.attachArtifact(project, getArchiveType(imageConfig), getClassifier(null), dockerTar);
} else {
for (ImageConfiguration imageConfig : imageConfigs) {
File dockerTar = hub.getArchiveService().createDockerBuildArchive(imageConfig, params);
String alias = imageConfig.getAlias();
if (alias == null) {
throw new IllegalArgumentException("Image " + imageConfig.getDescription() + " must have an 'alias' configured to be " + "used as a classifier for attaching a docker build tar as source to the maven build");
}
projectHelper.attachArtifact(project, getArchiveType(imageConfig), getClassifier(alias), dockerTar);
}
}
}
use of io.fabric8.maven.docker.service.ServiceHub in project docker-maven-plugin by fabric8io.
the class BuildMojo method buildAndTag.
protected void buildAndTag(ServiceHub hub, ImageConfiguration imageConfig) throws MojoExecutionException, IOException {
EnvUtil.storeTimestamp(getBuildTimestampFile(), getBuildTimestamp());
BuildService.BuildContext buildContext = getBuildContext();
ImagePullManager pullManager = getImagePullManager(determinePullPolicy(imageConfig.getBuildConfiguration()), autoPull);
proceedWithBuildProcess(hub, buildContext, imageConfig, pullManager);
}
use of io.fabric8.maven.docker.service.ServiceHub in project docker-maven-plugin by fabric8io.
the class LogsMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub hub) throws MojoExecutionException, DockerAccessException {
QueryService queryService = hub.getQueryService();
LogDispatcher logDispatcher = getLogDispatcher(hub);
for (ImageConfiguration image : getResolvedImages()) {
String imageName = image.getName();
if (logAll) {
for (Container container : queryService.getContainersForImage(imageName, false)) {
doLogging(logDispatcher, image, container.getId());
}
} else {
Container container = queryService.getLatestContainerForImage(imageName, false);
if (container != null) {
doLogging(logDispatcher, image, container.getId());
}
}
}
if (follow) {
// Block forever ....
waitForEver();
}
}
use of io.fabric8.maven.docker.service.ServiceHub in project docker-maven-plugin by fabric8io.
the class VolumeCreateMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub serviceHub) throws DockerAccessException, MojoExecutionException {
if (getVolumes() == null) {
log.info("No volume configuration found.");
return;
}
VolumeService volService = serviceHub.getVolumeService();
for (VolumeConfiguration volume : getVolumes()) {
log.info("Creating volume '%s'", volume.getName());
volService.createVolume(volume);
}
}
use of io.fabric8.maven.docker.service.ServiceHub in project docker-maven-plugin by fabric8io.
the class JibBuildServiceTest method testPushWithConfiguration.
@Test
public void testPushWithConfiguration(@Mocked JibServiceUtil jibServiceUtil) throws Exception {
// Given
File projectBaseDir = Files.createTempDirectory("test").toFile();
setupServiceHubExpectations(projectBaseDir);
final ImageConfiguration imageConfiguration = getImageConfiguration();
final RegistryService.RegistryConfig registryConfig = new RegistryService.RegistryConfig.Builder().authConfigFactory(authConfigFactory).build();
mockAuthConfigFactory(true, registryConfig);
// When
new JibBuildService(serviceHub, params, logger).push(Collections.singletonList(imageConfiguration), 1, registryConfig, false);
// Then
// @formatter:off
new Verifications() {
{
JibServiceUtil.jibPush(imageConfiguration, Credential.from("testuserpush", "testpass"), (File) any, logger);
times = 1;
}
};
// @formatter:on
}
Aggregations