Skip to content

[ACR] Fix content validation issues for github.io #37269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions sdk/containerregistry/azure-containerregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ For more information please see [Container Registry Concepts](https://docs.micro
The following sections provide several code snippets covering some of the most common ACR Service tasks, including:

- Registry operations:
- [List repositories](#list-repositories)
- [List tags with anonymous access](#list-tags-with-anonymous-access)
- [Set artifact properties](#set-artifact-properties)
- [Delete images](#delete-images)
- [List repositories](#list-repositories "List repositories")
- [List tags with anonymous access](#list-tags-with-anonymous-access "List tags with anonymous access")
- [Set artifact properties](#set-artifact-properties "Set artifact properties")
- [Delete images](#delete-images "Delete images")
- Blob and manifest operations:
- [Upload images](#upload-images)
- [Download images](#download-images)
- [Delete manifest](#delete-manifest)
- [Delete blob](#delete-blob)
- [Upload images](#upload-images "Upload images")
- [Download images](#download-images "Download images")
- [Delete manifests](#delete-manifests "Delete manifests")
- [Delete blobs](#delete-blobs "Delete blobs")

Please note that each sample assumes there is a `CONTAINERREGISTRY_ENDPOINT` environment variable set to a string containing the `https://` prefix and the name of the login server, for example "https://myregistry.azurecr.io". Anonymous access samples are getting endpoint value from environment variable`CONTAINERREGISTRY_ANONREGISTRY_ENDPOINT`.

Expand Down Expand Up @@ -238,7 +238,7 @@ with ContainerRegistryClient(self.endpoint, self.credential) as client:

<!-- END SNIPPET -->

### Delete manifest
### Delete manifests

<!-- SNIPPET:sample_set_get_image.delete_manifest -->

Expand All @@ -251,7 +251,7 @@ with ContainerRegistryClient(self.endpoint, self.credential) as client:

<!-- END SNIPPET -->

### Delete blob
### Delete blobs

<!-- SNIPPET:sample_set_get_image.delete_blob -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class AnonymousAccessCredential(TokenCredential):
def get_token(
self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs
self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs: Any
) -> AccessToken:
raise ValueError("This credential cannot be used to obtain access tokens.")

Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
)

def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decorator
self, challenge: str, **kwargs
self, challenge: str, **kwargs: Any
) -> Optional[str]:
parsed_challenge = _parse_challenge(challenge)
return self.exchange_refresh_token_for_access_token(
Expand All @@ -58,7 +58,7 @@ def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decora
)

def exchange_refresh_token_for_access_token( # pylint:disable=client-method-missing-tracing-decorator
self, refresh_token: str, service: str, scope: str, grant_type: Union[str, TokenGrantType], **kwargs
self, refresh_token: str, service: str, scope: str, grant_type: Union[str, TokenGrantType], **kwargs: Any
) -> Optional[str]:
auth_operation = cast(AuthenticationOperations, self._client.authentication)
access_token = auth_operation.exchange_acr_refresh_token_for_acr_access_token(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TransportWrapper(HttpTransport):
def __init__(self, transport):
self._transport = transport

def send(self, request, **kwargs):
def send(self, request, **kwargs: Any):
return self._transport.send(request, **kwargs)

def open(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ def _get_digest_from_tag(self, repository: str, tag: str) -> str:
return tag_props.digest

@distributed_trace
def delete_repository(self, repository: str, **kwargs) -> None:
def delete_repository(self, repository: str, **kwargs: Any) -> None:
"""Delete a repository. If the repository cannot be found or a response status code of
404 is returned an error will not be raised.

:param str repository: The repository to delete
:returns: None
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:

Expand All @@ -138,14 +138,14 @@ def delete_repository(self, repository: str, **kwargs) -> None:
self._client.container_registry.delete_repository(repository, **kwargs)

@distributed_trace
def list_repository_names(self, *, results_per_page: Optional[int] = None, **kwargs) -> ItemPaged[str]:
def list_repository_names(self, *, results_per_page: Optional[int] = None, **kwargs: Any) -> ItemPaged[str]:
"""List all repositories

:keyword results_per_page: Number of repositories to return per page
:paramtype results_per_page: int
:returns: An iterable of strings
:rtype: ~azure.core.paging.ItemPaged[str]
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:

.. admonition:: Example:

Expand Down Expand Up @@ -244,13 +244,13 @@ def get_next(next_link=None):
return ItemPaged(get_next, extract_data)

@distributed_trace
def get_repository_properties(self, repository: str, **kwargs) -> RepositoryProperties:
def get_repository_properties(self, repository: str, **kwargs: Any) -> RepositoryProperties:
"""Get the properties of a repository

:param str repository: Name of the repository
:rtype: ~azure.containerregistry.RepositoryProperties
:return: The properties of a repository
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:
"""
return RepositoryProperties._from_generated( # pylint: disable=protected-access
self._client.container_registry.get_properties(repository, **kwargs)
Expand All @@ -263,7 +263,7 @@ def list_manifest_properties(
*,
order_by: Optional[Union["ArtifactManifestOrder", str]] = None,
results_per_page: Optional[int] = None,
**kwargs,
**kwargs: Any,
) -> ItemPaged[ArtifactManifestProperties]:
"""List the artifacts for a repository

Expand All @@ -274,7 +274,7 @@ def list_manifest_properties(
:paramtype results_per_page: int
:returns: An iterable of :class:`~azure.containerregistry.ArtifactManifestProperties`
:rtype: ~azure.core.paging.ItemPaged[~azure.containerregistry.ArtifactManifestProperties]
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:
"""
name = repository
last = kwargs.pop("last", None)
Expand Down Expand Up @@ -380,15 +380,15 @@ def get_next(next_link=None):
return ItemPaged(get_next, extract_data)

@distributed_trace
def delete_tag(self, repository: str, tag: str, **kwargs) -> None:
def delete_tag(self, repository: str, tag: str, **kwargs: Any) -> None:
"""Delete a tag from a repository. If the tag cannot be found or a response status code of
404 is returned an error will not be raised.

:param str repository: Name of the repository the tag belongs to
:param str tag: The tag to be deleted
:returns: None
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:

Example

Expand All @@ -404,14 +404,14 @@ def delete_tag(self, repository: str, tag: str, **kwargs) -> None:
self._client.container_registry.delete_tag(repository, tag, **kwargs)

@distributed_trace
def get_manifest_properties(self, repository: str, tag_or_digest: str, **kwargs) -> ArtifactManifestProperties:
def get_manifest_properties(self, repository: str, tag_or_digest: str, **kwargs: Any) -> ArtifactManifestProperties:
"""Get the properties of a registry artifact

:param str repository: Name of the repository
:param str tag_or_digest: Tag or digest of the manifest
:return: The properties of a registry artifact
:rtype: ~azure.containerregistry.ArtifactManifestProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand All @@ -437,14 +437,14 @@ def get_manifest_properties(self, repository: str, tag_or_digest: str, **kwargs)
)

@distributed_trace
def get_tag_properties(self, repository: str, tag: str, **kwargs) -> ArtifactTagProperties:
def get_tag_properties(self, repository: str, tag: str, **kwargs: Any) -> ArtifactTagProperties:
"""Get the properties for a tag

:param str repository: Name of the repository
:param str tag: The tag to get tag properties for
:return: The properties for a tag
:rtype: ~azure.containerregistry.ArtifactTagProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand All @@ -470,7 +470,7 @@ def list_tag_properties(
*,
order_by: Optional[Union["ArtifactTagOrder", str]] = None,
results_per_page: Optional[int] = None,
**kwargs,
**kwargs: Any,
) -> ItemPaged[ArtifactTagProperties]:
"""List the tags for a repository

Expand All @@ -481,7 +481,7 @@ def list_tag_properties(
:paramtype results_per_page: int
:returns: An iterable of :class:`~azure.containerregistry.ArtifactTagProperties`
:rtype: ~azure.core.paging.ItemPaged[~azure.containerregistry.ArtifactTagProperties]
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand Down Expand Up @@ -612,7 +612,7 @@ def update_manifest_properties(
parameter. Please provide either this or individual keyword parameters.
:type properties: ~azure.containerregistry.ArtifactManifestProperties
:rtype: ~azure.containerregistry.ArtifactManifestProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand Down Expand Up @@ -656,7 +656,7 @@ def update_manifest_properties(
:keyword bool can_read: Read permissions for a manifest.
:keyword bool can_write: Write permissions for a manifest.
:rtype: ~azure.containerregistry.ArtifactManifestProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand All @@ -679,7 +679,7 @@ def update_manifest_properties(

@distributed_trace
def update_manifest_properties(
self, *args: Union[str, ArtifactManifestProperties], **kwargs
self, *args: Union[str, ArtifactManifestProperties], **kwargs: Any
) -> ArtifactManifestProperties:
repository = str(args[0])
tag_or_digest = str(args[1])
Expand Down Expand Up @@ -720,7 +720,7 @@ def update_tag_properties(
parameter. Please provide either this or individual keyword parameters.
:type properties: ~azure.containerregistry.ArtifactTagProperties
:rtype: ~azure.containerregistry.ArtifactTagProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand Down Expand Up @@ -761,7 +761,7 @@ def update_tag_properties(
:keyword bool can_read: Read permissions for a tag.
:keyword bool can_write: Write permissions for a tag.
:rtype: ~azure.containerregistry.ArtifactTagProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:

Example

Expand All @@ -782,7 +782,7 @@ def update_tag_properties(
"""

@distributed_trace
def update_tag_properties(self, *args: Union[str, ArtifactTagProperties], **kwargs) -> ArtifactTagProperties:
def update_tag_properties(self, *args: Union[str, ArtifactTagProperties], **kwargs: Any) -> ArtifactTagProperties:
repository = str(args[0])
tag = str(args[1])
properties = None
Expand Down Expand Up @@ -817,7 +817,7 @@ def update_repository_properties(
parameter. Please provide either this or individual keyword parameters.
:type properties: ~azure.containerregistry.RepositoryProperties
:rtype: ~azure.containerregistry.RepositoryProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:
"""

@overload
Expand All @@ -841,11 +841,13 @@ def update_repository_properties(
:keyword bool can_read: Read permissions for a repository.
:keyword bool can_write: Write permissions for a repository.
:rtype: ~azure.containerregistry.RepositoryProperties
:raises: ~azure.core.exceptions.ResourceNotFoundError
:raises ~azure.core.exceptions.ResourceNotFoundError:
"""

@distributed_trace
def update_repository_properties(self, *args: Union[str, RepositoryProperties], **kwargs) -> RepositoryProperties:
def update_repository_properties(
self, *args: Union[str, RepositoryProperties], **kwargs: Any
) -> RepositoryProperties:
repository = str(args[0])
properties = None
if len(args) == 2:
Expand All @@ -872,7 +874,7 @@ def set_manifest(
*,
tag: Optional[str] = None,
media_type: str = OCI_IMAGE_MANIFEST,
**kwargs,
**kwargs: Any,
) -> str:
"""Set a manifest for an artifact.

Expand Down Expand Up @@ -919,7 +921,7 @@ def set_manifest(
return digest

@distributed_trace
def get_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> GetManifestResult:
def get_manifest(self, repository: str, tag_or_digest: str, **kwargs: Any) -> GetManifestResult:
"""Get the manifest for an artifact.

:param str repository: Name of the repository.
Expand Down Expand Up @@ -965,7 +967,7 @@ def get_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> GetMani
return GetManifestResult(digest=digest, manifest=manifest_json, media_type=media_type)

@distributed_trace
def upload_blob(self, repository: str, data: IO[bytes], **kwargs) -> Tuple[str, int]:
def upload_blob(self, repository: str, data: IO[bytes], **kwargs: Any) -> Tuple[str, int]:
"""Upload an artifact blob.

:param str repository: Name of the repository.
Expand Down Expand Up @@ -1017,7 +1019,7 @@ def _upload_blob_chunk(self, location: str, data: IO[bytes], **kwargs) -> Tuple[
return f"sha256:{hasher.hexdigest()}", location, blob_size

@distributed_trace
def download_blob(self, repository: str, digest: str, **kwargs) -> DownloadBlobStream:
def download_blob(self, repository: str, digest: str, **kwargs: Any) -> DownloadBlobStream:
"""Download a blob that is part of an artifact to a stream.

:param str repository: Name of the repository.
Expand Down Expand Up @@ -1052,14 +1054,14 @@ def download_blob(self, repository: str, digest: str, **kwargs) -> DownloadBlobS
)

@distributed_trace
def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> None:
def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs: Any) -> None:
"""Delete a manifest. If the manifest cannot be found or a response status code of
404 is returned an error will not be raised.

:param str repository: Name of the repository the manifest belongs to
:param str tag_or_digest: Tag or digest of the manifest to be deleted
:returns: None
:raises: ~azure.core.exceptions.HttpResponseError
:raises ~azure.core.exceptions.HttpResponseError:

Example

Expand All @@ -1077,7 +1079,7 @@ def delete_manifest(self, repository: str, tag_or_digest: str, **kwargs) -> None
self._client.container_registry.delete_manifest(repository, tag_or_digest, **kwargs)

@distributed_trace
def delete_blob(self, repository: str, digest: str, **kwargs) -> None:
def delete_blob(self, repository: str, digest: str, **kwargs: Any) -> None:
"""Delete a blob. If the blob cannot be found or a response status code of
404 is returned an error will not be raised.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, endpoint: str, credential: TokenCredential, **kwargs: Any) ->
self._expiration_time: float = 0

def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decorator
self, challenge: str, **kwargs
self, challenge: str, **kwargs: Any
) -> Optional[str]:
parsed_challenge = _parse_challenge(challenge)
refresh_token = self.get_refresh_token(parsed_challenge["service"], **kwargs)
Expand All @@ -66,15 +66,15 @@ def get_acr_access_token( # pylint:disable=client-method-missing-tracing-decora
)

def get_refresh_token( # pylint:disable=client-method-missing-tracing-decorator
self, service: str, **kwargs
self, service: str, **kwargs: Any
) -> str:
if not self._refresh_token or self._expiration_time - time.time() > 300:
self._refresh_token = self.exchange_aad_token_for_refresh_token(service, **kwargs)
self._expiration_time = _parse_exp_time(self._refresh_token)
return self._refresh_token

def exchange_aad_token_for_refresh_token( # pylint:disable=client-method-missing-tracing-decorator
self, service: str, **kwargs
self, service: str, **kwargs: Any
) -> str:
auth_operation = cast(AuthenticationOperations, self._client.authentication)
refresh_token = auth_operation.exchange_aad_access_token_for_acr_refresh_token(
Expand All @@ -86,7 +86,7 @@ def exchange_aad_token_for_refresh_token( # pylint:disable=client-method-missin
return refresh_token.refresh_token if refresh_token.refresh_token is not None else ""

def exchange_refresh_token_for_access_token( # pylint:disable=client-method-missing-tracing-decorator
self, refresh_token: str, service: str, scope: str, **kwargs
self, refresh_token: str, service: str, scope: str, **kwargs: Any
) -> Optional[str]:
auth_operation = cast(AuthenticationOperations, self._client.authentication)
access_token = auth_operation.exchange_acr_refresh_token_for_acr_access_token(
Expand Down
Loading