Пример #1
0
        private async Task DeleteRepositoryAsync(IAcrClient acrClient, List <string> deletedRepos, Repository repository)
        {
            string[] manifestsDeleted;
            string[] tagsDeleted;

            ManifestAttributes[] manifests = (await acrClient.GetRepositoryManifestsAsync(repository.Name)).Manifests.ToArray();

            if (!Options.IsDryRun)
            {
                DeleteRepositoryResponse deleteResponse =
                    await acrClient.DeleteRepositoryAsync(repository.Name);

                manifestsDeleted = deleteResponse.ManifestsDeleted;
                tagsDeleted      = deleteResponse.TagsDeleted;
            }
            else
            {
                manifestsDeleted = manifests
                                   .Select(manifest => manifest.Digest)
                                   .ToArray();

                tagsDeleted = manifests
                              .SelectMany(manifest => manifest.Tags)
                              .ToArray();
            }

            StringBuilder messageBuilder = new StringBuilder();

            messageBuilder.AppendLine($"Deleted repository '{repository.Name}'");
            messageBuilder.AppendLine($"\tIncluded manifests:");
            foreach (string manifest in manifestsDeleted.OrderBy(manifest => manifest))
            {
                messageBuilder.AppendLine($"\t{manifest}");
            }

            messageBuilder.AppendLine();
            messageBuilder.AppendLine($"\tIncluded tags:");
            foreach (string tag in tagsDeleted.OrderBy(tag => tag))
            {
                messageBuilder.AppendLine($"\t{tag}");
            }

            _loggerService.WriteMessage(messageBuilder.ToString());

            lock (deletedRepos)
            {
                deletedRepos.Add(repository.Name);
            }
        }
Пример #2
0
        public static DeleteRepositoryResponse Unmarshall(UnmarshallerContext context)
        {
            DeleteRepositoryResponse deleteRepositoryResponse = new DeleteRepositoryResponse();

            deleteRepositoryResponse.HttpResponse = context.HttpResponse;
            deleteRepositoryResponse.RequestId    = context.StringValue("DeleteRepository.RequestId");
            deleteRepositoryResponse.ErrorCode    = context.StringValue("DeleteRepository.ErrorCode");
            deleteRepositoryResponse.Success      = context.BooleanValue("DeleteRepository.Success");
            deleteRepositoryResponse.ErrorMessage = context.StringValue("DeleteRepository.ErrorMessage");

            DeleteRepositoryResponse.DeleteRepository_Result result = new DeleteRepositoryResponse.DeleteRepository_Result();
            result.Result = context.BooleanValue("DeleteRepository.Result.Result");
            deleteRepositoryResponse.Result = result;

            return(deleteRepositoryResponse);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DeleteRepositoryResponse response = new DeleteRepositoryResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("repository", targetDepth))
                {
                    var unmarshaller = RepositoryUnmarshaller.Instance;
                    response.Repository = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }