Search in sources :

Example 1 with WatcherContext

use of org.eclipse.jkube.watcher.api.WatcherContext in project jkube by eclipse.

the class WatchMojo method executeInternal.

@Override
public void executeInternal() throws MojoExecutionException {
    URL masterUrl = kubernetesClient.getMasterUrl();
    KubernetesResourceUtil.validateKubernetesMasterUrl(masterUrl);
    try {
        List<HasMetadata> appliedK8sResources = KubernetesHelper.loadResources(getManifest(kubernetesClient));
        WatcherContext context = getWatcherContext();
        WatcherManager.watch(getResolvedImages(), applicableNamespace(null, namespace, resources, clusterAccess), appliedK8sResources, 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(org.eclipse.jkube.watcher.api.WatcherContext) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) URL(java.net.URL) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Example 2 with WatcherContext

use of org.eclipse.jkube.watcher.api.WatcherContext in project jkube by eclipse.

the class KubernetesWatchTask method run.

@Override
public void run() {
    try (KubernetesClient kubernetesClient = jKubeServiceHub.getClient()) {
        URL masterUrl = kubernetesClient.getMasterUrl();
        KubernetesResourceUtil.validateKubernetesMasterUrl(masterUrl);
        try {
            List<HasMetadata> resources = KubernetesHelper.loadResources(getManifest(kubernetesClient));
            WatcherContext context = createWatcherContext();
            WatcherManager.watch(resolvedImages, applicableNamespace(null, kubernetesExtension.getNamespaceOrNull(), kubernetesExtension.resources, clusterAccess), resources, context);
        } catch (KubernetesClientException kubernetesClientException) {
            KubernetesResourceUtil.handleKubernetesClientException(kubernetesClientException, kitLogger);
        } catch (Exception ioException) {
            throw new IllegalStateException("An error has occurred while while trying to watch the resources", ioException);
        }
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) WatcherContext(org.eclipse.jkube.watcher.api.WatcherContext) URL(java.net.URL) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) IOException(java.io.IOException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 IOException (java.io.IOException)2 URL (java.net.URL)2 WatcherContext (org.eclipse.jkube.watcher.api.WatcherContext)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1