示例#1
0
        public ServerInstance(string key, InstanceConfiguration instanceConfig, IConfiguration configuration,
                              ILogger <UpdateProviderJenkins> jenkinsLogger, ServersConfiguration serversConfiguration,
                              ILogger <ServerInstance> logger, IBackgroundTaskQueue taskQueue, ILogger <UpdateProviderLocal> localLogger,
                              ILogger <UpdateProviderGit> gitLogger)
        {
            Key                   = key;
            _instanceConfig       = instanceConfig;
            _configuration        = configuration;
            _serversConfiguration = serversConfiguration;
            _logger               = logger;
            _taskQueue            = taskQueue;

            switch (instanceConfig.UpdateType)
            {
            case "Jenkins":
                var jenkinsConfig = configuration
                                    .GetSection($"Servers:Instances:{key}:Updates")
                                    .Get <UpdateProviderJenkinsConfiguration>();

                _updateProvider = new UpdateProviderJenkins(jenkinsConfig, jenkinsLogger);
                break;

            case "Local":
                var localConfig = configuration
                                  .GetSection($"Servers:Instances:{key}:Updates")
                                  .Get <UpdateProviderLocalConfiguration>();

                _updateProvider = new UpdateProviderLocal(this, localConfig, localLogger, configuration);
                break;

            case "Git":
                var gitConfig = configuration
                                .GetSection($"Servers:Instances:{key}:Updates")
                                .Get <UpdateProviderGitConfiguration>();

                _updateProvider = new UpdateProviderGit(this, gitConfig, gitLogger, configuration);
                break;

            case "Dummy":
                _updateProvider = new UpdateProviderDummy();
                break;

            case null:
                _updateProvider = null;
                break;

            default:
                throw new ArgumentException($"Unknown update type: {instanceConfig.UpdateType}");
            }

            if (!Directory.Exists(InstanceDir))
            {
                Directory.CreateDirectory(InstanceDir);
                _logger.LogInformation($"Created InstanceDir {InstanceDir}");
            }

            LoadData();
        }
        private void CfgChanged(ServersConfiguration obj)
        {
            foreach (var(k, instance) in _instances)
            {
                if (!obj.Instances.TryGetValue(k, out var instanceCfg))
                {
                    return;
                }

                instance.OnConfigUpdate(instanceCfg);
            }
        }
示例#3
0
 public ServerManager(
     IOptions <ServersConfiguration> instancesOptions,
     ILogger <ServerManager> logger, IConfiguration configuration, ILogger <UpdateProviderJenkins> jenkinsLogger,
     ILogger <ServerInstance> serverInstanceLogger, IBackgroundTaskQueue taskQueue,
     ILogger <UpdateProviderLocal> localLogger)
 {
     _logger               = logger;
     _configuration        = configuration;
     _jenkinsLogger        = jenkinsLogger;
     _serverInstanceLogger = serverInstanceLogger;
     _taskQueue            = taskQueue;
     _localLogger          = localLogger;
     _serversOptions       = instancesOptions.Value;
 }
示例#4
0
 public ConfigurationController(
     IOptions <ServersConfiguration> serversConfiguration)
 {
     m_ServersConfiguration = serversConfiguration.Value;
 }