Search in sources :

Example 31 with TimerEventDispatcher

use of com.google.cloud.tools.jib.builder.TimerEventDispatcher in project jib by GoogleContainerTools.

the class PushImageStep method call.

@Override
public BuildResult call() throws IOException, RegistryException {
    EventHandlers eventHandlers = buildContext.getEventHandlers();
    try (TimerEventDispatcher ignored = new TimerEventDispatcher(eventHandlers, DESCRIPTION);
        ProgressEventDispatcher ignored2 = progressEventDispatcherFactory.create("pushing manifest for " + imageQualifier, 1)) {
        eventHandlers.dispatch(LogEvent.info("Pushing manifest for " + imageQualifier + "..."));
        registryClient.pushManifest(manifestTemplate, imageQualifier);
        return new BuildResult(imageDigest, imageId);
    }
}
Also used : ProgressEventDispatcher(com.google.cloud.tools.jib.builder.ProgressEventDispatcher) TimerEventDispatcher(com.google.cloud.tools.jib.builder.TimerEventDispatcher) EventHandlers(com.google.cloud.tools.jib.event.EventHandlers)

Example 32 with TimerEventDispatcher

use of com.google.cloud.tools.jib.builder.TimerEventDispatcher in project jib by GoogleContainerTools.

the class AuthenticatePushStep method call.

@Override
public RegistryClient call() throws CredentialRetrievalException, IOException, RegistryException {
    String registry = buildContext.getTargetImageConfiguration().getImageRegistry();
    try (ProgressEventDispatcher progressDispatcher = progressEventDispatcherFactory.create("authenticating push to " + registry, 2);
        TimerEventDispatcher ignored2 = new TimerEventDispatcher(buildContext.getEventHandlers(), String.format(DESCRIPTION, registry))) {
        Credential credential = RegistryCredentialRetriever.getTargetImageCredential(buildContext).orElse(null);
        progressDispatcher.dispatchProgress(1);
        RegistryClient registryClient = buildContext.newTargetImageRegistryClientFactory().setCredential(credential).newRegistryClient();
        if (!registryClient.doPushBearerAuth()) {
            // server returned "WWW-Authenticate: Basic ..." (e.g., local Docker registry)
            if (credential != null && !credential.isOAuth2RefreshToken()) {
                registryClient.configureBasicAuth();
            }
        }
        return registryClient;
    }
}
Also used : Credential(com.google.cloud.tools.jib.api.Credential) ProgressEventDispatcher(com.google.cloud.tools.jib.builder.ProgressEventDispatcher) TimerEventDispatcher(com.google.cloud.tools.jib.builder.TimerEventDispatcher) RegistryClient(com.google.cloud.tools.jib.registry.RegistryClient)

Aggregations

TimerEventDispatcher (com.google.cloud.tools.jib.builder.TimerEventDispatcher)32 ProgressEventDispatcher (com.google.cloud.tools.jib.builder.ProgressEventDispatcher)28 EventHandlers (com.google.cloud.tools.jib.event.EventHandlers)22 DescriptorDigest (com.google.cloud.tools.jib.api.DescriptorDigest)12 Image (com.google.cloud.tools.jib.image.Image)10 RegistryClient (com.google.cloud.tools.jib.registry.RegistryClient)10 IOException (java.io.IOException)10 BlobDescriptor (com.google.cloud.tools.jib.blob.BlobDescriptor)8 RegistryException (com.google.cloud.tools.jib.api.RegistryException)6 BuildContext (com.google.cloud.tools.jib.configuration.BuildContext)6 ImageToJsonTranslator (com.google.cloud.tools.jib.image.json.ImageToJsonTranslator)6 ImmutableList (com.google.common.collect.ImmutableList)6 Credential (com.google.cloud.tools.jib.api.Credential)4 LogEvent (com.google.cloud.tools.jib.api.LogEvent)4 ImagesAndRegistryClient (com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.ImagesAndRegistryClient)4 Cache (com.google.cloud.tools.jib.cache.Cache)4 CachedLayer (com.google.cloud.tools.jib.cache.CachedLayer)4 JibSystemProperties (com.google.cloud.tools.jib.global.JibSystemProperties)4 Digests (com.google.cloud.tools.jib.hash.Digests)4 BuildableManifestTemplate (com.google.cloud.tools.jib.image.json.BuildableManifestTemplate)4