use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyManagerCreateDockerTarArchiveTest method withDockerfileInBaseDirectoryAndAssemblyFile.
@Test
public void withDockerfileInBaseDirectoryAndAssemblyFile() throws IOException {
// Given
final File dockerFile = new File(baseDirectory, "Dockerfile");
writeLineToFile(dockerFile, "FROM busybox");
final File assemblyFile = temporaryFolder.newFile("extra-file-1.txt");
writeLineToFile(assemblyFile, "HELLO");
AssemblyConfiguration assemblyConfig = AssemblyConfiguration.builder().inline(Assembly.builder().file(AssemblyFile.builder().source(assemblyFile).outputDirectory(new File(".")).build()).build()).build();
final JKubeConfiguration configuration = createJKubeConfiguration();
final BuildConfiguration jKubeBuildConfiguration = BuildConfiguration.builder().dockerFileFile(dockerFile).dockerFile(dockerFile.getPath()).assembly(assemblyConfig).build();
// When
final File dockerArchiveFile = assemblyManager.createDockerTarArchive("dockerfile-and-assembly-file", configuration, jKubeBuildConfiguration, prefixedLogger, null);
// Then
assertTargetHasDockerDirectories("dockerfile-and-assembly-file");
ArchiveAssertions.assertThat(dockerArchiveFile).isFile().hasName("docker-build.tar").hasSameContentAsDirectory(getExpectedDirectory("with-dockerfile-in-base-directory-and-assembly-file"));
assertDockerFile("dockerfile-and-assembly-file").hasContent("FROM busybox\n");
assertBuildDirectoryFileTree("dockerfile-and-assembly-file").containsExactlyInAnyOrder("Dockerfile", "maven", "maven/Dockerfile", "maven/test-0.1.0.jar", "maven/extra-file-1.txt", "maven/target", "maven/target/test-0.1.0.jar");
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class OpenshiftBuildService method checkOrCreatePullSecret.
private boolean checkOrCreatePullSecret(OpenShiftClient client, KubernetesListBuilder builder, String pullSecretName, ImageConfiguration imageConfig) throws Exception {
BuildConfiguration buildConfig = imageConfig.getBuildConfiguration();
String fromImage;
if (buildConfig.isDockerFileMode()) {
fromImage = extractBaseFromDockerfile(jKubeConfiguration, buildConfig);
} else {
fromImage = extractBaseFromConfiguration(buildConfig);
}
String pullRegistry = EnvUtil.firstRegistryOf(new ImageName(fromImage).getRegistry(), jKubeConfiguration.getRegistryConfig().getRegistry(), jKubeConfiguration.getRegistryConfig().getRegistry());
if (pullRegistry != null) {
RegistryConfig registryConfig = jKubeConfiguration.getRegistryConfig();
final AuthConfig authConfig = new AuthConfigFactory(log).createAuthConfig(false, registryConfig.isSkipExtendedAuth(), registryConfig.getAuthConfig(), registryConfig.getSettings(), null, pullRegistry, registryConfig.getPasswordDecryptionMethod());
final Secret secret = Optional.ofNullable(pullSecretName).map(psn -> client.secrets().inNamespace(applicableOpenShiftNamespace).withName(psn).get()).orElse(null);
if (secret != null) {
log.info("Adding to Secret %s", pullSecretName);
return updateSecret(client, pullSecretName, secret.getData());
}
if (authConfig != null) {
JsonObject auths = new JsonObject();
JsonObject auth = new JsonObject();
JsonObject item = new JsonObject();
String authString = authConfig.getUsername() + ":" + authConfig.getPassword();
item.add("auth", new JsonPrimitive(Base64.encodeBase64String(authString.getBytes(StandardCharsets.UTF_8))));
auth.add(pullRegistry, item);
auths.add("auths", auth);
String credentials = Base64.encodeBase64String(auths.toString().getBytes(StandardCharsets.UTF_8));
Map<String, String> data = new HashMap<>();
data.put(".dockerconfigjson", credentials);
log.info("Creating Secret");
builder.addNewSecretItem().withNewMetadata().withName(pullSecretName).endMetadata().withData(data).withType("kubernetes.io/dockerconfigjson").endSecretItem();
return true;
}
}
return false;
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class HelmServiceIT method setUp.
@Before
public void setUp() throws Exception {
mapper = new ObjectMapper(new YAMLFactory());
helmService = new HelmService(new JKubeConfiguration(), new KitLogger.SilentLogger());
helmOutputDir = temporaryFolder.newFolder("helm-output");
helmConfig = new HelmConfig();
helmConfig.setSourceDir(new File(HelmServiceIT.class.getResource("/it/sources").toURI()).getAbsolutePath());
helmConfig.setOutputDir(helmOutputDir.getAbsolutePath());
helmConfig.setTarballOutputDir(helmOutputDir.getAbsolutePath());
helmConfig.setChartExtension("tar");
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyConfigurationSourceTest method testOutputDirHasImage.
@Test
public void testOutputDirHasImage() {
String image = "image";
JKubeConfiguration context = buildBuildContext("src/docker", "output/docker");
AssemblyConfigurationSource source = new AssemblyConfigurationSource(context, new BuildDirs(image, context), assemblyConfig);
assertTrue(containsDir(image, source.getOutputDirectory()));
assertTrue(containsDir(image, source.getWorkingDirectory()));
assertTrue(containsDir(image, source.getTemporaryRootDirectory()));
}
use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.
the class AssemblyConfigurationSourceTest method testReactorProjects.
@Test
public void testReactorProjects() {
JavaProject project1 = JavaProject.builder().build();
JavaProject project2 = JavaProject.builder().build();
JKubeConfiguration buildContext = JKubeConfiguration.builder().sourceDirectory("/src/docker").outputDirectory("/output/docker").reactorProjects(Arrays.asList(project1, project2)).build();
AssemblyConfigurationSource source = new AssemblyConfigurationSource(buildContext, null, null);
assertEquals(2, source.getReactorProjects().size());
}
Aggregations