use of io.fabric8.maven.docker.access.DockerAccessException in project docker-maven-plugin by fabric8io.
the class VolumeCreateMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub serviceHub) throws DockerAccessException, MojoExecutionException {
VolumeService volService = serviceHub.getVolumeService();
for (VolumeConfiguration volume : getVolumes()) {
log.info("Creating volume '%s'", volume.getName());
volService.createVolume(volume);
}
}
use of io.fabric8.maven.docker.access.DockerAccessException in project fabric8-maven-plugin by fabric8io.
the class BuildMojo method buildAndTag.
@Override
protected void buildAndTag(ServiceHub hub, ImageConfiguration imageConfig) throws MojoExecutionException, DockerAccessException {
try {
// TODO need to refactor d-m-p to avoid this call
EnvUtil.storeTimestamp(this.getBuildTimestampFile(), this.getBuildTimestamp());
fabric8ServiceHub.getBuildService().build(imageConfig);
} catch (Exception ex) {
throw new MojoExecutionException("Failed to execute the build", ex);
}
}
use of io.fabric8.maven.docker.access.DockerAccessException in project fabric8-maven-plugin by fabric8io.
the class WatchMojo method executeInternal.
@Override
protected synchronized void executeInternal(ServiceHub hub) throws DockerAccessException, MojoExecutionException {
this.hub = hub;
URL masterUrl = kubernetes.getMasterUrl();
KubernetesResourceUtil.validateKubernetesMasterUrl(masterUrl);
File manifest;
boolean isOpenshift = KubernetesHelper.isOpenShift(kubernetes);
if (isOpenshift) {
manifest = openshiftManifest;
} else {
manifest = kubernetesManifest;
}
try {
Set<HasMetadata> resources = KubernetesResourceUtil.loadResources(manifest);
WatcherContext context = getWatcherContext();
WatcherManager.watch(getResolvedImages(), resources, context);
} catch (KubernetesClientException ex) {
KubernetesResourceUtil.handleKubernetesClientException(ex, this.log);
} catch (Exception ex) {
throw new MojoExecutionException("An error has occurred while while trying to watch the resources", ex);
}
}
use of io.fabric8.maven.docker.access.DockerAccessException in project fabric8-maven-plugin by fabric8io.
the class DockerImageWatcher method watch.
@Override
public void watch(List<ImageConfiguration> configs, final Set<HasMetadata> resources, PlatformMode mode) {
BuildService.BuildContext buildContext = getContext().getBuildContext();
WatchService.WatchContext watchContext = getContext().getWatchContext();
// add a image customizer
watchContext = new WatchService.WatchContext.Builder(watchContext).imageCustomizer(new Task<ImageConfiguration>() {
@Override
public void execute(ImageConfiguration imageConfiguration) throws DockerAccessException, MojoExecutionException, MojoFailureException {
buildImage(imageConfiguration);
}
}).containerRestarter(new Task<WatchService.ImageWatcher>() {
@Override
public void execute(WatchService.ImageWatcher imageWatcher) throws DockerAccessException, MojoExecutionException, MojoFailureException {
restartContainer(imageWatcher, resources);
}
}).build();
ServiceHub hub = getContext().getServiceHub();
try {
hub.getWatchService().watch(watchContext, buildContext, configs);
} catch (Exception ex) {
throw new RuntimeException("Error while watching", ex);
}
}
Aggregations