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");
}
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);
}
}
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;
}
};
}
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());
}
}
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);
}
Aggregations