Search in sources :

Example 1 with PluginServiceFactory

use of org.eclipse.jkube.kit.common.util.PluginServiceFactory in project jkube by eclipse.

the class WatcherManager method watch.

public static void watch(List<ImageConfiguration> ret, String namespace, Collection<HasMetadata> resources, WatcherContext watcherCtx) throws Exception {
    final PluginServiceFactory<WatcherContext> pluginFactory = new PluginServiceFactory<>(watcherCtx);
    if (watcherCtx.isUseProjectClasspath()) {
        pluginFactory.addAdditionalClassLoader(ClassUtil.createProjectClassLoader(watcherCtx.getBuildContext().getProject().getCompileClassPathElements(), watcherCtx.getLogger()));
    }
    final boolean isOpenshift = watcherCtx.getJKubeServiceHub().getClusterAccess().isOpenShift();
    final PlatformMode mode = isOpenshift ? PlatformMode.openshift : PlatformMode.kubernetes;
    final KitLogger log = watcherCtx.getLogger();
    final List<Watcher> watchers = pluginFactory.createServiceObjects(SERVICE_PATHS);
    final List<Watcher> usableWatchers = watcherCtx.getConfig().prepareProcessors(watchers, "watcher");
    log.verbose("Watchers:");
    Watcher chosen = null;
    for (Watcher watcher : usableWatchers) {
        if (watcher.isApplicable(ret, resources, mode)) {
            if (chosen == null) {
                log.verbose(" - %s [selected]", watcher.getName());
                chosen = watcher;
            } else {
                log.verbose(" - %s", watcher.getName());
            }
        } else {
            log.verbose(" - %s [not applicable]", watcher.getName());
        }
    }
    if (chosen == null) {
        throw new IllegalStateException("No watchers can be used for the current project");
    }
    log.info("Running watcher %s", chosen.getName());
    chosen.watch(ret, namespace, resources, mode);
}
Also used : KitLogger(org.eclipse.jkube.kit.common.KitLogger) PlatformMode(org.eclipse.jkube.kit.config.resource.PlatformMode) PluginServiceFactory(org.eclipse.jkube.kit.common.util.PluginServiceFactory)

Example 2 with PluginServiceFactory

use of org.eclipse.jkube.kit.common.util.PluginServiceFactory in project jkube by eclipse.

the class GeneratorManager method generate.

public static List<ImageConfiguration> generate(List<ImageConfiguration> imageConfigs, GeneratorContext genCtx, boolean prePackagePhase) {
    final PluginServiceFactory<GeneratorContext> pluginFactory = new PluginServiceFactory<>(genCtx);
    if (genCtx.isUseProjectClasspath()) {
        pluginFactory.addAdditionalClassLoader(ClassUtil.createProjectClassLoader(genCtx.getProject().getCompileClassPathElements(), genCtx.getLogger()));
    }
    List<ImageConfiguration> ret = imageConfigs;
    final KitLogger log = genCtx.getLogger();
    final List<Generator> generators = pluginFactory.createServiceObjects(SERVICE_PATHS);
    final List<Generator> usableGenerators = genCtx.getConfig().prepareProcessors(generators, "generator");
    log.verbose("Generators:");
    for (Generator generator : usableGenerators) {
        log.verbose(" - %s", generator.getName());
        if (generator.isApplicable(ret)) {
            log.info("Running generator %s", generator.getName());
            ret = generator.customize(ret, prePackagePhase);
        }
    }
    return ret;
}
Also used : KitLogger(org.eclipse.jkube.kit.common.KitLogger) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) PluginServiceFactory(org.eclipse.jkube.kit.common.util.PluginServiceFactory)

Aggregations

KitLogger (org.eclipse.jkube.kit.common.KitLogger)2 PluginServiceFactory (org.eclipse.jkube.kit.common.util.PluginServiceFactory)2 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)1 PlatformMode (org.eclipse.jkube.kit.config.resource.PlatformMode)1