Search in sources :

Example 6 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class GeneratorManagerTest method setUp.

@Before
public void setUp() throws Exception {
    final ProcessorConfig processorConfig = new ProcessorConfig();
    processorConfig.setIncludes(Collections.singletonList("fake-generator"));
    generatorContext = GeneratorContext.builder().config(processorConfig).logger(logger).build();
}
Also used : ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 7 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class PrometheusEnricherTest method testCustomPrometheusPort.

@Test
public void testCustomPrometheusPort() {
    // Given
    initContext(new ProcessorConfig(null, null, Collections.singletonMap("jkube-prometheus", Collections.singletonMap("prometheusPort", "1234"))), null);
    final KubernetesListBuilder builder = new KubernetesListBuilder().withItems(new ServiceBuilder().withNewMetadata().withName("foo").endMetadata().build());
    // When
    prometheusEnricher.create(PlatformMode.kubernetes, builder);
    // Then
    assertThat(builder.buildFirstItem().getMetadata().getAnnotations()).hasSize(3).containsEntry("prometheus.io/port", "1234").containsEntry("prometheus.io/scrape", "true").containsEntry("prometheus.io/path", "/metrics");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 8 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class QuarkusHealthCheckEnricherTest method setUp.

@SuppressWarnings("ResultOfMethodCallIgnored")
@Before
public void setUp() {
    properties = new Properties();
    processorConfig = new ProcessorConfig();
    klb = new KubernetesListBuilder();
    // @formatter:off
    klb.addToItems(new DeploymentBuilder().editOrNewSpec().editOrNewTemplate().editOrNewMetadata().withName("template-name").endMetadata().editOrNewSpec().addNewContainer().withImage("container/image").endContainer().endSpec().endTemplate().endSpec().build());
    new Expectations() {

        {
            context.getProperties();
            result = properties;
            context.getConfiguration().getProcessorConfig();
            result = processorConfig;
            javaProject.getProperties();
            result = properties;
            minTimes = 0;
            javaProject.getOutputDirectory();
            result = new File("/tmp/ignored");
            minTimes = 0;
        }
    };
// @formatter:on
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Expectations(mockit.Expectations) Properties(java.util.Properties) File(java.io.File) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 9 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class KarafGeneratorTest method customizeWithKarafMavenPluginShouldAddImageConfiguration.

@Test
public void customizeWithKarafMavenPluginShouldAddImageConfiguration(@Mocked Plugin plugin) {
    // Given
    final List<ImageConfiguration> originalImageConfigurations = new ArrayList<>();
    // @formatter:off
    new Expectations() {

        {
            plugin.getGroupId();
            result = "org.apache.karaf.tooling";
            minTimes = 0;
            plugin.getArtifactId();
            result = "karaf-maven-plugin";
            minTimes = 0;
            generatorContext.getProject().getPlugins();
            result = Collections.singletonList(plugin);
            minTimes = 0;
            generatorContext.getProject().getBuildDirectory();
            result = temporaryFolder.getRoot();
            generatorContext.getProject().getVersion();
            result = "1.33.7-SNAPSHOT";
            generatorContext.getConfig();
            result = new ProcessorConfig();
        }
    };
    // @formatter:on
    // When
    final List<ImageConfiguration> result = new KarafGenerator(generatorContext).customize(originalImageConfigurations, false);
    // Then
    assertThat(originalImageConfigurations, sameInstance(result));
    assertThat(result, hasSize(1));
    final ImageConfiguration imageConfiguration = result.iterator().next();
    assertThat(imageConfiguration.getName(), equalTo("%g/%a:%l"));
    assertThat(imageConfiguration.getAlias(), equalTo("karaf"));
    final BuildConfiguration bc = imageConfiguration.getBuildConfiguration();
    assertThat(bc.getTags(), contains("latest"));
    assertThat(bc.getPorts(), contains("8181", "8778"));
    assertThat(bc.getEnv(), hasEntry("DEPLOYMENTS_DIR", "/deployments"));
    assertThat(bc.getEnv(), hasEntry("KARAF_HOME", "/deployments/karaf"));
    final AssemblyConfiguration ac = bc.getAssembly();
    assertThat(ac.getName(), equalTo("deployments"));
    assertThat(ac.isExcludeFinalOutputArtifact(), equalTo(false));
    assertThat(ac.getLayers(), hasSize(1));
    assertThat(ac.getLayers().iterator().next().getFileSets(), contains(allOf(hasProperty("directory", equalTo(new File(temporaryFolder.getRoot(), "assembly"))), hasProperty("outputDirectory", equalTo(new File("karaf"))), hasProperty("directoryMode", equalTo("0775"))), allOf(hasProperty("directory", equalTo(temporaryFolder.getRoot().toPath().resolve("assembly").resolve("bin").toFile())), hasProperty("outputDirectory", equalTo(new File("karaf", "bin"))), hasProperty("fileMode", equalTo("0777")), hasProperty("directoryMode", equalTo("0775")))));
}
Also used : Expectations(mockit.Expectations) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) AssemblyConfiguration(org.eclipse.jkube.kit.common.AssemblyConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Test(org.junit.Test)

Example 10 with ProcessorConfig

use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.

the class ThorntailV2HealthCheckEnricherTest method setUp.

@Before
public void setUp() {
    properties = new Properties();
    processorConfig = new ProcessorConfig();
    klb = new KubernetesListBuilder();
    // @formatter:off
    klb.addToItems(new DeploymentBuilder().editOrNewSpec().editOrNewTemplate().editOrNewMetadata().withName("template-name").endMetadata().editOrNewSpec().addNewContainer().withImage("container/image").endContainer().endSpec().endTemplate().endSpec().build());
    new Expectations() {

        {
            context.getProperties();
            result = properties;
            context.getConfiguration().getProcessorConfig();
            result = processorConfig;
            context.hasDependency("io.thorntail", "monitor");
            result = true;
            context.getProjectClassLoaders();
            result = new ProjectClassLoaders(new URLClassLoader(new URL[0], ThorntailV2HealthCheckEnricherTest.class.getClassLoader()));
        }
    };
// @formatter:on
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Expectations(mockit.Expectations) ProjectClassLoaders(org.eclipse.jkube.kit.common.util.ProjectClassLoaders) URLClassLoader(java.net.URLClassLoader) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Aggregations

ProcessorConfig (org.eclipse.jkube.kit.config.resource.ProcessorConfig)33 Expectations (mockit.Expectations)22 Before (org.junit.Before)14 Test (org.junit.Test)13 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)12 Properties (java.util.Properties)12 TreeMap (java.util.TreeMap)6 Configuration (org.eclipse.jkube.kit.enricher.api.model.Configuration)6 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)4 DeploymentBuilder (io.fabric8.kubernetes.api.model.apps.DeploymentBuilder)4 ArrayList (java.util.ArrayList)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 File (java.io.File)3 URLClassLoader (java.net.URLClassLoader)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ProjectClassLoaders (org.eclipse.jkube.kit.common.util.ProjectClassLoaders)3 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)3 TypeToken (com.google.common.reflect.TypeToken)2 Gson (com.google.gson.Gson)2