Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

feat: expand upstreams model and validation for 3.0 #311

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
293 changes: 169 additions & 124 deletions internal/gen/grpc/kong/admin/model/v1/upstream.pb.go

Large diffs are not rendered by default.

178 changes: 174 additions & 4 deletions internal/gen/jsonschema/schemas/upstream.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,35 @@
"consumer",
"ip",
"header",
"cookie"
"cookie",
"path",
"query_arg",
"uri_capture"
],
"type": "string"
},
"hash_fallback_header": {
"pattern": "^[A-Za-z0-9!#$%\u0026'*+-.^_|~]{1,64}$",
"type": "string"
},
"hash_fallback_query_arg": {
"pattern": "^[a-zA-Z0-9-_]+$",
"type": "string"
},
"hash_fallback_uri_capture": {
"pattern": "^[a-zA-Z0-9-_]+$",
"type": "string"
},
"hash_on": {
"enum": [
"none",
"consumer",
"ip",
"header",
"cookie"
"cookie",
"path",
"query_arg",
"uri_capture"
],
"type": "string"
},
Expand Down Expand Up @@ -81,6 +95,14 @@
"pattern": "^[A-Za-z0-9!#$%\u0026'*+-.^_|~]{1,64}$",
"type": "string"
},
"hash_on_query_arg": {
"pattern": "^[a-zA-Z0-9-_]+$",
"type": "string"
},
"hash_on_uri_capture": {
"pattern": "^[a-zA-Z0-9-_]+$",
"type": "string"
},
"healthchecks": {
"properties": {
"active": {
Expand Down Expand Up @@ -430,7 +452,7 @@
}
},
{
"description": "when 'hash_on' is set to 'consumer', 'hash_fallback' must be set to one of 'none', 'ip', 'header', 'cookie'",
"description": "when 'hash_on' is set to 'consumer', 'hash_fallback' must be set to one of 'none', 'ip', 'header', 'cookie', 'path', 'query_arg', 'uri_capture'",
"if": {
"required": [
"hash_on"
Expand Down Expand Up @@ -463,14 +485,26 @@
{
"type": "string",
"const": "cookie"
},
{
"type": "string",
"const": "path"
},
{
"type": "string",
"const": "query_arg"
},
{
"type": "string",
"const": "uri_capture"
}
]
}
}
}
},
{
"description": "when 'hash_on' is set to 'ip', 'hash_fallback' must be set to one of 'none', 'consumer', 'header', 'cookie'",
"description": "when 'hash_on' is set to 'ip', 'hash_fallback' must be set to one of 'none', 'consumer', 'header', 'cookie', 'path', 'query_arg', 'uri_capture'",
"if": {
"required": [
"hash_on"
Expand Down Expand Up @@ -503,11 +537,147 @@
{
"type": "string",
"const": "cookie"
},
{
"type": "string",
"const": "path"
},
{
"type": "string",
"const": "query_arg"
},
{
"type": "string",
"const": "uri_capture"
}
]
}
}
}
},
{
"description": "when 'hash_on' is set to 'path', 'hash_fallback' must be set to one of 'none', 'consumer', 'ip', 'header', 'cookie', 'query_arg', 'uri_capture'",
"if": {
"required": [
"hash_on"
],
"properties": {
"hash_on": {
"const": "path"
}
}
},
"then": {
"required": [
"hash_fallback"
],
"properties": {
"hash_fallback": {
"anyOf": [
{
"type": "string",
"const": "none"
},
{
"type": "string",
"const": "consumer"
},
{
"type": "string",
"const": "header"
},
{
"type": "string",
"const": "cookie"
},
{
"type": "string",
"const": "ip"
},
{
"type": "string",
"const": "query_arg"
},
{
"type": "string",
"const": "uri_capture"
}
]
}
}
}
},
{
"description": "when 'hash_on' is set to 'query_arg', 'hash_on_query_arg' must be set",
"if": {
"required": [
"hash_on"
],
"properties": {
"hash_on": {
"const": "query_arg"
}
}
},
"then": {
"required": [
"hash_on_query_arg"
]
}
},
{
"description": "when 'hash_fallback' is set to 'query_arg', 'hash_fallback_query_arg' must be set",
"if": {
"required": [
"hash_fallback"
],
"properties": {
"hash_fallback": {
"const": "query_arg"
}
}
},
"then": {
"required": [
"hash_fallback_query_arg"
]
}
},
{
"description": "when 'hash_on' is set to 'uri_capture', 'hash_on_uri_capture' must be set",
"if": {
"required": [
"hash_on"
],
"properties": {
"hash_on": {
"const": "uri_capture"
}
}
},
"then": {
"required": [
"hash_on_uri_capture"
]
}
},
{
"description": "when 'hash_fallback' is set to 'uri_capture', 'hash_fallback_uri_capture' must be set",
"if": {
"required": [
"hash_fallback"
],
"properties": {
"hash_fallback": {
"const": "uri_capture"
}
}
},
"then": {
"required": [
"hash_fallback_uri_capture"
]
}
}
],
"x-koko-config": {
Expand Down
24 changes: 24 additions & 0 deletions internal/gen/swagger/koko.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3279,6 +3279,18 @@
},
"client_certificate": {
"$ref": "#/definitions/kong.admin.model.v1.Certificate"
},
"hash_on_query_arg": {
"type": "string"
},
"hash_fallback_query_arg": {
"type": "string"
},
"hash_on_uri_capture": {
"type": "string"
},
"hash_fallback_uri_capture": {
"type": "string"
}
}
}
Expand Down Expand Up @@ -4175,6 +4187,18 @@
},
"client_certificate": {
"$ref": "#/definitions/kong.admin.model.v1.Certificate"
},
"hash_on_query_arg": {
"type": "string"
},
"hash_fallback_query_arg": {
"type": "string"
},
"hash_on_uri_capture": {
"type": "string"
},
"hash_fallback_uri_capture": {
"type": "string"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions internal/grpc/proto/kong/admin/model/v1/upstream.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ message Upstream {
repeated string tags = 14;
string host_header = 15;
Certificate client_certificate = 16;
string hash_on_query_arg = 17;
string hash_fallback_query_arg = 18;
string hash_on_uri_capture = 19;
string hash_fallback_uri_capture = 20;
}

message Healthchecks {
Expand Down
Loading