@Override public RegistryAuth authForSwarm() throws DockerException { final AccessToken accessToken; try { accessToken = getAccessToken(); } catch (IOException e) { // ignore the exception, as the user may not care if swarm is authenticated to use GCR log.warn("unable to get access token for Google Container Registry due to exception, " + "configuration for Swarm will not contain RegistryAuth for GCR", e); return null; } return authForAccessToken(accessToken); }
@Override public RegistryAuth authFor(final String imageName) throws DockerException { final String[] imageParts = imageName.split("/", 2); if (imageParts.length < 2 || !GCR_REGISTRIES.contains(imageParts[0])) { // not an image on GCR return null; } final AccessToken accessToken; try { accessToken = getAccessToken(); } catch (IOException e) { throw new DockerException(e); } return authForAccessToken(accessToken); }
@Override public RegistryConfigs authForBuild() throws DockerException { final AccessToken accessToken; try { accessToken = getAccessToken(); } catch (IOException e) { // do not fail as the GCR access token may not be necessary for building the image currently // being built log.warn("unable to get access token for Google Container Registry, " + "configuration for building image will not contain RegistryAuth for GCR", e); return RegistryConfigs.empty(); } final Map<String, RegistryAuth> configs = new HashMap<>(GCR_REGISTRIES.size()); for (String serverName : GCR_REGISTRIES) { configs.put(serverName, authForAccessToken(accessToken)); } return RegistryConfigs.create(configs); } }
@Override public RegistryAuth authForSwarm() throws DockerException { final AccessToken accessToken; try { accessToken = getAccessToken(); } catch (IOException e) { // ignore the exception, as the user may not care if swarm is authenticated to use GCR log.warn("unable to get access token for Google Container Registry due to exception, " + "configuration for Swarm will not contain RegistryAuth for GCR", e); return null; } return authForAccessToken(accessToken); }
@Override public RegistryAuth authFor(final String imageName) throws DockerException { final String[] imageParts = imageName.split("/", 2); if (imageParts.length < 2 || !GCR_REGISTRIES.contains(imageParts[0])) { // not an image on GCR return null; } final AccessToken accessToken; try { accessToken = getAccessToken(); } catch (IOException e) { throw new DockerException(e); } return authForAccessToken(accessToken); }
@Override public RegistryConfigs authForBuild() throws DockerException { final AccessToken accessToken; try { accessToken = getAccessToken(); } catch (IOException e) { // do not fail as the GCR access token may not be necessary for building the image currently // being built log.warn("unable to get access token for Google Container Registry, " + "configuration for building image will not contain RegistryAuth for GCR", e); return RegistryConfigs.empty(); } final Map<String, RegistryAuth> configs = new HashMap<>(GCR_REGISTRIES.size()); for (String serverName : GCR_REGISTRIES) { configs.put(serverName, authForAccessToken(accessToken)); } return RegistryConfigs.create(configs); } }