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);
}
}
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;
}
}
Aggregations