Example #1
0
        public async Task <bool> IsKnownRepository(string repository)
        {
            var repositories = await _client.DescribeRepositoriesAsync(new DescribeRepositoriesRequest());

            return(repositories.Repositories.Any(r =>
                                                 r.RepositoryUri.Equals(repository, StringComparison.OrdinalIgnoreCase)
                                                 ));
        }
Example #2
0
        public EcrRegistryClient BuildClient(ContainerRegistrySettings registrySettings)
        {
            var awsCredentials = new BasicAWSCredentials(
                registrySettings.Ecr.AccessKey,
                registrySettings.Ecr.SecretKey
                );

            var regionEndpoint = RegionEndpoint.GetBySystemName(registrySettings.Ecr.Region);
            var client         = new AmazonECRClient(awsCredentials, regionEndpoint);

            var repositories = client.DescribeRepositoriesAsync(new DescribeRepositoriesRequest()).Result;

            return(new EcrRegistryClient(_serviceProvider.GetService <ILogger <EcrRegistryClient> >(), client));
        }
Example #3
0
        private async Task <List <(string repositoryUri, string registryId, string repositoryName)> > GetRepositoriesInternal()
        {
            DescribeRepositoriesResponse?ecrResponse = null;
            var result = new List <(string repositoryUri, string registryId, string repositoryName)>();

            do
            {
                ecrResponse = await _client.DescribeRepositoriesAsync(new DescribeRepositoriesRequest()
                {
                    MaxResults = 1000,
                    NextToken  = (ecrResponse?.NextToken) ?? null
                });

                result.AddRange(ecrResponse.Repositories.Select(r => (r.RepositoryUri, r.RegistryId, r.RepositoryName)));
            }while (ecrResponse.NextToken != null);

            return(result);
        }