use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class AssemblyManagerTest method testCopyInvalidVerifyGivenDockerfile.
@Test
public void testCopyInvalidVerifyGivenDockerfile(@Injectable final KitLogger logger) throws IOException {
BuildConfiguration buildConfig = createBuildConfig();
AssemblyManager.verifyAssemblyReferencedInDockerfile(new File(getClass().getResource("/docker/Dockerfile_assembly_verify_copy_invalid.test").getPath()), buildConfig, new Properties(), logger);
// @formatter:off
new Verifications() {
{
logger.warn(anyString, (Object[]) any);
times = 1;
}
};
// @formatter:on
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class BuildUtilTest method extractBaseFromConfiguration_withBuildConfigurationAssemblyAndNoFrom_shouldReturnNull.
@Test
public void extractBaseFromConfiguration_withBuildConfigurationAssemblyAndNoFrom_shouldReturnNull() {
// Given
final BuildConfiguration buildConfiguration = BuildConfiguration.builder().assembly(new AssemblyConfiguration()).build();
// When
final String result = extractBaseFromConfiguration(buildConfiguration);
// Then
assertThat(result).isNull();
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class OpenShiftBuildServiceUtils method createBuildStrategy.
protected static BuildStrategy createBuildStrategy(JKubeServiceHub jKubeServiceHub, ImageConfiguration imageConfig, String openshiftPullSecret) {
final BuildServiceConfig config = jKubeServiceHub.getBuildServiceConfig();
final JKubeBuildStrategy osBuildStrategy = config.getJKubeBuildStrategy();
final BuildConfiguration buildConfig = imageConfig.getBuildConfiguration();
final Map<String, String> fromExt = buildConfig.getFromExt();
final String fromName;
if (buildConfig.isDockerFileMode()) {
fromName = extractBaseFromDockerfile(jKubeServiceHub.getConfiguration(), buildConfig);
} else {
fromName = getMapValueWithDefault(fromExt, JKubeBuildStrategy.SourceStrategy.name, buildConfig.getFrom());
}
final String fromKind = getMapValueWithDefault(fromExt, JKubeBuildStrategy.SourceStrategy.kind, DOCKER_IMAGE);
final String fromNamespace = getMapValueWithDefault(fromExt, JKubeBuildStrategy.SourceStrategy.namespace, IMAGE_STREAM_TAG.equals(fromKind) ? "openshift" : null);
if (osBuildStrategy == JKubeBuildStrategy.docker) {
BuildStrategy buildStrategy = new BuildStrategyBuilder().withType("Docker").withNewDockerStrategy().withNewFrom().withKind(fromKind).withName(fromName).withNamespace(StringUtils.isEmpty(fromNamespace) ? null : fromNamespace).endFrom().withEnv(checkForEnv(imageConfig)).withNoCache(checkForNocache(imageConfig)).endDockerStrategy().build();
if (openshiftPullSecret != null) {
buildStrategy.getDockerStrategy().setPullSecret(new LocalObjectReferenceBuilder().withName(openshiftPullSecret).build());
}
return buildStrategy;
} else if (osBuildStrategy == JKubeBuildStrategy.s2i) {
BuildStrategy buildStrategy = new BuildStrategyBuilder().withType("Source").withNewSourceStrategy().withNewFrom().withKind(fromKind).withName(fromName).withNamespace(StringUtils.isEmpty(fromNamespace) ? null : fromNamespace).endFrom().withForcePull(config.isForcePull()).endSourceStrategy().build();
if (openshiftPullSecret != null) {
buildStrategy.getSourceStrategy().setPullSecret(new LocalObjectReferenceBuilder().withName(openshiftPullSecret).build());
}
return buildStrategy;
} else {
throw new IllegalArgumentException("Unsupported BuildStrategy " + osBuildStrategy);
}
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class ContainerHandlerTest method getContainerWithGroupArtifactTest.
@Test
public void getContainerWithGroupArtifactTest() {
project.setArtifactId("test-artifact");
project.setGroupId("test-group");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
// container name with group id and aritact id without alias and user
final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compressionString("gzip").dockerFile("testFile").build();
ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("test").build(buildImageConfiguration).registry("docker.io").build();
images.clear();
images.add(imageConfiguration);
containers = handler.getContainers(config, images);
assertNotNull(containers);
assertEquals("test-group-test-artifact", containers.get(0).getName());
assertEquals("docker.io/test:latest", containers.get(0).getImage());
assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
use of org.eclipse.jkube.kit.config.image.build.BuildConfiguration in project jkube by eclipse.
the class PropertyConfigHandlerTest method testEntrypoint.
@Test
public void testEntrypoint() {
List<ImageConfiguration> configs = resolveImage(imageConfiguration, props(mergeArrays(getBaseTestData(), new String[] { "docker.from", "base", "docker.name", "demo", "docker.entrypoint", "/entrypoint.sh --from-property" })));
assertEquals(1, configs.size());
BuildConfiguration buildConfig = configs.get(0).getBuildConfiguration();
assertArrayEquals(new String[] { "/entrypoint.sh", "--from-property" }, buildConfig.getEntryPoint().asStrings().toArray());
}
Aggregations