예제 #1
0
        public virtual async Task <KongvergeConfiguration> FromKong(IKongAdminReader kongReader)
        {
            Log.Information("Reading configuration from Kong");

            Log.Verbose("Getting plugins from Kong");
            var plugins = await kongReader.GetPlugins();

            Log.Verbose("Getting services from Kong");
            var services = await kongReader.GetServices();

            Log.Verbose("Getting routes from Kong");
            var routes = await kongReader.GetRoutes();

            foreach (var existingService in services)
            {
                PopulateServiceTree(existingService, routes, plugins);
            }

            return(new KongvergeConfiguration
            {
                Services = services.ToArray(),
                GlobalConfig = new GlobalConfig
                {
                    Plugins = plugins.Where(x => x.IsGlobal()).ToArray()
                }
            });
        }
예제 #2
0
 public ExportWorkflow(
     IKongAdminReader kongReader,
     IOptions <Settings> configuration,
     ConfigFileWriter configWriter,
     ConfigBuilder configBuilder) : base(kongReader, configuration)
 {
     _configWriter  = configWriter;
     _configBuilder = configBuilder;
 }
예제 #3
0
 public ExportWorkflow(
     IKongAdminReader kongReader,
     ExportWorkflowArguments arguments,
     ConfigFileWriter configWriter,
     ConfigBuilder configBuilder) : base(kongReader)
 {
     _arguments     = arguments;
     _configWriter  = configWriter;
     _configBuilder = configBuilder;
 }
예제 #4
0
 public KongvergeWorkflow(
     IKongAdminReader kongReader,
     IOptions <Settings> configuration,
     IKongAdminWriter kongWriter,
     ConfigFileReader configReader,
     ConfigBuilder configBuilder) : base(kongReader, configuration)
 {
     _kongWriter    = kongWriter;
     _configReader  = configReader;
     _configBuilder = configBuilder;
 }
예제 #5
0
 public KongvergeWorkflow(
     IKongAdminReader kongReader,
     KongvergeWorkflowArguments arguments,
     IKongAdminWriter kongWriter,
     ConfigFileReader configReader,
     ConfigBuilder configBuilder) : base(kongReader)
 {
     _arguments     = arguments;
     _kongWriter    = kongWriter;
     _configReader  = configReader;
     _configBuilder = configBuilder;
 }
 public IDictionary <string, AsyncLazy <KongSchema> > GetSchemas(IKongAdminReader kongReader)
 {
     return(Plugins.Available
            .Where(x => x.Value)
            .Select(x => $"plugins/{x.Key}")
            .Append("plugins")
            .Append("consumers")
            .Append("routes")
            .Append("services")
            .Append("certificates")
            .ToDictionary(x => x, x => new AsyncLazy <KongSchema>(() => kongReader.GetSchema(x))));
 }
예제 #7
0
        public virtual async Task <KongvergeConfiguration> FromKong(IKongAdminReader kongReader, IReadOnlyCollection <string> ignoreTags)
        {
            ignoreTags ??= Array.Empty <string>();

            Log.Information("Reading configuration from Kong");

            Log.Verbose("Getting consumers from Kong");
            var consumers = IgnoreByTag(ignoreTags, await kongReader.GetConsumers());

            Log.Verbose("Getting plugins from Kong");
            var plugins = IgnoreByTag(ignoreTags, await kongReader.GetPlugins());

            Log.Verbose("Getting services from Kong");
            var services = IgnoreByTag(ignoreTags, await kongReader.GetServices());

            Log.Verbose("Getting routes from Kong");
            var routes = IgnoreByTag(ignoreTags, await kongReader.GetRoutes());

            foreach (var consumer in consumers)
            {
                consumer.Plugins = plugins.Where(x => x.Consumer?.Id == consumer.Id).ToArray();
            }
            foreach (var service in services)
            {
                PopulateServiceTree(service, routes, plugins);
            }

            var configuration = new KongvergeConfiguration
            {
                Services     = services.ToArray(),
                GlobalConfig = new GlobalConfig
                {
                    Plugins   = plugins.Where(x => x.IsGlobal()).ToArray(),
                    Consumers = consumers.ToArray()
                }
            };

            Log.Information($"Configuration from Kong: {configuration}");

            return(configuration);
        }
예제 #8
0
        public virtual async Task <KongvergeConfiguration> FromKong(IKongAdminReader kongReader)
        {
            var plugins = await kongReader.GetPlugins();

            var services = await kongReader.GetServices();

            var routes = await kongReader.GetRoutes();

            foreach (var existingService in services)
            {
                PopulateServiceTree(existingService, routes, plugins);
            }

            return(new KongvergeConfiguration
            {
                Services = services.ToArray(),
                GlobalConfig = new ExtendibleKongObject
                {
                    Plugins = plugins.Where(x => x.IsGlobal()).ToArray()
                }
            });
        }
예제 #9
0
 protected Workflow(IKongAdminReader kongReader, IOptions <Settings> configuration)
 {
     KongReader    = kongReader;
     Configuration = configuration.Value;
 }
예제 #10
0
 protected Workflow(IKongAdminReader kongReader)
 {
     KongReader = kongReader;
 }
예제 #11
0
 public TestWorkflow(IKongAdminReader kongReader) : base(kongReader)
 {
 }