예제 #1
0
        public IActionResult PostSinkSecrets()
        {
            var sinkLogger = _loggerFactory.CreateLogger <SecretsSinker>();
            var sinker     = new SecretsSinker(sinkLogger, _kubeOptions, _providers, _config);

            _logger.LogInformation("Scheduling immediate secrets sink");
            sinker.UpdateAllSecretsAsync().FireAndForget(sinkLogger);
            return(Ok());
        }
        public Task StartAsync(CancellationToken cancellationToken)
        {
            var sinkerLogger = _loggerFactory.CreateLogger <SecretsSinker>();
            var schedule     = TimeSpan.FromSeconds(_configuration.RefreshInterval);

            _logger.LogInformation($"Starting {nameof(SecretsWatcherHostedService)} with a refresh rate of {schedule}");

            _sinker = new SecretsSinker(sinkerLogger, _kubeOptions, _providers, _configuration);
            _timer  = new Timer(async(object state) => { await _sinker.UpdateAllSecretsAsync(); }, null, TimeSpan.Zero, schedule);

            return(Task.CompletedTask);
        }