From cd85c5d525b1dbf897ff89f359cbbb4814162bb7 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Mon, 16 Oct 2023 11:40:37 +0530 Subject: [PATCH 01/22] fix: add missing properties to schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 6f6450b46e0c..adcb4f09cb92 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -71,6 +71,37 @@ local config_schema = { properties = { apisix = { properties = { + node_listen = { + anyOf = { + { + type = "array", + items = { + type = "integer", + minimum = 1, + maximum = 65535 + } + }, + { + type = "array", + items = { + type = "object", + properties = { + port = { + type = "integer", + minimum = 1, + maximum = 65535 + }, + ip = { + type = "string", + }, + enable_http2 = { + type = "boolean", + }, + } + }, + } + }, + }, lua_module_hook = { pattern = "^[a-zA-Z._-]+$", }, From 5e332ddcf2b0b2a6af80a6f9e8fc628b3753bbe9 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Mon, 16 Oct 2023 12:07:23 +0530 Subject: [PATCH 02/22] fix: add single integer Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index adcb4f09cb92..62b889e9a967 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -73,6 +73,11 @@ local config_schema = { properties = { node_listen = { anyOf = { + { + type = "integer", + minimum = 1, + maximum = 65535 + }, { type = "array", items = { From 5902e5932d45532a2ad1bd4ffa6bfd039d2c963f Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Mon, 16 Oct 2023 15:43:20 +0530 Subject: [PATCH 03/22] fix: use single schema instead of multiple schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 228 ++++++++++++++++++++++++++---------------- 1 file changed, 142 insertions(+), 86 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 62b889e9a967..2f75193ee1df 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -66,6 +66,40 @@ local etcd_schema = { required = {"prefix", "host"} } +local admin_schema = { + type = "object", + properties = { + admin_key = { + type = "array", + properties = { + items = { + properties = { + name = {type = "string"}, + key = {type = "string"}, + role = {type = "string"}, + } + } + } + }, + admin_listen = { + properties = { + listen = { type = "string" }, + port = { type = "integer" }, + }, + default = { + listen = "0.0.0.0", + port = 9180, + } + }, + https_admin = { + type = "boolean", + }, + admin_key_required = { + type = "boolean", + }, + } +} + local config_schema = { type = "object", properties = { @@ -353,94 +387,116 @@ local config_schema = { role = { enum = {"traditional", "control_plane", "data_plane", "standalone"}, default = "traditional" - } + }, }, - }, - }, - required = {"apisix", "deployment"}, -} - -local admin_schema = { - type = "object", - properties = { - admin_key = { - type = "array", - properties = { - items = { - properties = { - name = {type = "string"}, - key = {type = "string"}, - role = {type = "string"}, + dependencies = { + role = { + oneOf = { + { + properties = { + role = { const = "traditional" }, + etcd = etcd_schema, + admin = admin_schema, + role_traditional = { + type = "object", + properties = { + config_provider = { + enum = { "etcd" } + }, + }, + required = { "config_provider" } + }, + }, + required = { "role_traditional" }, + }, + { + properties = { + role = { const = "control_plane" }, + etcd = etcd_schema, + admin = admin_schema, + role_control_plane = { + type = "object", + properties = { + config_provider = { + enum = { "etcd" } + }, + }, + required = { "config_provider" } + }, + }, + required = { "role_control_plane" }, + }, + { + properties = { + role = { const = "data_plane" }, + etcd = etcd_schema, + role_data_plane = { + type = "object", + properties = { + config_provider = { + enum = { "etcd", "yaml", "xds" } + }, + }, + required = { "config_provider" } + }, + }, + required = { "role_data_plane" }, + }, } } } }, - admin_listen = { - properties = { - listen = { type = "string" }, - port = { type = "integer" }, - }, - default = { - listen = "0.0.0.0", - port = 9180, - } - }, - https_admin = { - type = "boolean", - }, - admin_key_required = { - type = "boolean", - }, - } -} - -local deployment_schema = { - traditional = { - properties = { - etcd = etcd_schema, - admin = admin_schema, - role_traditional = { - properties = { - config_provider = { - enum = {"etcd"} - }, - }, - required = {"config_provider"} - } - }, - required = {"etcd"} }, - control_plane = { - properties = { - etcd = etcd_schema, - admin = admin_schema, - role_control_plane = { - properties = { - config_provider = { - enum = {"etcd"} - }, - }, - required = {"config_provider"} - }, - }, - required = {"etcd", "role_control_plane"} - }, - data_plane = { - properties = { - etcd = etcd_schema, - role_data_plane = { - properties = { - config_provider = { - enum = {"etcd", "yaml", "xds"} - }, - }, - required = {"config_provider"} - }, - }, - required = {"role_data_plane"} - } + required = {"apisix", "deployment"}, } +-- local deployment_schema = { +-- traditional = { +-- properties = { +-- etcd = etcd_schema, +-- admin = admin_schema, +-- role_traditional = { +-- properties = { +-- config_provider = { +-- enum = {"etcd"} +-- }, +-- }, +-- required = {"config_provider"} +-- } +-- }, +-- required = {"etcd"} +-- }, +-- control_plane = { +-- properties = { +-- etcd = etcd_schema, +-- admin = admin_schema, +-- role_control_plane = { +-- properties = { +-- config_provider = { +-- enum = {"etcd"} +-- }, +-- }, +-- required = {"config_provider"} +-- }, +-- }, +-- required = {"etcd", "role_control_plane"} +-- }, +-- data_plane = { +-- properties = { +-- etcd = etcd_schema, +-- role_data_plane = { +-- properties = { +-- config_provider = { +-- enum = {"etcd", "yaml", "xds"} +-- }, +-- }, +-- required = {"config_provider"} +-- }, +-- }, +-- required = {"role_data_plane"} +-- } +-- } + function _M.validate(yaml_conf) local validator = jsonschema.generate_validator(config_schema) @@ -462,12 +518,12 @@ function _M.validate(yaml_conf) end end - local role = yaml_conf.deployment.role - local validator = jsonschema.generate_validator(deployment_schema[role]) - local ok, err = validator(yaml_conf.deployment) - if not ok then - return false, "invalid deployment " .. role .. " configuration: " .. err - end + -- local role = yaml_conf.deployment.role + -- local validator = jsonschema.generate_validator(deployment_schema[role]) + -- local ok, err = validator(yaml_conf.deployment) + -- if not ok then + -- return false, "invalid deployment " .. role .. " configuration: " .. err + -- end return true end From 2a0e7513945b235afeaf0bbaed6a9104756f9828 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 17 Oct 2023 11:18:29 +0530 Subject: [PATCH 04/22] fix: add properties to schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 385 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 316 insertions(+), 69 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 2f75193ee1df..84c3b8bd4aa5 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -25,6 +25,12 @@ local _M = {} local etcd_schema = { type = "object", properties = { + health_check_timeout = { + type = "integer" + }, + startup_retry = { + type = "integer" + }, resync_delay = { type = "integer", }, @@ -43,6 +49,9 @@ local etcd_schema = { key = { type = "string", }, + verify = { + type = "boolean" + } }, }, prefix = { @@ -63,7 +72,7 @@ local etcd_schema = { description = "etcd connection timeout in seconds", }, }, - required = {"prefix", "host"} + required = { "prefix", "host" } } local admin_schema = { @@ -74,9 +83,9 @@ local admin_schema = { properties = { items = { properties = { - name = {type = "string"}, - key = {type = "string"}, - role = {type = "string"}, + name = { type = "string" }, + key = { type = "string" }, + role = { type = "string" }, } } } @@ -97,6 +106,32 @@ local admin_schema = { admin_key_required = { type = "boolean", }, + enable_admin_cors = { + type = "boolean" + }, + allow_admin = { + type = "array", + items = { + type = "string" + } + }, + admin_api_mtls = { + type = "object", + properties = { + admin_ssl_cert = { + type = "string" + }, + admin_ssl_cert_key = { + type = "string" + }, + admin_ssl_ca_cert = { + type = "string" + } + } + }, + admin_api_version = { + type = "string" + } } } @@ -141,6 +176,30 @@ local config_schema = { } }, }, + enable_admin = { + type = "boolean", + }, + enable_dev_mode = { + type = "boolean", + }, + enable_reuseport = { + type = "boolean", + }, + show_upstream_status_in_response_header = { + type = "boolean", + }, + enable_ipv6 = { + type = "boolean", + }, + enable_server_tokens = { + type = "boolean", + }, + extra_lua_path = { + type = "string" + }, + extra_lua_cpath = { + type = "string" + }, lua_module_hook = { pattern = "^[a-zA-Z._-]+$", }, @@ -188,12 +247,12 @@ local config_schema = { }, oneOf = { { - required = {"name", "memory_size"}, + required = { "name", "memory_size" }, maxProperties = 2, }, { - required = {"name", "memory_size", "disk_size", - "disk_path", "cache_levels"}, + required = { "name", "memory_size", "disk_size", + "disk_path", "cache_levels" }, } }, }, @@ -201,9 +260,29 @@ local config_schema = { } } }, + delete_uri_tail_slash = { + type = "boolean", + }, + normalize_uri_like_servlet = { + type = "boolean", + }, + router = { + type = "object", + properties = { + http = { + type = "string", + enum = { "radixtree_host_uri", "radixtree_uri", "radixtree_uri_with_parameter" }, + }, + ssl = { + type = "string", + enum = { "radixtree_host_uri", "radixtree_uri", "radixtree_uri_with_parameter", + "radixtree_sni" }, + }, + } + }, proxy_mode = { type = "string", - enum = {"http", "stream", "http&stream"}, + enum = { "http", "stream", "http&stream" }, }, stream_proxy = { type = "object", @@ -236,7 +315,7 @@ local config_schema = { type = "boolean", } }, - required = {"addr"} + required = { "addr" } }, }, }, @@ -269,6 +348,12 @@ local config_schema = { dns_resolver_valid = { type = "integer", }, + resolver_timeout = { + type = "integer", + }, + enable_resolv_search_opt = { + type = "boolean", + }, ssl = { type = "object", properties = { @@ -316,18 +401,225 @@ local config_schema = { }, } }, + enable_control = { + type = "boolean", + }, + control = { + type = "object", + properties = { + ip = { + type = "string", + }, + port = { + type = "integer", + minimum = 1, + maximum = 65535 + }, + } + }, + data_encryption = { + type = "object", + properties = { + enable = { + type = "boolean", + }, + keyring = { + type = "array", + items = { + type = "string", + } + }, + } + }, nginx_config = { type = "object", properties = { + user = { + type = "string", + }, + error_log = { + type = "string", + }, + error_log_level = { + type = "string", + enum = { "info", "debug", "notice", "warn", "error", "crit", "alert", "emerg" } + }, + worker_processes = { + anyOf = { + { + type = "integer", + minimum = 1, + }, + { + type = "string" + }, + { + type = "string", + enum = { "auto" } + } + } + }, + enable_cpu_affinity = { + type = "boolean", + }, + worker_rlimit_nofile = { + type = "integer", + }, + worker_shutdown_timeout = { + type = "string", + }, + max_pending_timers = { + type = "integer", + }, + max_running_timers = { + type = "integer", + }, + event = { + type = "object", + properties = { + worker_connections = { + type = "integer" + }, + } + }, envs = { type = "array", minItems = 1, items = { type = "string", } + }, + meta = { + type = "object", + properties = { + lua_shared_dict = { + type = "object", + }, + } + }, + stream = { + type = "object", + properties = { + enable_access_log = { + type = "boolean", + }, + access_log = { + type = "string", + }, + access_log_format = { + type = "string", + }, + access_log_format_escape = { + type = "string", + }, + lua_shared_dict = { + type = "object", + }, + } + }, + main_configuration_snippet = { + type = "string" + }, + http_configuration_snippet = { + type = "string" + }, + http_server_configuration_snippet = { + type = "string" + }, + http_server_location_configuration_snippet = { + type = "string" + }, + http_admin_configuration_snippet = { + type = "string" + }, + http_end_configuration_snippet = { + type = "string" + }, + stream_configuration_snippet = { + type = "string" + }, + http = { + type = "object", + properties = { + enable_access_log = { + type = "string" + }, + access_log = { + type = "string" + }, + access_log_buffer = { + type = "integer" + }, + access_log_format = { + type = "string" + }, + access_log_format_escape = { + type = "string" + }, + keepalive_timeout = { + type = "string" + }, + client_header_timeout = { + type = "string" + }, + client_body_timeout = { + type = "string" + }, + client_max_body_size = { + type = "string" + }, + send_timeout = { + type = "string" + }, + underscores_in_headers = { + type = "string" + }, + real_ip_header = { + type = "string" + }, + real_ip_recursive = { + type = "string" + }, + real_ip_from = { + type = "array", + items = { + type = "string" + } + }, + custom_lua_shared_dict = { + type = "object" + }, + proxy_ssl_server_name = { + type = "boolean" + }, + upstream = { + type = "object", + properties = { + keepalive = { + type = "integer" + }, + keepalive_requests = { + type = "integer" + }, + keepalive_timeout = { + type = "string" + } + } + }, + charset = { + type = "string" + }, + variables_hash_max_size = { + type = "integer" + }, + lua_shared_dict = { + type = "object" + } + } } }, }, + -- TODO: Add schema for discovery http = { type = "object", properties = { @@ -336,6 +628,14 @@ local config_schema = { } } }, + graphql = { + type = "object", + properties = { + max_size = { + type = "integer" + } + } + }, etcd = etcd_schema, plugins = { type = "array", @@ -372,20 +672,23 @@ local config_schema = { type = "integer" }, http_request_phase = { - enum = {"access", "rewrite"}, + enum = { "access", "rewrite" }, default = "access", }, }, - required = {"name", "file", "priority"} + required = { "name", "file", "priority" } } } } }, + plugin_attr = { + type = "object" + }, deployment = { type = "object", properties = { role = { - enum = {"traditional", "control_plane", "data_plane", "standalone"}, + enum = { "traditional", "control_plane", "data_plane", "standalone" }, default = "traditional" }, }, @@ -447,57 +750,9 @@ local config_schema = { } }, }, - required = {"apisix", "deployment"}, + required = { "apisix", "deployment" }, } --- local deployment_schema = { --- traditional = { --- properties = { --- etcd = etcd_schema, --- admin = admin_schema, --- role_traditional = { --- properties = { --- config_provider = { --- enum = {"etcd"} --- }, --- }, --- required = {"config_provider"} --- } --- }, --- required = {"etcd"} --- }, --- control_plane = { --- properties = { --- etcd = etcd_schema, --- admin = admin_schema, --- role_control_plane = { --- properties = { --- config_provider = { --- enum = {"etcd"} --- }, --- }, --- required = {"config_provider"} --- }, --- }, --- required = {"etcd", "role_control_plane"} --- }, --- data_plane = { --- properties = { --- etcd = etcd_schema, --- role_data_plane = { --- properties = { --- config_provider = { --- enum = {"etcd", "yaml", "xds"} --- }, --- }, --- required = {"config_provider"} --- }, --- }, --- required = {"role_data_plane"} --- } --- } - - function _M.validate(yaml_conf) local validator = jsonschema.generate_validator(config_schema) local ok, err = validator(yaml_conf) @@ -518,15 +773,7 @@ function _M.validate(yaml_conf) end end - -- local role = yaml_conf.deployment.role - -- local validator = jsonschema.generate_validator(deployment_schema[role]) - -- local ok, err = validator(yaml_conf.deployment) - -- if not ok then - -- return false, "invalid deployment " .. role .. " configuration: " .. err - -- end - return true end - return _M From 41182da452a5f3425e060eac56258af80cb38480 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 17 Oct 2023 11:29:24 +0530 Subject: [PATCH 05/22] fix: CI errors Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 84c3b8bd4aa5..36f224b05f31 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -271,11 +271,15 @@ local config_schema = { properties = { http = { type = "string", - enum = { "radixtree_host_uri", "radixtree_uri", "radixtree_uri_with_parameter" }, + enum = { "radixtree_host_uri", + "radixtree_uri", + "radixtree_uri_with_parameter" }, }, ssl = { type = "string", - enum = { "radixtree_host_uri", "radixtree_uri", "radixtree_uri_with_parameter", + enum = { "radixtree_host_uri", + "radixtree_uri", + "radixtree_uri_with_parameter", "radixtree_sni" }, }, } @@ -542,7 +546,7 @@ local config_schema = { type = "object", properties = { enable_access_log = { - type = "string" + type = "boolean" }, access_log = { type = "string" From f3ecf055e025c1b92abc4a0804a9403e31ea8a68 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 17 Oct 2023 11:38:56 +0530 Subject: [PATCH 06/22] fix: CI errors Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 36f224b05f31..2a758db677a2 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -570,7 +570,7 @@ local config_schema = { type = "string" }, client_max_body_size = { - type = "string" + type = "number" }, send_timeout = { type = "string" From 2eb47d941af5ec90655da08c389f810b1d7cfbb6 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 17 Oct 2023 21:22:58 +0530 Subject: [PATCH 07/22] fix CI error Co-authored-by: Ashish Tiwari --- apisix/cli/schema.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 2a758db677a2..36f224b05f31 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -570,7 +570,7 @@ local config_schema = { type = "string" }, client_max_body_size = { - type = "number" + type = "string" }, send_timeout = { type = "string" From e4e5f56b065511ce429021b3a1753c6320ef4d2b Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 17 Oct 2023 21:35:29 +0530 Subject: [PATCH 08/22] fix: add number and string Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 36f224b05f31..676cc986e2ee 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -570,7 +570,14 @@ local config_schema = { type = "string" }, client_max_body_size = { - type = "string" + anyOf = { + { + type = "number" + }, + { + type = "string" + } + } }, send_timeout = { type = "string" From 5f70eb1ac544914f95062eb0ba025625308e308c Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 24 Oct 2023 11:40:38 +0530 Subject: [PATCH 09/22] remove prefix from required property Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 676cc986e2ee..7d3a7b2bc2cf 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -72,7 +72,7 @@ local etcd_schema = { description = "etcd connection timeout in seconds", }, }, - required = { "prefix", "host" } + required = { "host" } } local admin_schema = { From ddae2a1581b4d5c2ba95aa2d67b4fa7fbaea60e4 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Tue, 24 Oct 2023 13:07:47 +0530 Subject: [PATCH 10/22] remove pattern Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 7d3a7b2bc2cf..5194d8f52c46 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -60,8 +60,7 @@ local etcd_schema = { host = { type = "array", items = { - type = "string", - pattern = [[^https?://]] + type = "string" }, minItems = 1, }, From ef3d8bec96c4b4adc030b1000a26767bd1bc0af0 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 14:05:05 +0530 Subject: [PATCH 11/22] revert to working schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 401 ++++++++---------------------------------- 1 file changed, 72 insertions(+), 329 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 5194d8f52c46..7e9186355eab 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -25,12 +25,6 @@ local _M = {} local etcd_schema = { type = "object", properties = { - health_check_timeout = { - type = "integer" - }, - startup_retry = { - type = "integer" - }, resync_delay = { type = "integer", }, @@ -49,9 +43,6 @@ local etcd_schema = { key = { type = "string", }, - verify = { - type = "boolean" - } }, }, prefix = { @@ -60,7 +51,8 @@ local etcd_schema = { host = { type = "array", items = { - type = "string" + type = "string", + pattern = [[^https?://]] }, minItems = 1, }, @@ -71,7 +63,7 @@ local etcd_schema = { description = "etcd connection timeout in seconds", }, }, - required = { "host" } + required = {"prefix", "host"} } local admin_schema = { @@ -82,9 +74,9 @@ local admin_schema = { properties = { items = { properties = { - name = { type = "string" }, - key = { type = "string" }, - role = { type = "string" }, + name = {type = "string"}, + key = {type = "string"}, + role = {type = "string"}, } } } @@ -105,32 +97,6 @@ local admin_schema = { admin_key_required = { type = "boolean", }, - enable_admin_cors = { - type = "boolean" - }, - allow_admin = { - type = "array", - items = { - type = "string" - } - }, - admin_api_mtls = { - type = "object", - properties = { - admin_ssl_cert = { - type = "string" - }, - admin_ssl_cert_key = { - type = "string" - }, - admin_ssl_ca_cert = { - type = "string" - } - } - }, - admin_api_version = { - type = "string" - } } } @@ -175,30 +141,6 @@ local config_schema = { } }, }, - enable_admin = { - type = "boolean", - }, - enable_dev_mode = { - type = "boolean", - }, - enable_reuseport = { - type = "boolean", - }, - show_upstream_status_in_response_header = { - type = "boolean", - }, - enable_ipv6 = { - type = "boolean", - }, - enable_server_tokens = { - type = "boolean", - }, - extra_lua_path = { - type = "string" - }, - extra_lua_cpath = { - type = "string" - }, lua_module_hook = { pattern = "^[a-zA-Z._-]+$", }, @@ -246,12 +188,12 @@ local config_schema = { }, oneOf = { { - required = { "name", "memory_size" }, + required = {"name", "memory_size"}, maxProperties = 2, }, { - required = { "name", "memory_size", "disk_size", - "disk_path", "cache_levels" }, + required = {"name", "memory_size", "disk_size", + "disk_path", "cache_levels"}, } }, }, @@ -259,33 +201,9 @@ local config_schema = { } } }, - delete_uri_tail_slash = { - type = "boolean", - }, - normalize_uri_like_servlet = { - type = "boolean", - }, - router = { - type = "object", - properties = { - http = { - type = "string", - enum = { "radixtree_host_uri", - "radixtree_uri", - "radixtree_uri_with_parameter" }, - }, - ssl = { - type = "string", - enum = { "radixtree_host_uri", - "radixtree_uri", - "radixtree_uri_with_parameter", - "radixtree_sni" }, - }, - } - }, proxy_mode = { type = "string", - enum = { "http", "stream", "http&stream" }, + enum = {"http", "stream", "http&stream"}, }, stream_proxy = { type = "object", @@ -318,7 +236,7 @@ local config_schema = { type = "boolean", } }, - required = { "addr" } + required = {"addr"} }, }, }, @@ -351,12 +269,6 @@ local config_schema = { dns_resolver_valid = { type = "integer", }, - resolver_timeout = { - type = "integer", - }, - enable_resolv_search_opt = { - type = "boolean", - }, ssl = { type = "object", properties = { @@ -404,232 +316,18 @@ local config_schema = { }, } }, - enable_control = { - type = "boolean", - }, - control = { - type = "object", - properties = { - ip = { - type = "string", - }, - port = { - type = "integer", - minimum = 1, - maximum = 65535 - }, - } - }, - data_encryption = { - type = "object", - properties = { - enable = { - type = "boolean", - }, - keyring = { - type = "array", - items = { - type = "string", - } - }, - } - }, nginx_config = { type = "object", properties = { - user = { - type = "string", - }, - error_log = { - type = "string", - }, - error_log_level = { - type = "string", - enum = { "info", "debug", "notice", "warn", "error", "crit", "alert", "emerg" } - }, - worker_processes = { - anyOf = { - { - type = "integer", - minimum = 1, - }, - { - type = "string" - }, - { - type = "string", - enum = { "auto" } - } - } - }, - enable_cpu_affinity = { - type = "boolean", - }, - worker_rlimit_nofile = { - type = "integer", - }, - worker_shutdown_timeout = { - type = "string", - }, - max_pending_timers = { - type = "integer", - }, - max_running_timers = { - type = "integer", - }, - event = { - type = "object", - properties = { - worker_connections = { - type = "integer" - }, - } - }, envs = { type = "array", minItems = 1, items = { type = "string", } - }, - meta = { - type = "object", - properties = { - lua_shared_dict = { - type = "object", - }, - } - }, - stream = { - type = "object", - properties = { - enable_access_log = { - type = "boolean", - }, - access_log = { - type = "string", - }, - access_log_format = { - type = "string", - }, - access_log_format_escape = { - type = "string", - }, - lua_shared_dict = { - type = "object", - }, - } - }, - main_configuration_snippet = { - type = "string" - }, - http_configuration_snippet = { - type = "string" - }, - http_server_configuration_snippet = { - type = "string" - }, - http_server_location_configuration_snippet = { - type = "string" - }, - http_admin_configuration_snippet = { - type = "string" - }, - http_end_configuration_snippet = { - type = "string" - }, - stream_configuration_snippet = { - type = "string" - }, - http = { - type = "object", - properties = { - enable_access_log = { - type = "boolean" - }, - access_log = { - type = "string" - }, - access_log_buffer = { - type = "integer" - }, - access_log_format = { - type = "string" - }, - access_log_format_escape = { - type = "string" - }, - keepalive_timeout = { - type = "string" - }, - client_header_timeout = { - type = "string" - }, - client_body_timeout = { - type = "string" - }, - client_max_body_size = { - anyOf = { - { - type = "number" - }, - { - type = "string" - } - } - }, - send_timeout = { - type = "string" - }, - underscores_in_headers = { - type = "string" - }, - real_ip_header = { - type = "string" - }, - real_ip_recursive = { - type = "string" - }, - real_ip_from = { - type = "array", - items = { - type = "string" - } - }, - custom_lua_shared_dict = { - type = "object" - }, - proxy_ssl_server_name = { - type = "boolean" - }, - upstream = { - type = "object", - properties = { - keepalive = { - type = "integer" - }, - keepalive_requests = { - type = "integer" - }, - keepalive_timeout = { - type = "string" - } - } - }, - charset = { - type = "string" - }, - variables_hash_max_size = { - type = "integer" - }, - lua_shared_dict = { - type = "object" - } - } } }, }, - -- TODO: Add schema for discovery http = { type = "object", properties = { @@ -638,14 +336,6 @@ local config_schema = { } } }, - graphql = { - type = "object", - properties = { - max_size = { - type = "integer" - } - } - }, etcd = etcd_schema, plugins = { type = "array", @@ -682,23 +372,20 @@ local config_schema = { type = "integer" }, http_request_phase = { - enum = { "access", "rewrite" }, + enum = {"access", "rewrite"}, default = "access", }, }, - required = { "name", "file", "priority" } + required = {"name", "file", "priority"} } } } }, - plugin_attr = { - type = "object" - }, deployment = { type = "object", properties = { role = { - enum = { "traditional", "control_plane", "data_plane", "standalone" }, + enum = {"traditional", "control_plane", "data_plane", "standalone"}, default = "traditional" }, }, @@ -760,9 +447,57 @@ local config_schema = { } }, }, - required = { "apisix", "deployment" }, + required = {"apisix", "deployment"}, } +-- local deployment_schema = { +-- traditional = { +-- properties = { +-- etcd = etcd_schema, +-- admin = admin_schema, +-- role_traditional = { +-- properties = { +-- config_provider = { +-- enum = {"etcd"} +-- }, +-- }, +-- required = {"config_provider"} +-- } +-- }, +-- required = {"etcd"} +-- }, +-- control_plane = { +-- properties = { +-- etcd = etcd_schema, +-- admin = admin_schema, +-- role_control_plane = { +-- properties = { +-- config_provider = { +-- enum = {"etcd"} +-- }, +-- }, +-- required = {"config_provider"} +-- }, +-- }, +-- required = {"etcd", "role_control_plane"} +-- }, +-- data_plane = { +-- properties = { +-- etcd = etcd_schema, +-- role_data_plane = { +-- properties = { +-- config_provider = { +-- enum = {"etcd", "yaml", "xds"} +-- }, +-- }, +-- required = {"config_provider"} +-- }, +-- }, +-- required = {"role_data_plane"} +-- } +-- } + + function _M.validate(yaml_conf) local validator = jsonschema.generate_validator(config_schema) local ok, err = validator(yaml_conf) @@ -783,7 +518,15 @@ function _M.validate(yaml_conf) end end + -- local role = yaml_conf.deployment.role + -- local validator = jsonschema.generate_validator(deployment_schema[role]) + -- local ok, err = validator(yaml_conf.deployment) + -- if not ok then + -- return false, "invalid deployment " .. role .. " configuration: " .. err + -- end + return true end -return _M + +return _M \ No newline at end of file From f22bc399dad994a0ac84e1400c7ac6f0780cae64 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 14:06:23 +0530 Subject: [PATCH 12/22] add newline Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 7e9186355eab..2f75193ee1df 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -529,4 +529,4 @@ function _M.validate(yaml_conf) end -return _M \ No newline at end of file +return _M From bf8bdb87649dc18cabd85624ce301d83991e65a2 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 14:48:59 +0530 Subject: [PATCH 13/22] revert to no change Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 265 ++++++++++++++---------------------------- 1 file changed, 87 insertions(+), 178 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 2f75193ee1df..6788435ee567 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -20,6 +20,7 @@ local pairs = pairs local pcall = pcall local require = require +-- test comment local _M = {} local etcd_schema = { @@ -66,81 +67,11 @@ local etcd_schema = { required = {"prefix", "host"} } -local admin_schema = { - type = "object", - properties = { - admin_key = { - type = "array", - properties = { - items = { - properties = { - name = {type = "string"}, - key = {type = "string"}, - role = {type = "string"}, - } - } - } - }, - admin_listen = { - properties = { - listen = { type = "string" }, - port = { type = "integer" }, - }, - default = { - listen = "0.0.0.0", - port = 9180, - } - }, - https_admin = { - type = "boolean", - }, - admin_key_required = { - type = "boolean", - }, - } -} - local config_schema = { type = "object", properties = { apisix = { properties = { - node_listen = { - anyOf = { - { - type = "integer", - minimum = 1, - maximum = 65535 - }, - { - type = "array", - items = { - type = "integer", - minimum = 1, - maximum = 65535 - } - }, - { - type = "array", - items = { - type = "object", - properties = { - port = { - type = "integer", - minimum = 1, - maximum = 65535 - }, - ip = { - type = "string", - }, - enable_http2 = { - type = "boolean", - }, - } - }, - } - }, - }, lua_module_hook = { pattern = "^[a-zA-Z._-]+$", }, @@ -387,115 +318,93 @@ local config_schema = { role = { enum = {"traditional", "control_plane", "data_plane", "standalone"}, default = "traditional" - }, + } }, - dependencies = { - role = { - oneOf = { - { - properties = { - role = { const = "traditional" }, - etcd = etcd_schema, - admin = admin_schema, - role_traditional = { - type = "object", - properties = { - config_provider = { - enum = { "etcd" } - }, - }, - required = { "config_provider" } - }, - }, - required = { "role_traditional" }, - }, - { - properties = { - role = { const = "control_plane" }, - etcd = etcd_schema, - admin = admin_schema, - role_control_plane = { - type = "object", - properties = { - config_provider = { - enum = { "etcd" } - }, - }, - required = { "config_provider" } - }, - }, - required = { "role_control_plane" }, - }, - { - properties = { - role = { const = "data_plane" }, - etcd = etcd_schema, - role_data_plane = { - type = "object", - properties = { - config_provider = { - enum = { "etcd", "yaml", "xds" } - }, - }, - required = { "config_provider" } - }, - }, - required = { "role_data_plane" }, - }, + }, + }, + required = {"apisix", "deployment"}, +} + +local admin_schema = { + type = "object", + properties = { + admin_key = { + type = "array", + properties = { + items = { + properties = { + name = {type = "string"}, + key = {type = "string"}, + role = {type = "string"}, } } } }, - }, - required = {"apisix", "deployment"}, + admin_listen = { + properties = { + listen = { type = "string" }, + port = { type = "integer" }, + }, + default = { + listen = "0.0.0.0", + port = 9180, + } + }, + https_admin = { + type = "boolean", + }, + admin_key_required = { + type = "boolean", + }, + } } --- local deployment_schema = { --- traditional = { --- properties = { --- etcd = etcd_schema, --- admin = admin_schema, --- role_traditional = { --- properties = { --- config_provider = { --- enum = {"etcd"} --- }, --- }, --- required = {"config_provider"} --- } --- }, --- required = {"etcd"} --- }, --- control_plane = { --- properties = { --- etcd = etcd_schema, --- admin = admin_schema, --- role_control_plane = { --- properties = { --- config_provider = { --- enum = {"etcd"} --- }, --- }, --- required = {"config_provider"} --- }, --- }, --- required = {"etcd", "role_control_plane"} --- }, --- data_plane = { --- properties = { --- etcd = etcd_schema, --- role_data_plane = { --- properties = { --- config_provider = { --- enum = {"etcd", "yaml", "xds"} --- }, --- }, --- required = {"config_provider"} --- }, --- }, --- required = {"role_data_plane"} --- } --- } +local deployment_schema = { + traditional = { + properties = { + etcd = etcd_schema, + admin = admin_schema, + role_traditional = { + properties = { + config_provider = { + enum = {"etcd"} + }, + }, + required = {"config_provider"} + } + }, + required = {"etcd"} + }, + control_plane = { + properties = { + etcd = etcd_schema, + admin = admin_schema, + role_control_plane = { + properties = { + config_provider = { + enum = {"etcd"} + }, + }, + required = {"config_provider"} + }, + }, + required = {"etcd", "role_control_plane"} + }, + data_plane = { + properties = { + etcd = etcd_schema, + role_data_plane = { + properties = { + config_provider = { + enum = {"etcd", "yaml", "xds"} + }, + }, + required = {"config_provider"} + }, + }, + required = {"role_data_plane"} + } +} function _M.validate(yaml_conf) @@ -518,12 +427,12 @@ function _M.validate(yaml_conf) end end - -- local role = yaml_conf.deployment.role - -- local validator = jsonschema.generate_validator(deployment_schema[role]) - -- local ok, err = validator(yaml_conf.deployment) - -- if not ok then - -- return false, "invalid deployment " .. role .. " configuration: " .. err - -- end + local role = yaml_conf.deployment.role + local validator = jsonschema.generate_validator(deployment_schema[role]) + local ok, err = validator(yaml_conf.deployment) + if not ok then + return false, "invalid deployment " .. role .. " configuration: " .. err + end return true end From e15de73ad0d8572aaff20b71895909cb611ff28c Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 15:50:23 +0530 Subject: [PATCH 14/22] test with minor changes Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 6788435ee567..62b889e9a967 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -20,7 +20,6 @@ local pairs = pairs local pcall = pcall local require = require --- test comment local _M = {} local etcd_schema = { @@ -72,6 +71,42 @@ local config_schema = { properties = { apisix = { properties = { + node_listen = { + anyOf = { + { + type = "integer", + minimum = 1, + maximum = 65535 + }, + { + type = "array", + items = { + type = "integer", + minimum = 1, + maximum = 65535 + } + }, + { + type = "array", + items = { + type = "object", + properties = { + port = { + type = "integer", + minimum = 1, + maximum = 65535 + }, + ip = { + type = "string", + }, + enable_http2 = { + type = "boolean", + }, + } + }, + } + }, + }, lua_module_hook = { pattern = "^[a-zA-Z._-]+$", }, From 0b8ad8d9ea0d89a461bc93785a885d2db97a855c Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 16:43:50 +0530 Subject: [PATCH 15/22] change etcd schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 62b889e9a967..99c1691dbb39 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -25,6 +25,12 @@ local _M = {} local etcd_schema = { type = "object", properties = { + health_check_timeout = { + type = "integer" + }, + startup_retry = { + type = "integer" + }, resync_delay = { type = "integer", }, @@ -43,6 +49,9 @@ local etcd_schema = { key = { type = "string", }, + verify = { + type = "boolean" + } }, }, prefix = { @@ -51,8 +60,7 @@ local etcd_schema = { host = { type = "array", items = { - type = "string", - pattern = [[^https?://]] + type = "string" }, minItems = 1, }, @@ -63,7 +71,7 @@ local etcd_schema = { description = "etcd connection timeout in seconds", }, }, - required = {"prefix", "host"} + required = { "host" } } local config_schema = { From 6409be42b5cbc99bd32b1d75ed1e5976560b2d9b Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 17:02:05 +0530 Subject: [PATCH 16/22] revert etcd schema change Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 46 ++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 99c1691dbb39..5f6ec63f64dc 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -25,12 +25,6 @@ local _M = {} local etcd_schema = { type = "object", properties = { - health_check_timeout = { - type = "integer" - }, - startup_retry = { - type = "integer" - }, resync_delay = { type = "integer", }, @@ -49,9 +43,6 @@ local etcd_schema = { key = { type = "string", }, - verify = { - type = "boolean" - } }, }, prefix = { @@ -60,7 +51,8 @@ local etcd_schema = { host = { type = "array", items = { - type = "string" + type = "string", + pattern = [[^https?://]] }, minItems = 1, }, @@ -71,7 +63,7 @@ local etcd_schema = { description = "etcd connection timeout in seconds", }, }, - required = { "host" } + required = {"prefix", "host"} } local config_schema = { @@ -376,9 +368,9 @@ local admin_schema = { properties = { items = { properties = { - name = {type = "string"}, - key = {type = "string"}, - role = {type = "string"}, + name = { type = "string" }, + key = { type = "string" }, + role = { type = "string" }, } } } @@ -399,6 +391,32 @@ local admin_schema = { admin_key_required = { type = "boolean", }, + enable_admin_cors = { + type = "boolean" + }, + allow_admin = { + type = "array", + items = { + type = "string" + } + }, + admin_api_mtls = { + type = "object", + properties = { + admin_ssl_cert = { + type = "string" + }, + admin_ssl_cert_key = { + type = "string" + }, + admin_ssl_ca_cert = { + type = "string" + } + } + }, + admin_api_version = { + type = "string" + } } } From 0608393267eaeee1a9da8ae7618bc172303009ef Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Wed, 15 Nov 2023 18:04:17 +0530 Subject: [PATCH 17/22] change validation logic Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 8 -------- 1 file changed, 8 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 5f6ec63f64dc..e67e074241eb 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -488,15 +488,7 @@ function _M.validate(yaml_conf) end end - local role = yaml_conf.deployment.role - local validator = jsonschema.generate_validator(deployment_schema[role]) - local ok, err = validator(yaml_conf.deployment) - if not ok then - return false, "invalid deployment " .. role .. " configuration: " .. err - end - return true end - return _M From fde02d8822acf262c0d8b2d05998ff07f8198831 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Thu, 16 Nov 2023 13:42:35 +0530 Subject: [PATCH 18/22] merge schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 181 ++++++++++++++++++++++++++---------------- 1 file changed, 114 insertions(+), 67 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index e67e074241eb..d8aa3ed3ba30 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -66,6 +66,66 @@ local etcd_schema = { required = {"prefix", "host"} } +local admin_schema = { + type = "object", + properties = { + admin_key = { + type = "array", + properties = { + items = { + properties = { + name = { type = "string" }, + key = { type = "string" }, + role = { type = "string" }, + } + } + } + }, + admin_listen = { + properties = { + listen = { type = "string" }, + port = { type = "integer" }, + }, + default = { + listen = "0.0.0.0", + port = 9180, + } + }, + https_admin = { + type = "boolean", + }, + admin_key_required = { + type = "boolean", + }, + enable_admin_cors = { + type = "boolean" + }, + allow_admin = { + type = "array", + items = { + type = "string" + } + }, + admin_api_mtls = { + type = "object", + properties = { + admin_ssl_cert = { + type = "string" + }, + admin_ssl_cert_key = { + type = "string" + }, + admin_ssl_ca_cert = { + type = "string" + } + } + }, + admin_api_version = { + type = "string" + } + } +} + local config_schema = { type = "object", properties = { @@ -347,79 +407,66 @@ local config_schema = { } } }, - deployment = { - type = "object", - properties = { - role = { - enum = {"traditional", "control_plane", "data_plane", "standalone"}, - default = "traditional" + dependencies = { + role = { + oneOf = { + { + properties = { + role = { const = "traditional" }, + etcd = etcd_schema, + admin = admin_schema, + role_traditional = { + type = "object", + properties = { + config_provider = { + enum = { "etcd" } + }, + }, + required = { "config_provider" } + }, + }, + required = { "role_traditional" }, + }, + { + properties = { + role = { const = "control_plane" }, + etcd = etcd_schema, + admin = admin_schema, + role_control_plane = { + type = "object", + properties = { + config_provider = { + enum = { "etcd" } + }, + }, + required = { "config_provider" } + }, + }, + required = { "role_control_plane" }, + }, + { + properties = { + role = { const = "data_plane" }, + etcd = etcd_schema, + role_data_plane = { + type = "object", + properties = { + config_provider = { + enum = { "etcd", "yaml", "xds" } + }, + }, + required = { "config_provider" } + }, + }, + required = { "role_data_plane" }, + }, } - }, + } }, }, required = {"apisix", "deployment"}, } -local admin_schema = { - type = "object", - properties = { - admin_key = { - type = "array", - properties = { - items = { - properties = { - name = { type = "string" }, - key = { type = "string" }, - role = { type = "string" }, - } - } - } - }, - admin_listen = { - properties = { - listen = { type = "string" }, - port = { type = "integer" }, - }, - default = { - listen = "0.0.0.0", - port = 9180, - } - }, - https_admin = { - type = "boolean", - }, - admin_key_required = { - type = "boolean", - }, - enable_admin_cors = { - type = "boolean" - }, - allow_admin = { - type = "array", - items = { - type = "string" - } - }, - admin_api_mtls = { - type = "object", - properties = { - admin_ssl_cert = { - type = "string" - }, - admin_ssl_cert_key = { - type = "string" - }, - admin_ssl_ca_cert = { - type = "string" - } - } - }, - admin_api_version = { - type = "string" - } - } -} - local deployment_schema = { traditional = { properties = { From 6e42a8908e89780c9826dcde8d3a0677003009ea Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Thu, 16 Nov 2023 14:01:49 +0530 Subject: [PATCH 19/22] remove deployment schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 48 ------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index d8aa3ed3ba30..76ee3ace8521 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -467,54 +467,6 @@ local config_schema = { required = {"apisix", "deployment"}, } -local deployment_schema = { - traditional = { - properties = { - etcd = etcd_schema, - admin = admin_schema, - role_traditional = { - properties = { - config_provider = { - enum = {"etcd"} - }, - }, - required = {"config_provider"} - } - }, - required = {"etcd"} - }, - control_plane = { - properties = { - etcd = etcd_schema, - admin = admin_schema, - role_control_plane = { - properties = { - config_provider = { - enum = {"etcd"} - }, - }, - required = {"config_provider"} - }, - }, - required = {"etcd", "role_control_plane"} - }, - data_plane = { - properties = { - etcd = etcd_schema, - role_data_plane = { - properties = { - config_provider = { - enum = {"etcd", "yaml", "xds"} - }, - }, - required = {"config_provider"} - }, - }, - required = {"role_data_plane"} - } -} - - function _M.validate(yaml_conf) local validator = jsonschema.generate_validator(config_schema) local ok, err = validator(yaml_conf) From a7d2027eb2667d0980b3704c71083e642b1ba86a Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Thu, 16 Nov 2023 15:13:44 +0530 Subject: [PATCH 20/22] proper formatting Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 76ee3ace8521..bb8fcd4936fc 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -63,7 +63,7 @@ local etcd_schema = { description = "etcd connection timeout in seconds", }, }, - required = {"prefix", "host"} + required = { "prefix", "host" } } local admin_schema = { @@ -214,12 +214,12 @@ local config_schema = { }, oneOf = { { - required = {"name", "memory_size"}, + required = { "name", "memory_size" }, maxProperties = 2, }, { - required = {"name", "memory_size", "disk_size", - "disk_path", "cache_levels"}, + required = { "name", "memory_size", "disk_size", + "disk_path", "cache_levels" }, } }, }, @@ -229,7 +229,7 @@ local config_schema = { }, proxy_mode = { type = "string", - enum = {"http", "stream", "http&stream"}, + enum = { "http", "stream", "http&stream" }, }, stream_proxy = { type = "object", @@ -262,7 +262,7 @@ local config_schema = { type = "boolean", } }, - required = {"addr"} + required = { "addr" } }, }, }, @@ -398,11 +398,11 @@ local config_schema = { type = "integer" }, http_request_phase = { - enum = {"access", "rewrite"}, + enum = { "access", "rewrite" }, default = "access", }, }, - required = {"name", "file", "priority"} + required = { "name", "file", "priority" } } } } @@ -464,7 +464,7 @@ local config_schema = { } }, }, - required = {"apisix", "deployment"}, + required = { "apisix", "deployment" }, } function _M.validate(yaml_conf) From 3a3b72bc5f642217198d0785e8be266db542936d Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Thu, 16 Nov 2023 16:15:36 +0530 Subject: [PATCH 21/22] add properties Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index bb8fcd4936fc..8c9ef90ade4d 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -167,6 +167,30 @@ local config_schema = { } }, }, + enable_admin = { + type = "boolean", + }, + enable_dev_mode = { + type = "boolean", + }, + enable_reuseport = { + type = "boolean", + }, + show_upstream_status_in_response_header = { + type = "boolean", + }, + enable_ipv6 = { + type = "boolean", + }, + enable_server_tokens = { + type = "boolean", + }, + extra_lua_path = { + type = "string" + }, + extra_lua_cpath = { + type = "string" + }, lua_module_hook = { pattern = "^[a-zA-Z._-]+$", }, From c6595f38d262dd715c612b556e02f75a4fbbcb92 Mon Sep 17 00:00:00 2001 From: Navendu Pottekkat Date: Fri, 17 Nov 2023 10:34:21 +0530 Subject: [PATCH 22/22] fix deployment schema Signed-off-by: Navendu Pottekkat --- apisix/cli/schema.lua | 91 ++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua index 8c9ef90ade4d..401998094625 100644 --- a/apisix/cli/schema.lua +++ b/apisix/cli/schema.lua @@ -431,59 +431,68 @@ local config_schema = { } } }, - dependencies = { - role = { - oneOf = { - { - properties = { - role = { const = "traditional" }, - etcd = etcd_schema, - admin = admin_schema, - role_traditional = { - type = "object", - properties = { - config_provider = { - enum = { "etcd" } + deployment = { + type = "object", + properties = { + role = { + enum = { "traditional", "control_plane", "data_plane", "standalone" }, + default = "traditional" + }, + }, + dependencies = { + role = { + oneOf = { + { + properties = { + role = { const = "traditional" }, + etcd = etcd_schema, + admin = admin_schema, + role_traditional = { + type = "object", + properties = { + config_provider = { + enum = { "etcd" } + }, }, + required = { "config_provider" } }, - required = { "config_provider" } }, + required = { "role_traditional" }, }, - required = { "role_traditional" }, - }, - { - properties = { - role = { const = "control_plane" }, - etcd = etcd_schema, - admin = admin_schema, - role_control_plane = { - type = "object", - properties = { - config_provider = { - enum = { "etcd" } + { + properties = { + role = { const = "control_plane" }, + etcd = etcd_schema, + admin = admin_schema, + role_control_plane = { + type = "object", + properties = { + config_provider = { + enum = { "etcd" } + }, }, + required = { "config_provider" } }, - required = { "config_provider" } }, + required = { "role_control_plane" }, }, - required = { "role_control_plane" }, - }, - { - properties = { - role = { const = "data_plane" }, - etcd = etcd_schema, - role_data_plane = { - type = "object", - properties = { - config_provider = { - enum = { "etcd", "yaml", "xds" } + { + properties = { + role = { const = "data_plane" }, + etcd = etcd_schema, + role_data_plane = { + type = "object", + properties = { + config_provider = { + enum = { "etcd", "yaml", "xds" } + }, }, + required = { "config_provider" } }, - required = { "config_provider" } }, + required = { "role_data_plane" }, }, - required = { "role_data_plane" }, - }, + } } } },