Search in sources :

Example 31 with DockerAccessException

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);
    }
}
Also used : VolumeService(io.fabric8.maven.docker.service.VolumeService) VolumeConfiguration(io.fabric8.maven.docker.config.VolumeConfiguration)

Example 32 with DockerAccessException

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);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 33 with DockerAccessException

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);
    }
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) WatcherContext(io.fabric8.maven.watcher.api.WatcherContext) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) URL(java.net.URL) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Example 34 with DockerAccessException

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);
    }
}
Also used : Task(io.fabric8.maven.docker.util.Task) ServiceHub(io.fabric8.maven.docker.service.ServiceHub) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) BuildService(io.fabric8.maven.docker.service.BuildService) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) WatchService(io.fabric8.maven.docker.service.WatchService)

Aggregations

DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)11 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)8 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)7 Container (io.fabric8.maven.docker.model.Container)6 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)5 Arguments (io.fabric8.maven.docker.config.Arguments)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)3 PortMapping (io.fabric8.maven.docker.access.PortMapping)3 File (java.io.File)3 IOException (java.io.IOException)3 ContainerCreateConfig (io.fabric8.maven.docker.access.ContainerCreateConfig)2 ContainerHostConfig (io.fabric8.maven.docker.access.ContainerHostConfig)2 ExecException (io.fabric8.maven.docker.access.ExecException)2 HttpBodyAndStatus (io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.HttpBodyAndStatus)2 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)2 VolumeConfiguration (io.fabric8.maven.docker.config.VolumeConfiguration)2 LogDispatcher (io.fabric8.maven.docker.log.LogDispatcher)2 ContainerDetails (io.fabric8.maven.docker.model.ContainerDetails)2 Network (io.fabric8.maven.docker.model.Network)2