Search in sources :

Example 6 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class OpenShiftBuildServiceUtilsTest method computeS2IBuildName_withImageNameAndBuildServiceWithCustomSuffix_shouldReturnNameWithCustomSuffix.

@Test
public void computeS2IBuildName_withImageNameAndBuildServiceWithCustomSuffix_shouldReturnNameWithCustomSuffix() {
    // Given
    final BuildServiceConfig buildServiceConfig = BuildServiceConfig.builder().jKubeBuildStrategy(JKubeBuildStrategy.s2i).s2iBuildNameSuffix("-custom").buildDirectory(temporaryFolder.getRoot().getAbsolutePath()).build();
    final ImageName imageName = new ImageName("registry/name:tag");
    // When
    final String result = computeS2IBuildName(buildServiceConfig, imageName);
    // Then
    assertThat(result).isEqualTo("name-custom");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) Test(org.junit.Test)

Example 7 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class OpenShiftBuildServiceUtilsTest method createBuildOutput_withOutputKindDockerAndPushSecret_shouldReturnDocker.

@Test
public void createBuildOutput_withOutputKindDockerAndPushSecret_shouldReturnDocker() {
    // Given
    final BuildServiceConfig buildServiceConfig = BuildServiceConfig.builder().buildOutputKind("DockerImage").openshiftPushSecret("my-push-secret").buildDirectory(temporaryFolder.getRoot().getAbsolutePath()).build();
    // When
    final BuildOutput result = createBuildOutput(buildServiceConfig, new ImageName("my-app-image"));
    // Then
    assertThat(result).hasFieldOrPropertyWithValue("pushSecret.name", "my-push-secret").extracting(BuildOutput::getTo).hasFieldOrPropertyWithValue("kind", "DockerImage").hasFieldOrPropertyWithValue("name", "my-app-image:latest");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) BuildOutput(io.fabric8.openshift.api.model.BuildOutput) OpenShiftBuildServiceUtils.createBuildOutput(org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput) Test(org.junit.Test)

Example 8 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class OpenShiftBuildServiceUtilsTest method createBuildOutput_withDefaults_shouldReturnImageStreamTag.

@Test
public void createBuildOutput_withDefaults_shouldReturnImageStreamTag() {
    // When
    final BuildOutput result = createBuildOutput(new BuildServiceConfig(), new ImageName("my-app-image"));
    // Then
    assertThat(result).extracting(BuildOutput::getTo).hasFieldOrPropertyWithValue("kind", "ImageStreamTag").hasFieldOrPropertyWithValue("name", "my-app-image:latest");
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) ImageName(org.eclipse.jkube.kit.config.image.ImageName) BuildOutput(io.fabric8.openshift.api.model.BuildOutput) OpenShiftBuildServiceUtils.createBuildOutput(org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput) Test(org.junit.Test)

Example 9 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class KubernetesResourceUtil method extractImageUser.

private static String extractImageUser(String image, String groupId) {
    ImageName name = new ImageName(image);
    String imageUser = name.getUser();
    if (imageUser != null) {
        return imageUser;
    } else {
        return groupId;
    }
}
Also used : ImageName(org.eclipse.jkube.kit.config.image.ImageName)

Example 10 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class DockerAccessWithHcClient method saveImage.

@Override
public void saveImage(String image, String filename, ArchiveCompression compression) throws DockerAccessException {
    ImageName name = new ImageName(image);
    String url = urlBuilder.getImage(name);
    try {
        delegate.get(url, getImageResponseHandler(filename, compression), HTTP_OK);
    } catch (IOException e) {
        throw new DockerAccessException(e, "Unable to save '%s' to '%s'", image, filename);
    }
}
Also used : ImageName(org.eclipse.jkube.kit.config.image.ImageName) DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) IOException(java.io.IOException)

Aggregations

ImageName (org.eclipse.jkube.kit.config.image.ImageName)22 BuildServiceConfig (org.eclipse.jkube.kit.config.service.BuildServiceConfig)6 Test (org.junit.Test)6 IOException (java.io.IOException)5 BuildOutput (io.fabric8.openshift.api.model.BuildOutput)4 OpenShiftBuildServiceUtils.createBuildOutput (org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput)4 AuthConfig (org.eclipse.jkube.kit.build.api.auth.AuthConfig)3 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 WatcherException (io.fabric8.kubernetes.client.WatcherException)2 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)2 BuildConfigSpec (io.fabric8.openshift.api.model.BuildConfigSpec)2 BuildStrategy (io.fabric8.openshift.api.model.BuildStrategy)2 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)2 File (java.io.File)2 Map (java.util.Map)2 DockerAccessException (org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException)2 AuthConfigFactory (org.eclipse.jkube.kit.build.service.docker.auth.AuthConfigFactory)2 OpenShiftBuildServiceUtils.createBuildStrategy (org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildStrategy)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1