- Added upstream objects

- Renamed host templates to nginx templates
- Generate upstream templates
- Better nginx error reporting when reloading
- Use tparse for golang test reporting
This commit is contained in:
Jamie Curnow
2023-01-04 15:36:56 +10:00
parent b3ae2f4dbb
commit 5e5f0de0e2
82 changed files with 2209 additions and 294 deletions

View File

@ -17,14 +17,14 @@ func CreateHost() string {
"required": [
"type",
"domain_names",
"host_template_id"
"nginx_template_id"
],
"properties": {
"type": {
"type": "string",
"pattern": "^proxy$"
},
"host_template_id": {
"nginx_template_id": {
"type": "integer",
"minimum": 1
},
@ -63,9 +63,6 @@ func CreateHost() string {
"paths": {
"type": "string"
},
"upstream_options": {
"type": "string"
},
"advanced_config": {
"type": "string"
},

View File

@ -1,14 +1,14 @@
package schema
// CreateHostTemplate is the schema for incoming data validation
func CreateHostTemplate() string {
// CreateNginxTemplate is the schema for incoming data validation
func CreateNginxTemplate() string {
return `
{
"type": "object",
"additionalProperties": false,
"required": [
"name",
"host_type",
"type",
"template"
],
"properties": {
@ -16,9 +16,9 @@ func CreateHostTemplate() string {
"type": "string",
"minLength": 1
},
"host_type": {
"type": {
"type": "string",
"pattern": "^proxy|redirect|dead|stream$"
"pattern": "^proxy|redirect|dead|stream|upstream$"
},
"template": {
"type": "string",

View File

@ -0,0 +1,73 @@
package schema
import "fmt"
// CreateUpstream is the schema for incoming data validation
func CreateUpstream() string {
return fmt.Sprintf(`
{
"type": "object",
"additionalProperties": false,
"required": [
"name",
"servers",
"nginx_template_id"
],
"properties": {
"name": %s,
"nginx_template_id": {
"type": "integer",
"minimum": 1
},
"advanced_config": %s,
"ip_hash": {
"type": "boolean"
},
"ntlm": {
"type": "boolean"
},
"keepalive": {
"type": "integer"
},
"keepalive_requests": {
"type": "integer"
},
"keepalive_time": {
"type": "string"
},
"keepalive_timeout": {
"type": "string"
},
"servers": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"server"
],
"properties": {
"server": %s,
"weight": {
"type": "integer"
},
"max_conns": {
"type": "integer"
},
"max_fails": {
"type": "integer"
},
"fail_timeout": {
"type": "integer"
},
"backup": {
"type": "boolean"
}
}
}
}
}
}
`, stringMinMax(1, 100), stringMinMax(0, 1024), stringMinMax(2, 255))
}

View File

@ -10,7 +10,7 @@ func UpdateHost() string {
"additionalProperties": false,
"minProperties": 1,
"properties": {
"host_template_id": {
"nginx_template_id": {
"type": "integer",
"minimum": 1
},

View File

@ -1,7 +1,7 @@
package schema
// UpdateHostTemplate is the schema for incoming data validation
func UpdateHostTemplate() string {
func UpdateNginxTemplate() string {
return `
{
"type": "object",