Search in sources :

Example 1 with RegistryAuthenticator

use of com.google.cloud.tools.jib.registry.RegistryAuthenticator in project jib by google.

the class AuthenticatePushStep method call.

/**
 * Depends on {@link RetrieveRegistryCredentialsStep}.
 */
@Override
@Nullable
public Authorization call() throws ExecutionException, InterruptedException, RegistryAuthenticationFailedException, IOException, RegistryException {
    try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), String.format(DESCRIPTION, buildConfiguration.getTargetRegistry()))) {
        Authorization registryCredentials = NonBlockingFutures.get(registryCredentialsFuture);
        RegistryAuthenticator registryAuthenticator = RegistryAuthenticators.forOther(buildConfiguration.getTargetRegistry(), buildConfiguration.getTargetRepository());
        if (registryAuthenticator == null) {
            return registryCredentials;
        }
        return registryAuthenticator.setAuthorization(NonBlockingFutures.get(registryCredentialsFuture)).authenticatePush();
    }
}
Also used : Authorization(com.google.cloud.tools.jib.http.Authorization) Timer(com.google.cloud.tools.jib.Timer) RegistryAuthenticator(com.google.cloud.tools.jib.registry.RegistryAuthenticator) Nullable(javax.annotation.Nullable)

Example 2 with RegistryAuthenticator

use of com.google.cloud.tools.jib.registry.RegistryAuthenticator in project jib by google.

the class AuthenticatePullStep method call.

/**
 * Depends on {@link RetrieveRegistryCredentialsStep}.
 */
@Override
public Authorization call() throws RegistryAuthenticationFailedException, IOException, RegistryException, ExecutionException, InterruptedException {
    try (Timer ignored = new Timer(buildConfiguration.getBuildLogger(), String.format(DESCRIPTION, buildConfiguration.getBaseImageRegistry()))) {
        Authorization registryCredentials = NonBlockingFutures.get(registryCredentialsFuture);
        RegistryAuthenticator registryAuthenticator = RegistryAuthenticators.forOther(buildConfiguration.getBaseImageRegistry(), buildConfiguration.getBaseImageRepository());
        if (registryAuthenticator == null) {
            return registryCredentials;
        }
        return registryAuthenticator.setAuthorization(registryCredentials).authenticatePull();
    }
}
Also used : Authorization(com.google.cloud.tools.jib.http.Authorization) Timer(com.google.cloud.tools.jib.Timer) RegistryAuthenticator(com.google.cloud.tools.jib.registry.RegistryAuthenticator)

Aggregations

Timer (com.google.cloud.tools.jib.Timer)2 Authorization (com.google.cloud.tools.jib.http.Authorization)2 RegistryAuthenticator (com.google.cloud.tools.jib.registry.RegistryAuthenticator)2 Nullable (javax.annotation.Nullable)1