From 77e27a11c31fee82c2ff30613bc832f5171fa845 Mon Sep 17 00:00:00 2001 From: Hussein Ait-Lahcen Date: Mon, 19 Nov 2018 15:51:21 +0100 Subject: add dhall interface --- dhall/Config.dhall | 1 + dhall/Vault.dhall | 1 + dhall/functions.dhall | 1 + dhall/server/Server.dhall | 9 +++++++++ dhall/server/functions.dhall | 1 + dhall/server/mkServer.dhall | 17 +++++++++++++++++ dhall/server/service/Service.dhall | 5 +++++ dhall/server/service/functions.dhall | 1 + dhall/server/service/plugin/Config.dhall | 9 +++++++++ dhall/server/service/plugin/CorrelationId.dhall | 11 +++++++++++ dhall/server/service/plugin/Plugin.dhall | 1 + dhall/server/service/plugin/functions.dhall | 9 +++++++++ dhall/server/service/plugin/mkIPRestriction.dhall | 11 +++++++++++ .../server/service/plugin/mkRequestTermination.dhall | 20 ++++++++++++++++++++ .../server/service/plugin/mkRequestTransformer.dhall | 11 +++++++++++ dhall/server/service/route/Route.dhall | 1 + dhall/types.dhall | 13 +++++++++++++ 17 files changed, 122 insertions(+) create mode 100644 dhall/Config.dhall create mode 100644 dhall/Vault.dhall create mode 100644 dhall/functions.dhall create mode 100644 dhall/server/Server.dhall create mode 100644 dhall/server/functions.dhall create mode 100644 dhall/server/mkServer.dhall create mode 100644 dhall/server/service/Service.dhall create mode 100644 dhall/server/service/functions.dhall create mode 100644 dhall/server/service/plugin/Config.dhall create mode 100644 dhall/server/service/plugin/CorrelationId.dhall create mode 100644 dhall/server/service/plugin/Plugin.dhall create mode 100644 dhall/server/service/plugin/functions.dhall create mode 100644 dhall/server/service/plugin/mkIPRestriction.dhall create mode 100644 dhall/server/service/plugin/mkRequestTermination.dhall create mode 100644 dhall/server/service/plugin/mkRequestTransformer.dhall create mode 100644 dhall/server/service/route/Route.dhall create mode 100644 dhall/types.dhall (limited to 'dhall') diff --git a/dhall/Config.dhall b/dhall/Config.dhall new file mode 100644 index 0000000..f1a28fc --- /dev/null +++ b/dhall/Config.dhall @@ -0,0 +1 @@ +let Server = ./server/Server.dhall in { kong_servers : List Server } diff --git a/dhall/Vault.dhall b/dhall/Vault.dhall new file mode 100644 index 0000000..56cd0e5 --- /dev/null +++ b/dhall/Vault.dhall @@ -0,0 +1 @@ +{ appAdminApiKey : Text, accessKey : Text } diff --git a/dhall/functions.dhall b/dhall/functions.dhall new file mode 100644 index 0000000..6465760 --- /dev/null +++ b/dhall/functions.dhall @@ -0,0 +1 @@ +{ Server = ./server/functions.dhall } diff --git a/dhall/server/Server.dhall b/dhall/server/Server.dhall new file mode 100644 index 0000000..beddd7d --- /dev/null +++ b/dhall/server/Server.dhall @@ -0,0 +1,9 @@ + let Service = ./service/Service.dhall + +in { kong_app_admin_url : + Text + , kong_app_admin_apikey : + Text + , services : + List Service + } diff --git a/dhall/server/functions.dhall b/dhall/server/functions.dhall new file mode 100644 index 0000000..2775fb9 --- /dev/null +++ b/dhall/server/functions.dhall @@ -0,0 +1 @@ +{ Service = ./service/functions.dhall, mkServer = ./mkServer.dhall } diff --git a/dhall/server/mkServer.dhall b/dhall/server/mkServer.dhall new file mode 100644 index 0000000..f02055b --- /dev/null +++ b/dhall/server/mkServer.dhall @@ -0,0 +1,17 @@ + let Server = ./Server.dhall + +in let Service = ./service/Service.dhall + +in let Vault = ./../Vault.dhall + +in λ(vault : Vault) + → λ(adminUrl : Text) + → λ(services : List Service) + → { kong_app_admin_url = + adminUrl + , kong_app_admin_apikey = + vault.appAdminApiKey + , services = + services + } + : Server diff --git a/dhall/server/service/Service.dhall b/dhall/server/service/Service.dhall new file mode 100644 index 0000000..f238553 --- /dev/null +++ b/dhall/server/service/Service.dhall @@ -0,0 +1,5 @@ + let Plugin = ./plugin/Plugin.dhall + +in let Route = ./route/Route.dhall + +in { name : Text, url : Text, plugins : List Plugin, routes : List Route } diff --git a/dhall/server/service/functions.dhall b/dhall/server/service/functions.dhall new file mode 100644 index 0000000..08f25c0 --- /dev/null +++ b/dhall/server/service/functions.dhall @@ -0,0 +1 @@ +{ Plugin = ./plugin/functions.dhall } diff --git a/dhall/server/service/plugin/Config.dhall b/dhall/server/service/plugin/Config.dhall new file mode 100644 index 0000000..73a333f --- /dev/null +++ b/dhall/server/service/plugin/Config.dhall @@ -0,0 +1,9 @@ +< CorrelationId : + { header_name : Text, echo_downstream : Bool } +| RequestTransformer : + { `add.headers` : Text } +| RequestTermination : + { status_code : Natural, content_type : Text, body : Text } +| IPRestriction : + { whitelist : Text } +> diff --git a/dhall/server/service/plugin/CorrelationId.dhall b/dhall/server/service/plugin/CorrelationId.dhall new file mode 100644 index 0000000..d96bfc9 --- /dev/null +++ b/dhall/server/service/plugin/CorrelationId.dhall @@ -0,0 +1,11 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in { name = + "correlation-id" + , config = + config.CorrelationId + { header_name = "X-correl", echo_downstream = True } + } + : Plugin diff --git a/dhall/server/service/plugin/Plugin.dhall b/dhall/server/service/plugin/Plugin.dhall new file mode 100644 index 0000000..548061c --- /dev/null +++ b/dhall/server/service/plugin/Plugin.dhall @@ -0,0 +1 @@ +let Config = ./Config.dhall in { name : Text, config : Config } diff --git a/dhall/server/service/plugin/functions.dhall b/dhall/server/service/plugin/functions.dhall new file mode 100644 index 0000000..dcf2c9a --- /dev/null +++ b/dhall/server/service/plugin/functions.dhall @@ -0,0 +1,9 @@ +{ mkRequestTermination = + ./mkRequestTermination.dhall +, mkRequestTransformer = + ./mkRequestTransformer.dhall +, mkIPRestriction = + ./mkIPRestriction.dhall +, CorrelationId = + ./CorrelationId.dhall +} diff --git a/dhall/server/service/plugin/mkIPRestriction.dhall b/dhall/server/service/plugin/mkIPRestriction.dhall new file mode 100644 index 0000000..f803769 --- /dev/null +++ b/dhall/server/service/plugin/mkIPRestriction.dhall @@ -0,0 +1,11 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in λ(whiteList : Text) + → { name = + "ip-restriction" + , config = + config.IPRestriction { whitelist = whiteList } + } + : Plugin diff --git a/dhall/server/service/plugin/mkRequestTermination.dhall b/dhall/server/service/plugin/mkRequestTermination.dhall new file mode 100644 index 0000000..aff538f --- /dev/null +++ b/dhall/server/service/plugin/mkRequestTermination.dhall @@ -0,0 +1,20 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in λ(statusCode : Natural) + → λ(contentType : Text) + → λ(body : Text) + → { name = + "request-termination" + , config = + config.RequestTermination + { status_code = + statusCode + , content_type = + contentType + , body = + body + } + } + : Plugin diff --git a/dhall/server/service/plugin/mkRequestTransformer.dhall b/dhall/server/service/plugin/mkRequestTransformer.dhall new file mode 100644 index 0000000..90789c8 --- /dev/null +++ b/dhall/server/service/plugin/mkRequestTransformer.dhall @@ -0,0 +1,11 @@ + let Plugin = ./Plugin.dhall + +in let config = constructors ./Config.dhall + +in λ(header : Text) + → { name = + "request-transformer" + , config = + config.RequestTransformer { `add.headers` = header } + } + : Plugin diff --git a/dhall/server/service/route/Route.dhall b/dhall/server/service/route/Route.dhall new file mode 100644 index 0000000..c0fa1a9 --- /dev/null +++ b/dhall/server/service/route/Route.dhall @@ -0,0 +1 @@ +{ paths : List Text, protocols : List Text, hosts : List Text } diff --git a/dhall/types.dhall b/dhall/types.dhall new file mode 100644 index 0000000..938dc74 --- /dev/null +++ b/dhall/types.dhall @@ -0,0 +1,13 @@ +{ Vault = + ./Vault.dhall +, Config = + ./Config.dhall +, Server = + ./server/Server.dhall +, Service = + ./server/service/Service.dhall +, Plugin = + ./server/service/plugin/Plugin.dhall +, Route = + ./server/service/route/Route.dhall +} -- cgit v1.2.3