Search in sources :

Example 21 with RegistryException

use of com.google.cloud.tools.jib.api.RegistryException in project jib by GoogleContainerTools.

the class JibBuildRunnerTest method testBuildImage_other.

@Test
public void testBuildImage_other() throws InterruptedException, IOException, CacheDirectoryCreationException, RegistryException, ExecutionException {
    Mockito.doThrow(new RegistryException("messagePrefix")).when(mockJibContainerBuilder).containerize(mockContainerizer);
    try {
        testJibBuildRunner.runBuild();
        Assert.fail();
    } catch (BuildStepsExecutionException ex) {
        Assert.assertEquals(TEST_HELPFUL_SUGGESTIONS.none(), ex.getMessage());
    }
}
Also used : InsecureRegistryException(com.google.cloud.tools.jib.api.InsecureRegistryException) RegistryException(com.google.cloud.tools.jib.api.RegistryException) Test(org.junit.Test)

Example 22 with RegistryException

use of com.google.cloud.tools.jib.api.RegistryException in project jkube by eclipse.

the class JibServiceUtil method pushImage.

private static void pushImage(TarImage baseImage, String targetImageName, Credential credential, KitLogger logger) throws InterruptedException {
    final ExecutorService jibBuildExecutor = Executors.newCachedThreadPool();
    try {
        submitPushToJib(baseImage, getRegistryImage(targetImageName, credential), jibBuildExecutor, logger);
    } catch (RegistryException | CacheDirectoryCreationException | InvalidImageReferenceException | IOException | ExecutionException e) {
        logger.error("Exception occurred while pushing the image: %s, %s", targetImageName, e.getMessage());
        throw new IllegalStateException(e.getMessage(), e);
    } catch (InterruptedException ex) {
        logger.error("Thread interrupted", ex);
        throw ex;
    } finally {
        jibBuildExecutor.shutdown();
        jibBuildExecutor.awaitTermination(JIB_EXECUTOR_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS);
    }
}
Also used : CacheDirectoryCreationException(com.google.cloud.tools.jib.api.CacheDirectoryCreationException) ExecutorService(java.util.concurrent.ExecutorService) InvalidImageReferenceException(com.google.cloud.tools.jib.api.InvalidImageReferenceException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) RegistryException(com.google.cloud.tools.jib.api.RegistryException)

Example 23 with RegistryException

use of com.google.cloud.tools.jib.api.RegistryException in project geronimo-arthur by apache.

the class JibMojo method execute.

@Override
public void execute() {
    final JibContainerBuilder prepared = prepare();
    withExecutor(es -> {
        try {
            final Containerizer containerizer = createContainer();
            final JibContainer container = prepared.containerize(configure(containerizer, es));
            if (propertiesPrefix != null) {
                project.getProperties().setProperty(propertiesPrefix + "image.imageId", container.getImageId().getHash());
                project.getProperties().setProperty(propertiesPrefix + "image.digest", container.getDigest().getHash());
            }
            getLog().info("Built '" + to + "'");
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
        } catch (final RegistryException | IOException | CacheDirectoryCreationException | ExecutionException | InvalidImageReferenceException e) {
            throw new IllegalStateException(e);
        }
    });
}
Also used : CacheDirectoryCreationException(com.google.cloud.tools.jib.api.CacheDirectoryCreationException) JibContainer(com.google.cloud.tools.jib.api.JibContainer) InvalidImageReferenceException(com.google.cloud.tools.jib.api.InvalidImageReferenceException) Containerizer(com.google.cloud.tools.jib.api.Containerizer) JibContainerBuilder(com.google.cloud.tools.jib.api.JibContainerBuilder) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) RegistryException(com.google.cloud.tools.jib.api.RegistryException)

Aggregations

RegistryException (com.google.cloud.tools.jib.api.RegistryException)23 IOException (java.io.IOException)15 Test (org.junit.Test)12 ExecutionException (java.util.concurrent.ExecutionException)9 RegistryClient (com.google.cloud.tools.jib.registry.RegistryClient)8 CacheDirectoryCreationException (com.google.cloud.tools.jib.api.CacheDirectoryCreationException)7 DescriptorDigest (com.google.cloud.tools.jib.api.DescriptorDigest)6 Blob (com.google.cloud.tools.jib.blob.Blob)6 ImagesAndRegistryClient (com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.ImagesAndRegistryClient)6 EventHandlers (com.google.cloud.tools.jib.event.EventHandlers)6 DigestException (java.security.DigestException)6 ExecutorService (java.util.concurrent.ExecutorService)6 Assert (org.junit.Assert)6 InsecureRegistryException (com.google.cloud.tools.jib.api.InsecureRegistryException)4 InvalidImageReferenceException (com.google.cloud.tools.jib.api.InvalidImageReferenceException)4 Blobs (com.google.cloud.tools.jib.blob.Blobs)4 ProgressEventDispatcher (com.google.cloud.tools.jib.builder.ProgressEventDispatcher)4 ProgressEvent (com.google.cloud.tools.jib.event.events.ProgressEvent)4 ProgressEventHandler (com.google.cloud.tools.jib.event.progress.ProgressEventHandler)4 FailoverHttpClient (com.google.cloud.tools.jib.http.FailoverHttpClient)4