Skip to content

Commit 81d1154

Browse files
authored
Prepare ACR for beta release. (Azure#28036)
* Prepare ACR for beta release. * Incorporate PR comments.
1 parent 571c1d0 commit 81d1154

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

sdk/containerregistry/azure-containers-containerregistry/CHANGELOG.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
- Added interfaces from `com.azure.core.client.traits` to `ContainerRegistryClientBuilder`.
77
- Added support for `ContainerRegistryBlobAsyncClient`.
88

9-
### Breaking Changes
10-
11-
### Bugs Fixed
12-
13-
### Other Changes
14-
159
## 1.0.2 (2022-03-08)
1610

1711
### Other Changes

sdk/containerregistry/azure-containers-containerregistry/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ and then include the direct dependency in the dependencies section without the v
5656
<dependency>
5757
<groupId>com.azure</groupId>
5858
<artifactId>azure-containers-containerregistry</artifactId>
59-
<version>1.0.0</version>
59+
<version>1.1.0-beta.1</version>
6060
</dependency>
6161
```
6262
[//]: # ({x-version-update-end})

sdk/containerregistry/azure-containers-containerregistry/src/main/java/com/azure/containers/containerregistry/implementation/ContainerRegistryRedirectPolicy.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
import java.util.Set;
2020

2121
import static com.azure.containers.containerregistry.implementation.UtilsImpl.DOCKER_DIGEST_HEADER_NAME;
22+
import static com.azure.containers.containerregistry.implementation.UtilsImpl.getDigestFromHeader;
2223

2324
/**
2425
* <p> Redirect policy for the container registry.</p>
2526
*
2627
* <p> This reads some of the headers that are returned from the redirect call that core redirect policy does not handle.</p>
2728
*/
2829
public final class ContainerRegistryRedirectPolicy implements HttpPipelinePolicy {
29-
private static final ClientLogger LOGGER = new ClientLogger(com.azure.core.http.policy.DefaultRedirectStrategy.class);
30+
private static final ClientLogger LOGGER = new ClientLogger(ContainerRegistryRedirectPolicy.class);
3031
private static final int MAX_REDIRECT_ATTEMPTS;
3132
private static final String REDIRECT_LOCATION_HEADER_NAME;
3233
private static final int PERMANENT_REDIRECT_STATUS_CODE;
@@ -60,9 +61,9 @@ private Mono<HttpResponse> attemptRedirect(HttpPipelineCallContext context, Http
6061
return httpResponse.getBody().ignoreElements()
6162
.then(this.attemptRedirect(context, next, redirectRequestCopy, redirectAttempt + 1, attemptedRedirectUrls))
6263
.flatMap(newResponse -> {
63-
String digest = httpResponse.getHeaders().getValue(DOCKER_DIGEST_HEADER_NAME);
64+
String digest = getDigestFromHeader(httpResponse.getHeaders());
6465
if (digest != null) {
65-
newResponse.getHeaders().add(DOCKER_DIGEST_HEADER_NAME, digest);
66+
newResponse.getHeaders().set(DOCKER_DIGEST_HEADER_NAME, digest);
6667
}
6768
return Mono.just(newResponse);
6869
});
@@ -76,7 +77,7 @@ public boolean shouldAttemptRedirect(HttpPipelineCallContext context, HttpRespon
7677
if (this.isValidRedirectStatusCode(httpResponse.getStatusCode()) && this.isValidRedirectCount(tryCount) && this.isAllowedRedirectMethod(httpResponse.getRequest().getHttpMethod())) {
7778
String redirectUrl = this.tryGetRedirectHeader(httpResponse.getHeaders(), REDIRECT_LOCATION_HEADER_NAME);
7879
if (redirectUrl != null && !this.alreadyAttemptedRedirectUrl(redirectUrl, attemptedRedirectUrls)) {
79-
LOGGER.verbose("[Redirecting] Try count: {}, Attempted Redirect URLs: {}", tryCount, String.join(",", attemptedRedirectUrls));
80+
LOGGER.verbose("[Redirecting] Try count:" + tryCount + ", Attempted Redirect URLs:" + String.join(",", attemptedRedirectUrls));
8081
attemptedRedirectUrls.add(redirectUrl);
8182
return true;
8283
} else {
@@ -97,7 +98,7 @@ private HttpRequest createRedirectRequest(HttpResponse httpResponse) {
9798

9899
private boolean alreadyAttemptedRedirectUrl(String redirectUrl, Set<String> attemptedRedirectUrls) {
99100
if (attemptedRedirectUrls.contains(redirectUrl)) {
100-
LOGGER.error("Request was redirected more than once to: {}", new Object[]{redirectUrl});
101+
LOGGER.error("Request was redirected more than once to:" + redirectUrl);
101102
return true;
102103
} else {
103104
return false;
@@ -106,7 +107,7 @@ private boolean alreadyAttemptedRedirectUrl(String redirectUrl, Set<String> atte
106107

107108
private boolean isValidRedirectCount(int tryCount) {
108109
if (tryCount >= MAX_REDIRECT_ATTEMPTS) {
109-
LOGGER.error("Request has been redirected more than {} times.", new Object[]{MAX_REDIRECT_ATTEMPTS});
110+
LOGGER.error("Request has been redirected more than " + MAX_REDIRECT_ATTEMPTS + "times");
110111
return false;
111112
} else {
112113
return true;
@@ -117,7 +118,7 @@ private boolean isAllowedRedirectMethod(HttpMethod httpMethod) {
117118
if (REDIRECT_ALLOWED_METHODS.contains(httpMethod)) {
118119
return true;
119120
} else {
120-
LOGGER.error("Request was redirected from an invalid redirect allowed method: {}", new Object[]{httpMethod});
121+
LOGGER.error("Request was redirected from an invalid redirect allowed method:" + httpMethod);
121122
return false;
122123
}
123124
}
@@ -129,7 +130,7 @@ private boolean isValidRedirectStatusCode(int statusCode) {
129130
String tryGetRedirectHeader(HttpHeaders headers, String headerName) {
130131
String headerValue = headers.getValue(headerName);
131132
if (CoreUtils.isNullOrEmpty(headerValue)) {
132-
LOGGER.error("Redirect url was null for header name: {}, request redirect was terminated.", headerName);
133+
LOGGER.error("Redirect url was null for header name:" + headerName + " request redirect was terminated.");
133134
return null;
134135
} else {
135136
return headerValue;

sdk/containerregistry/azure-containers-containerregistry/src/main/java/com/azure/containers/containerregistry/implementation/UtilsImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ public static <T, R> PagedResponse<T> getPagedResponseWithContinuationToken(Page
339339

340340
/**
341341
* Get the digest from the response header if available.
342-
* @param response The HttpResponse to parse.
342+
* @param headers The headers to parse.
343343
* @return The digest value.
344344
*/
345-
public static <T> String getDigestFromHeader(Response<T> response) {
346-
return response.getHeaders().getValue(DOCKER_DIGEST_HEADER_NAME);
345+
public static <T> String getDigestFromHeader(HttpHeaders headers) {
346+
return headers.getValue(DOCKER_DIGEST_HEADER_NAME);
347347
}
348348
}

sdk/containerregistry/azure-containers-containerregistry/src/main/java/com/azure/containers/containerregistry/specialized/ContainerRegistryBlobAsyncClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Mono<Response<DownloadManifestResult>> downloadManifestWithResponse(DownloadMani
284284

285285
return this.registriesImpl.getManifestWithResponseAsync(repositoryName, tagOrDigest, UtilsImpl.OCI_MANIFEST_MEDIA_TYPE, context)
286286
.flatMap(response -> {
287-
String digest = UtilsImpl.getDigestFromHeader(response);
287+
String digest = UtilsImpl.getDigestFromHeader(response.getHeaders());
288288
ManifestWrapper wrapper = response.getValue();
289289

290290
// The service wants us to validate the digest here since a lot of customers forget to do it before consuming
@@ -341,7 +341,7 @@ Mono<Response<DownloadBlobResult>> downloadBlobWithResponse(String digest, Conte
341341
}
342342

343343
return this.blobsImpl.getBlobWithResponseAsync(repositoryName, digest, context).flatMap(streamResponse -> {
344-
String resDigest = UtilsImpl.getDigestFromHeader(streamResponse);
344+
String resDigest = UtilsImpl.getDigestFromHeader(streamResponse.getHeaders());
345345

346346
return BinaryData.fromFlux(streamResponse.getValue())
347347
.flatMap(binaryData -> {

0 commit comments

Comments
 (0)