cat schema.lua
local typedefs = require "kong.db.schema.typedefs"
return {
name = "http-service",
fields = {
{ consumer=typedefs.no_consumer },
{ protocols = typedefs.protocols_http },
{ config = {
type = "record",
fields = {
{ policy = {
type = "string",
default = "redis",
len_min = 0,
one_of = {"redis" },
}, },
{ v2_Share_weight = { type = "number", default = 10, }, },
{ v2_Fengyun_weight = { type = "number", default = 10, }, },
{ v2_Easypay_weight = { type = "number", default = 10, }, },
{ Share_rt_json_v1 = { type = "string", len_min = 0 }, },
{ Share_rt_json_v2 = { type = "string", len_min = 0 }, },
{ Fengyun_rt_json_v1 = { type = "string", len_min = 0 }, },
{ Fengyun_rt_json_v2 = { type = "string", len_min = 0 }, },
{ Easypay_rt_json_v1 = { type = "string", len_min = 0 }, },
{ Easypay_rt_json_v2 = { type = "string", len_min = 0 }, },
{ redis_host = typedefs.host },
{ redis_port = typedefs.port({ default = 6379 }), },
{ redis_password = { type = "string", len_min = 0 }, },
{ redis_timeout = { type = "number", default = 2000, }, },
custom_validator = validate_periods_order,
entity_checks = {
{ conditional = {
if_field = "config.policy", if_match = { eq = "redis" },
then_field = "config.redis_host", then_match = { required = true },
} },
{ conditional = {
if_field = "config.policy", if_match = { eq = "redis" },
then_field = "config.redis_port", then_match = { required = true },
} },
{ conditional = {
if_field = "config.policy", if_match = { eq = "redis" },
then_field = "config.redis_timeout", then_match = { required = true },
} },
配置使用konga, 然后测试的话 就多测就完事了
- mountPath: /mnt
name: volume-1564450826736
- mountPath: /usr/local/share/lua/5.1/kong/constants.lua
name: volume-1567501801119
subPath: constants.lua
- mountPath: /usr/local/share/lua/5.1/kong/plugins/http-service/
name: volume-1567502147319
volumes:
- hostPath:
path: /opt/logs/pre-kong/
type: ''
name: volume-1564450826736
- configMap:
defaultMode: 420
name: constants.lua
name: volume-1567501801119
- configMap:
defaultMode: 420
name: handler.lua
name: volume-1567502147319