Search in sources :

Example 41 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class DockerComposeConfigHandler method resolve.

@Override
@SuppressWarnings("unchecked")
public List<ImageConfiguration> resolve(ImageConfiguration unresolvedConfig, JavaProject project) {
    List<ImageConfiguration> resolved = new ArrayList<>();
    DockerComposeConfiguration handlerConfig = new DockerComposeConfiguration(unresolvedConfig.getExternalConfig());
    File composeFile = resolveComposeFileAbsolutely(handlerConfig.getBasedir(), handlerConfig.getComposeFile(), (project != null && project.getBaseDirectory() != null) ? project.getBaseDirectory().getAbsolutePath() : null);
    for (Object composeO : getComposeConfigurations(composeFile)) {
        Map<String, Object> compose = (Map<String, Object>) composeO;
        validateVersion(compose, composeFile);
        Map<String, Object> services = (Map<String, Object>) compose.get("services");
        for (Map.Entry<String, Object> entry : services.entrySet()) {
            String serviceName = entry.getKey();
            Map<String, Object> serviceDefinition = (Map<String, Object>) entry.getValue();
            DockerComposeServiceWrapper mapper = new DockerComposeServiceWrapper(serviceName, composeFile, serviceDefinition, unresolvedConfig, resolveAbsolutely(handlerConfig.getBasedir(), (project != null && project.getBaseDirectory() != null) ? project.getBaseDirectory().getAbsolutePath() : null));
            resolved.add(buildImageConfiguration(mapper, composeFile.getParentFile(), unresolvedConfig, handlerConfig));
        }
    }
    return resolved;
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) ArrayList(java.util.ArrayList) File(java.io.File) Map(java.util.Map)

Example 42 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class ImageConfigurationTest method initAndValidateWithBuildAndRun.

@Test
public void initAndValidateWithBuildAndRun(@Mocked ConfigHelper.NameFormatter nameFormatter, @Mocked BuildConfiguration buildConfiguration, @Mocked RunImageConfiguration runImageConfiguration) {
    // Given
    final ImageConfiguration imageConfiguration = ImageConfiguration.builder().build(buildConfiguration).run(runImageConfiguration).build();
    // @formatter:off
    new Expectations() {

        {
            buildConfiguration.initAndValidate();
            result = "1.337";
            runImageConfiguration.initAndValidate();
            result = "13.37";
        }
    };
    // @formatter:on
    // When
    final String result = ConfigHelper.initAndValidate(nameFormatter, imageConfiguration);
    // Then
    assertThat(result, is("13.37"));
}
Also used : Expectations(mockit.Expectations) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) Test(org.junit.Test)

Example 43 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class WatchServiceTest method testRestartContainerAndCallPostGoalRestartEnabled.

@Test
public void testRestartContainerAndCallPostGoalRestartEnabled() throws Exception {
    // Given
    AtomicBoolean restarted = new AtomicBoolean(false);
    WatchContext watchContext = WatchContext.builder().watchMode(WatchMode.both).containerRestarter(// Override Restart task to set this value to true
    i -> restarted.set(true)).build();
    WatchService.ImageWatcher imageWatcher = new WatchService.ImageWatcher(imageConfiguration, watchContext, "test-img", "efe1234");
    WatchService watchService = new WatchService(archiveService, buildService, queryService, runService, logger);
    // When
    watchService.restartContainerAndCallPostGoal(imageWatcher, true);
    // Then
    assertTrue(restarted.get());
}
Also used : WatchMode(org.eclipse.jkube.kit.config.image.WatchMode) Files(java.nio.file.Files) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AtomicReference(java.util.concurrent.atomic.AtomicReference) File(java.io.File) WatchImageConfiguration(org.eclipse.jkube.kit.config.image.WatchImageConfiguration) KitLogger(org.eclipse.jkube.kit.common.KitLogger) Mocked(mockit.Mocked) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) Test(org.junit.Test)

Example 44 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class StartOrderResolver method resolveImageDependencies.

private void resolveImageDependencies(List<ImageConfiguration> resolved) throws DockerAccessException, ResolveSteadyStateException {
    boolean changed = false;
    Iterator<ImageConfiguration> iterator = secondPass.iterator();
    while (iterator.hasNext()) {
        ImageConfiguration config = iterator.next();
        if (hasRequiredDependencies(config)) {
            updateProcessedImages(config);
            resolved.add(config);
            changed = true;
            iterator.remove();
        }
    }
    if (!changed) {
        throw new ResolveSteadyStateException();
    }
}
Also used : ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration)

Example 45 with ImageConfiguration

use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.

the class ImageEnricherTest method givenResourceConfigWithEnvVar.

private void givenResourceConfigWithEnvVar(String name, String value) {
    // @formatter:off
    new Expectations() {

        {
            Configuration configuration = Configuration.builder().resource(ResourceConfig.builder().env(Collections.singletonMap(name, value)).build()).image(imageConfiguration).build();
            context.getConfiguration();
            result = configuration;
        }
    };
// @formatter:on
}
Also used : Expectations(mockit.Expectations) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration)

Aggregations

ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)109 Test (org.junit.Test)75 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)29 RunImageConfiguration (org.eclipse.jkube.kit.config.image.RunImageConfiguration)28 File (java.io.File)26 ArrayList (java.util.ArrayList)19 Expectations (mockit.Expectations)15 GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)11 Before (org.junit.Before)11 IOException (java.io.IOException)9 Properties (java.util.Properties)8 KitLogger (org.eclipse.jkube.kit.common.KitLogger)8 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)7 JKubeServiceException (org.eclipse.jkube.kit.config.service.JKubeServiceException)7 WatchImageConfiguration (org.eclipse.jkube.kit.config.image.WatchImageConfiguration)6 ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)6 List (java.util.List)5 JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)5 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)5 Container (io.fabric8.kubernetes.api.model.Container)4