Beispiel #1
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            _log.LogTrace("ContainerRegistryHostedService::StartAsync() >>");

            using var scope = _serviceProvider.CreateScope();

            var conf = _configuration.Value;

            // register image repositories
            _log.LogInformation("Adding Container Registries");
            conf.Registries.ForEach(settings =>
            {
                _log.LogDebug($"Adding container registry {settings.Name}");
                switch (settings.Type)
                {
                case ContainerRegistryType.DockerRegistry:
                    break;

                case ContainerRegistryType.Ecr:
                    _registryClientPool.AddClient(
                        new EcrClientFactory(scope.ServiceProvider).BuildClient(settings)
                        );
                    break;
                }
            });

            var scheduler = scope.ServiceProvider.GetService <IScheduler>();
            await scheduler.StartRecurringJob <ApplicationContainerImagePollingJob>(
                "ApplicationContainerImagePollingJob",
                "ContainerRegistryPollingJobs",
                TimeSpan.FromSeconds(60)
                );

            _log.LogTrace("ContainerRegistryHostedService::StartAsync() <<");
        }
Beispiel #2
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _log.LogTrace("DummyContainerRegistryHostedService::StartAsync() >>");

            using var scope = _serviceProvider.CreateScope();

            var conf = _configuration.Value;

            // register image repositories
            _log.LogInformation("Adding Container Registries");
            var dummyRegistryClients = conf.Registries
                                       .Where(x => x.Type == ContainerRegistryType.Dummy)
                                       .Select(settings => new DummyRegistryClient(settings.Dummy))
                                       .ToList();

            dummyRegistryClients.ForEach(x => _registryClientPool.AddClient(x));

            _log.LogTrace("DummyContainerRegistryHostedService::StartAsync() <<");

            return(Task.CompletedTask);
        }