Search in sources :

Example 1 with OpenShiftBuildStrategy

use of io.fabric8.maven.core.config.OpenShiftBuildStrategy in project fabric8-maven-plugin by fabric8io.

the class OpenshiftBuildServiceTest method init.

@Before
public void init() throws Exception {
    final File dockerFile = new File(baseDir, "Docker.tar");
    dockerFile.getParentFile().mkdirs();
    dockerFile.createNewFile();
    imageStreamFile.delete();
    new Expectations() {

        {
            dockerServiceHub.getArchiveService();
            result = archiveService;
            archiveService.createDockerBuildArchive(withAny(ImageConfiguration.class.cast(null)), withAny(MojoParameters.class.cast(null)));
            result = dockerFile;
            minTimes = 0;
            project.getArtifact();
            result = "myapp";
            minTimes = 0;
            dockerMojoParameters.getProject();
            result = project;
            minTimes = 0;
        }
    };
    image = new ImageConfiguration.Builder().name(projectName).buildConfig(new BuildImageConfiguration.Builder().from(projectName).build()).build();
    defaultConfig = new BuildService.BuildServiceConfig.Builder().buildDirectory(baseDir).buildRecreateMode(BuildRecreateMode.none).s2iBuildNameSuffix("-s2i-suffix2").openshiftBuildStrategy(OpenShiftBuildStrategy.s2i).dockerMojoParameters(dockerMojoParameters);
}
Also used : Expectations(mockit.Expectations) BuildService(io.fabric8.maven.core.service.BuildService) ImageStreamStatusBuilder(io.fabric8.openshift.api.model.ImageStreamStatusBuilder) BuildBuilder(io.fabric8.openshift.api.model.BuildBuilder) NamedTagEventListBuilder(io.fabric8.openshift.api.model.NamedTagEventListBuilder) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) BuildConfigBuilder(io.fabric8.openshift.api.model.BuildConfigBuilder) File(java.io.File) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 2 with OpenShiftBuildStrategy

use of io.fabric8.maven.core.config.OpenShiftBuildStrategy in project fabric8-maven-plugin by fabric8io.

the class JavaRunGeneratorTest method fromSelector.

@Test
public void fromSelector() throws IOException {
    Object[] data = { "3.1.123", PlatformMode.kubernetes, null, "java.upstream.docker", "3.1.redhat-101", PlatformMode.kubernetes, null, "java.redhat.docker", "3.1.123", PlatformMode.openshift, OpenShiftBuildStrategy.docker, "java.upstream.docker", "3.1.redhat-101", PlatformMode.openshift, OpenShiftBuildStrategy.docker, "java.redhat.docker", "3.1.123", PlatformMode.openshift, OpenShiftBuildStrategy.s2i, "java.upstream.s2i", "3.1.redhat-101", PlatformMode.openshift, OpenShiftBuildStrategy.s2i, "java.redhat.s2i" };
    Properties imageProps = getDefaultImageProps();
    for (int i = 0; i < data.length; i += 4) {
        prepareExpectation((String) data[i], (PlatformMode) data[i + 1], (OpenShiftBuildStrategy) data[i + 2]);
        final GeneratorContext context = ctx;
        FromSelector selector = new FromSelector.Default(context, "java");
        String from = selector.getFrom();
        assertEquals(imageProps.getProperty((String) data[i + 3]), from);
    }
}
Also used : GeneratorContext(io.fabric8.maven.generator.api.GeneratorContext) FromSelector(io.fabric8.maven.generator.api.FromSelector) Test(org.junit.Test)

Example 3 with OpenShiftBuildStrategy

use of io.fabric8.maven.core.config.OpenShiftBuildStrategy in project fabric8-maven-plugin by fabric8io.

the class FromSelector method getFrom.

public String getFrom() {
    PlatformMode mode = context.getMode();
    OpenShiftBuildStrategy strategy = context.getStrategy();
    if (mode == PlatformMode.openshift && strategy == OpenShiftBuildStrategy.s2i) {
        return getS2iBuildFrom();
    } else {
        return getDockerBuildFrom();
    }
}
Also used : PlatformMode(io.fabric8.maven.core.config.PlatformMode) OpenShiftBuildStrategy(io.fabric8.maven.core.config.OpenShiftBuildStrategy)

Aggregations

KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)1 OpenShiftBuildStrategy (io.fabric8.maven.core.config.OpenShiftBuildStrategy)1 PlatformMode (io.fabric8.maven.core.config.PlatformMode)1 BuildService (io.fabric8.maven.core.service.BuildService)1 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)1 FromSelector (io.fabric8.maven.generator.api.FromSelector)1 GeneratorContext (io.fabric8.maven.generator.api.GeneratorContext)1 BuildBuilder (io.fabric8.openshift.api.model.BuildBuilder)1 BuildConfigBuilder (io.fabric8.openshift.api.model.BuildConfigBuilder)1 ImageStreamBuilder (io.fabric8.openshift.api.model.ImageStreamBuilder)1 ImageStreamStatusBuilder (io.fabric8.openshift.api.model.ImageStreamStatusBuilder)1 NamedTagEventListBuilder (io.fabric8.openshift.api.model.NamedTagEventListBuilder)1 File (java.io.File)1 Expectations (mockit.Expectations)1 Before (org.junit.Before)1 Test (org.junit.Test)1