public DockerHubClient( ILogger logger, HttpClient httpClient, DockerRegistryInfo registry, IEnumerable <string> repos, IConfigurationRoot config) : base(logger, httpClient, (DockerHubRegistryInfo)registry, repos) { this.config = config; }
public IDockerRegistryClient CreateClient(DockerRegistryInfo registry, IEnumerable <string> repos) { switch (registry.RegistryType) { case RegistryType.DockerHub: return(new DockerHubClient(this.logger, this.httpClient, registry, repos, this.config)); case RegistryType.AzureContainerRegistry: return(new AcrClient(this.logger, this.httpClient, registry, repos)); default: throw new NotSupportedException($"Unknown registry type: {registry.RegistryType}"); } }
public async Task Run( [TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, ExecutionContext context) { if (myTimer.IsPastDue) { log.LogInformation("Timer is running late!"); } log.LogInformation("Checking tag changes"); string storageConnectionString = config["AzureWebJobsStorage"]; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable digestsTable = tableClient.GetTableReference("digests"); await digestsTable.CreateIfNotExistsAsync(); CloudTable subscriptionsTable = tableClient.GetTableReference("subscriptions"); await subscriptionsTable.CreateIfNotExistsAsync(); var subscriptions = subscriptionsTable.ExecuteQuery(new TableQuery <Subscription>()); var comparer = new DockerRegistryIdentifierComparer(); var subscriptionsByRegistry = subscriptions.GroupBy(sub => sub, comparer); List <Task> checkTagTasks = new List <Task>(); foreach (var registrySubscriptions in subscriptionsByRegistry) { var registryClient = this.dockerRegistryClientFactory.CreateClient( DockerRegistryInfo.Create(registrySubscriptions.Key), registrySubscriptions.Select(sub => sub.Repo).ToArray()); foreach (var subscription in registrySubscriptions) { checkTagTasks.Add(CheckTagChangeAsync(subscription, registryClient, digestsTable)); } } await Task.WhenAll(checkTagTasks); }
public AcrClient(ILogger logger, HttpClient httpClient, DockerRegistryInfo registryInfo, IEnumerable <string> repos) : base(logger, httpClient, (AcrInfo)registryInfo, repos) { this.logger = logger; this.httpClient = httpClient; }