Search in sources :

Example 16 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class AssemblyManagerCreateDockerTarArchiveTest method withoutDockerfileAndAlreadyExistingFileInAssemblyGetsOverwritten.

@Test
public void withoutDockerfileAndAlreadyExistingFileInAssemblyGetsOverwritten() throws IOException {
    final JKubeConfiguration jKubeConfiguration = createJKubeConfiguration();
    final BuildConfiguration buildConfiguration = BuildConfiguration.builder().build();
    File dockerArchiveFile;
    // When
    assemblyManager.createDockerTarArchive("modified-image", jKubeConfiguration, buildConfiguration, prefixedLogger, null);
    // Modify file contents
    writeLineToFile(jKubeConfiguration.getProject().getArtifact(), "Modified content");
    dockerArchiveFile = assemblyManager.createDockerTarArchive("modified-image", jKubeConfiguration, buildConfiguration, prefixedLogger, null);
    // Then
    assertTargetHasDockerDirectories("modified-image");
    ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("without-dockerfile-and-already-existing-file-in-assembly-gets-overwritten"));
    assertDockerFile("modified-image").hasContent(DOCKERFILE_DEFAULT_FALLBACK_CONTENT);
    assertBuildDirectoryFileTree("modified-image").containsExactlyInAnyOrder("Dockerfile", "jkube-generated-layer-final-artifact", "jkube-generated-layer-final-artifact/maven", "jkube-generated-layer-final-artifact/maven/test-0.1.0.jar", "maven");
    assertThat(resolveDockerBuild("modified-image").resolve("jkube-generated-layer-final-artifact").resolve("maven").resolve("test-0.1.0.jar")).exists().isRegularFile().hasContent("Modified content");
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) AssemblyFile(org.eclipse.jkube.kit.common.AssemblyFile) File(java.io.File) Test(org.junit.Test)

Example 17 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class HelmService method uploadHelmChart.

/**
 * Uploads the charts defined in the provided {@link HelmConfig} to the applicable configured repository.
 *
 * <p> For Charts with versions ending in "-SNAPSHOT" the {@link HelmConfig#getSnapshotRepository()} is used.
 * {@link HelmConfig#getStableRepository()} is used for other versions.
 *
 * @param helm Configuration for which to generate the Charts.
 * @throws BadUploadException in case the chart cannot be uploaded.
 * @throws IOException in case of any I/O exception when .
 */
public void uploadHelmChart(HelmConfig helm) throws BadUploadException, IOException {
    final HelmRepository helmRepository = selectHelmRepository(helm);
    if (isRepositoryValid(helmRepository)) {
        final List<RegistryServerConfiguration> registryServerConfigurations = Optional.ofNullable(jKubeConfiguration).map(JKubeConfiguration::getRegistryConfig).map(RegistryConfig::getSettings).orElse(Collections.emptyList());
        final UnaryOperator<String> passwordDecryptor = Optional.ofNullable(jKubeConfiguration).map(JKubeConfiguration::getRegistryConfig).map(RegistryConfig::getPasswordDecryptionMethod).orElse(s -> s);
        setAuthentication(helmRepository, logger, registryServerConfigurations, passwordDecryptor);
        uploadHelmChart(helm, helmRepository);
    } else {
        String error = "No repository or invalid repository configured for upload";
        logger.error(error);
        throw new IllegalStateException(error);
    }
}
Also used : HelmServiceUtil.selectHelmRepository(org.eclipse.jkube.kit.resource.helm.HelmServiceUtil.selectHelmRepository) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) RegistryServerConfiguration(org.eclipse.jkube.kit.common.RegistryServerConfiguration)

Example 18 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class DockerImageWatcherTest method setUp.

@Before
public void setUp() {
    dockerImageWatcher = new DockerImageWatcher(watcherContext);
    // @formatter:off
    new Expectations() {

        {
            watcherContext.getWatchContext();
            result = new WatchContext();
            minTimes = 0;
        }
    };
    // @formatter:on
    new MockUp<WatchService>() {

        @Mock
        void watch(WatchContext context, JKubeConfiguration buildContext, List<ImageConfiguration> images) {
            watchContext = context;
        }
    };
}
Also used : Expectations(mockit.Expectations) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) MockUp(mockit.MockUp) List(java.util.List) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext) Before(org.junit.Before)

Example 19 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class WatchMojo method getWatcherContext.

private WatcherContext getWatcherContext() throws MojoExecutionException {
    try {
        JKubeConfiguration buildContext = initJKubeConfiguration();
        WatchContext watchContext = jkubeServiceHub.getDockerServiceHub() != null ? getWatchContext() : null;
        return WatcherContext.builder().buildContext(buildContext).watchContext(watchContext).config(extractWatcherConfig()).logger(log).newPodLogger(createLogger("[[C]][NEW][[C]] ")).oldPodLogger(createLogger("[[R]][OLD][[R]] ")).useProjectClasspath(useProjectClasspath).jKubeServiceHub(jkubeServiceHub).build();
    } catch (DependencyResolutionRequiredException dependencyException) {
        throw new MojoExecutionException("Instructed to use project classpath, but cannot. Continuing build if we can: " + dependencyException.getMessage());
    } catch (IOException ioException) {
        throw new MojoExecutionException(ioException.getMessage());
    }
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) WatchContext(org.eclipse.jkube.kit.build.service.docker.watch.WatchContext)

Example 20 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class JibBuildServiceBuildIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    projectRoot = temporaryFolder.getRoot();
    imageConfiguration = ImageConfiguration.builder().name("registry/image-name:tag").build(BuildConfiguration.builder().build()).build();
    targetDirectory = temporaryFolder.newFolder("target");
    final JKubeConfiguration configuration = JKubeConfiguration.builder().outputDirectory("target/docker").project(JavaProject.builder().buildFinalName("final-artifact").packaging("jar").baseDirectory(projectRoot).buildDirectory(targetDirectory).properties(new Properties()).build()).registryConfig(RegistryConfig.builder().settings(Collections.emptyList()).build()).build();
    // @formatter:off
    new Expectations() {

        {
            hub.getConfiguration();
            result = configuration;
            hub.getLog();
            result = log;
        }
    };
    // @formatter:on
    jibBuildService = new JibBuildService(hub);
}
Also used : Expectations(mockit.Expectations) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)23 File (java.io.File)15 Test (org.junit.Test)13 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)12 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)11 KitLogger (org.eclipse.jkube.kit.common.KitLogger)6 IOException (java.io.IOException)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)4 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)4 JavaProject (org.eclipse.jkube.kit.common.JavaProject)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 Map (java.util.Map)3 Optional (java.util.Optional)3 Properties (java.util.Properties)3 Assembly (org.eclipse.jkube.kit.common.Assembly)3 Before (org.junit.Before)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2