Ejemplo n.º 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()
                }
            });
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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()
                }
            });
        }