Search in sources :

Example 31 with ProcessorConfig

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

the class NameEnricherTest method setUp.

@Before
public void setUp() {
    properties = new Properties();
    ProcessorConfig processorConfig = new ProcessorConfig();
    klb = new KubernetesListBuilder();
    // @formatter:off
    klb.addToItems(new ConfigMapBuilder().withNewMetadata().endMetadata().build(), new DeploymentBuilder().withNewMetadata().endMetadata().build(), new ReplicaSetBuilder().withNewMetadata().endMetadata().build(), new ReplicationControllerBuilder().withNewMetadata().endMetadata().build(), new NamespaceBuilder().build());
    // @formatter:on
    context = mock(JKubeEnricherContext.class, RETURNS_DEEP_STUBS);
    when(context.getProperties()).thenReturn(properties);
    when(context.getConfiguration().getProcessorConfig()).thenReturn(processorConfig);
    when(context.getGav().getSanitizedArtifactId()).thenReturn("artifact-id");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ReplicaSetBuilder(io.fabric8.kubernetes.api.model.apps.ReplicaSetBuilder) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) ReplicationControllerBuilder(io.fabric8.kubernetes.api.model.ReplicationControllerBuilder) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) Properties(java.util.Properties) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) NamespaceBuilder(io.fabric8.kubernetes.api.model.NamespaceBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 32 with ProcessorConfig

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

the class DefaultControllerEnricherTest method setUp.

@Before
public void setUp() throws Exception {
    config = new HashMap<>();
    context = JKubeEnricherContext.builder().processorConfig(new ProcessorConfig(null, null, config)).log(new KitLogger.SilentLogger()).resources(ResourceConfig.builder().build()).image(ImageConfiguration.builder().name("helloworld").build(BuildConfiguration.builder().port("8080").build()).build()).project(JavaProject.builder().properties(new Properties()).groupId("group").artifactId("artifact-id").build()).build();
}
Also used : Properties(java.util.Properties) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Before(org.junit.Before)

Example 33 with ProcessorConfig

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

the class DefaultServiceEnricherTest method serviceImageLabelEnrichment.

@Test
public void serviceImageLabelEnrichment() throws Exception {
    ImageConfiguration imageConfigurationWithLabels = ImageConfiguration.builder().name("test-label").alias("test").build();
    final TreeMap<String, Object> config = new TreeMap<>();
    config.put("type", "LoadBalancer");
    new Expectations() {

        {
            Configuration configuration = Configuration.builder().image(imageConfigurationWithLabels).processorConfig(new ProcessorConfig(null, null, Collections.singletonMap("jkube-service", config))).build();
            groupArtifactVersion.getSanitizedArtifactId();
            result = "jkube-service";
            context.getConfiguration();
            result = configuration;
            imageConfigurationWithLabels.getBuildConfiguration();
            result = BuildConfiguration.builder().labels(Collections.singletonMap("jkube.generator.service.ports", "9090")).ports(Arrays.asList("80", "53/UDP")).build();
        }
    };
    String json = enrich();
    assertPort(json, 0, 9090, 9090, "http", "TCP");
}
Also used : Expectations(mockit.Expectations) BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) TreeMap(java.util.TreeMap) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) Test(org.junit.Test)

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