Search in sources :

Example 6 with Configuration

use of org.eclipse.jkube.kit.enricher.api.model.Configuration in project jkube by eclipse.

the class WildflyJARHealthCheckEnricherTest method setupExpectations.

private void setupExpectations(JavaProject project, Map<String, Object> bootableJarconfig, Map<String, Map<String, Object>> jkubeConfig) {
    Plugin plugin = Plugin.builder().artifactId(WildflyJARHealthCheckEnricher.BOOTABLE_JAR_ARTIFACT_ID).groupId(WildflyJARHealthCheckEnricher.BOOTABLE_JAR_GROUP_ID).configuration(bootableJarconfig).build();
    List<Plugin> lst = new ArrayList<>();
    lst.add(plugin);
    ProcessorConfig c = new ProcessorConfig(null, null, jkubeConfig);
    new Expectations() {

        {
            project.getPlugins();
            result = lst;
            context.getProject();
            result = project;
            Configuration.ConfigurationBuilder configBuilder = Configuration.builder();
            configBuilder.processorConfig(c);
            context.getConfiguration();
            result = configBuilder.build();
        }
    };
}
Also used : Expectations(mockit.Expectations) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) ArrayList(java.util.ArrayList) Plugin(org.eclipse.jkube.kit.common.Plugin) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig)

Example 7 with Configuration

use of org.eclipse.jkube.kit.enricher.api.model.Configuration in project jkube by eclipse.

the class RevisionHistoryEnricherTest method testCustomRevisionHistoryLimit.

@Test
public void testCustomRevisionHistoryLimit() throws JsonProcessingException {
    // Setup mock behaviour
    final String revisionNumber = "10";
    new Expectations() {

        {
            Configuration config = Configuration.builder().processorConfig(prepareEnricherConfig(revisionNumber)).build();
            context.getConfiguration();
            result = config;
        }
    };
    // Given
    KubernetesListBuilder builder = new KubernetesListBuilder().addToItems(new DeploymentBuilder().build());
    RevisionHistoryEnricher enricher = new RevisionHistoryEnricher(context);
    // When
    enricher.create(PlatformMode.kubernetes, builder);
    // Then
    assertRevisionHistory(builder.build(), Integer.parseInt(revisionNumber));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) Test(org.junit.Test)

Example 8 with Configuration

use of org.eclipse.jkube.kit.enricher.api.model.Configuration 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)

Example 9 with Configuration

use of org.eclipse.jkube.kit.enricher.api.model.Configuration in project jkube by eclipse.

the class DockerRegistrySecretEnricher method generateData.

@Override
protected Map<String, String> generateData(String dockerId) {
    final Configuration config = getContext().getConfiguration();
    final Optional<Map<String, Object>> secretConfig = config.getSecretConfiguration(dockerId);
    if (!secretConfig.isPresent()) {
        return null;
    }
    JsonObject params = new JsonObject();
    for (String key : new String[] { "username", "password", "email" }) {
        if (secretConfig.get().containsKey(key)) {
            params.add(key, new JsonPrimitive(secretConfig.get().get(key).toString()));
        }
    }
    JsonObject ret = new JsonObject();
    ret.add(dockerId, params);
    return Collections.singletonMap(SecretConstants.DOCKER_DATA_KEY, encode(ret.toString()));
}
Also used : Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) JsonPrimitive(com.google.gson.JsonPrimitive) JsonObject(com.google.gson.JsonObject) Map(java.util.Map)

Aggregations

Configuration (org.eclipse.jkube.kit.enricher.api.model.Configuration)9 Expectations (mockit.Expectations)8 ProcessorConfig (org.eclipse.jkube.kit.config.resource.ProcessorConfig)5 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)4 TreeMap (java.util.TreeMap)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 Test (org.junit.Test)4 JsonObject (com.google.gson.JsonObject)2 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)2 TypeToken (com.google.common.reflect.TypeToken)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonParser (com.google.gson.JsonParser)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)1 Container (io.fabric8.kubernetes.api.model.Container)1 GenericKubernetesResourceBuilder (io.fabric8.kubernetes.api.model.GenericKubernetesResourceBuilder)1 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 PodTemplate (io.fabric8.kubernetes.api.model.PodTemplate)1