mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 08:48:32 +02:00
refactor(proxmox): consolidate NodeConfig and add service field
Centralize Proxmox node configuration by moving `ProxmoxConfig` from `internal/types/idlewatcher.go` to a new `NodeConfig` struct in `internal/proxmox/node.go`. - Add `proxmox` field to route; allowing `proxy.app.proxmox` labels and corresponding route file config - Added `service` optional field to NodeConfig for service identification - Integrated Proxmox config directly into Route struct with proper validation - Propagate Proxmox settings to Idlewatcher during route validation - Updated swagger documentation to reflect schema changes
This commit is contained in:
@@ -3750,7 +3750,7 @@
|
|||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
"proxmox": {
|
"proxmox": {
|
||||||
"$ref": "#/definitions/ProxmoxConfig",
|
"$ref": "#/definitions/ProxmoxNodeConfig",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
@@ -4369,7 +4369,7 @@
|
|||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
"ProxmoxConfig": {
|
"ProxmoxNodeConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"node",
|
"node",
|
||||||
@@ -4381,6 +4381,9 @@
|
|||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
"x-omitempty": false
|
"x-omitempty": false
|
||||||
},
|
},
|
||||||
|
"service": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"vmid": {
|
"vmid": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
@@ -4600,6 +4603,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": true
|
"x-nullable": true
|
||||||
},
|
},
|
||||||
|
"proxmox": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/ProxmoxNodeConfig"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x-nullable": true
|
||||||
|
},
|
||||||
"purl": {
|
"purl": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
@@ -6069,6 +6080,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": true
|
"x-nullable": true
|
||||||
},
|
},
|
||||||
|
"proxmox": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/ProxmoxNodeConfig"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"x-nullable": true
|
||||||
|
},
|
||||||
"purl": {
|
"purl": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-nullable": false,
|
"x-nullable": false,
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ definitions:
|
|||||||
no_loading_page:
|
no_loading_page:
|
||||||
type: boolean
|
type: boolean
|
||||||
proxmox:
|
proxmox:
|
||||||
$ref: '#/definitions/ProxmoxConfig'
|
$ref: '#/definitions/ProxmoxNodeConfig'
|
||||||
start_endpoint:
|
start_endpoint:
|
||||||
description: Optional path that must be hit to start container
|
description: Optional path that must be hit to start container
|
||||||
type: string
|
type: string
|
||||||
@@ -933,10 +933,12 @@ definitions:
|
|||||||
- ProviderTypeDocker
|
- ProviderTypeDocker
|
||||||
- ProviderTypeFile
|
- ProviderTypeFile
|
||||||
- ProviderTypeAgent
|
- ProviderTypeAgent
|
||||||
ProxmoxConfig:
|
ProxmoxNodeConfig:
|
||||||
properties:
|
properties:
|
||||||
node:
|
node:
|
||||||
type: string
|
type: string
|
||||||
|
service:
|
||||||
|
type: string
|
||||||
vmid:
|
vmid:
|
||||||
type: integer
|
type: integer
|
||||||
required:
|
required:
|
||||||
@@ -1050,6 +1052,10 @@ definitions:
|
|||||||
description: for backward compatibility
|
description: for backward compatibility
|
||||||
type: string
|
type: string
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
|
proxmox:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/ProxmoxNodeConfig'
|
||||||
|
x-nullable: true
|
||||||
purl:
|
purl:
|
||||||
type: string
|
type: string
|
||||||
response_header_timeout:
|
response_header_timeout:
|
||||||
@@ -1849,6 +1855,10 @@ definitions:
|
|||||||
description: for backward compatibility
|
description: for backward compatibility
|
||||||
type: string
|
type: string
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
|
proxmox:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/ProxmoxNodeConfig'
|
||||||
|
x-nullable: true
|
||||||
purl:
|
purl:
|
||||||
type: string
|
type: string
|
||||||
response_header_timeout:
|
response_header_timeout:
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ import (
|
|||||||
"github.com/yusing/goutils/pool"
|
"github.com/yusing/goutils/pool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type NodeConfig struct {
|
||||||
|
Node string `json:"node" validate:"required"`
|
||||||
|
VMID int `json:"vmid" validate:"required"`
|
||||||
|
Service string `json:"service,omitempty"`
|
||||||
|
} // @name ProxmoxNodeConfig
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
name string
|
name string
|
||||||
id string // likely node/<name>
|
id string // likely node/<name>
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ type (
|
|||||||
AccessLog *accesslog.RequestLoggerConfig `json:"access_log,omitempty" extensions:"x-nullable"`
|
AccessLog *accesslog.RequestLoggerConfig `json:"access_log,omitempty" extensions:"x-nullable"`
|
||||||
Agent string `json:"agent,omitempty"`
|
Agent string `json:"agent,omitempty"`
|
||||||
|
|
||||||
|
Proxmox *proxmox.NodeConfig `json:"proxmox,omitempty" extensions:"x-nullable"`
|
||||||
|
|
||||||
Idlewatcher *types.IdlewatcherConfig `json:"idlewatcher,omitempty" extensions:"x-nullable"`
|
Idlewatcher *types.IdlewatcherConfig `json:"idlewatcher,omitempty" extensions:"x-nullable"`
|
||||||
|
|
||||||
Metadata `deserialize:"-"`
|
Metadata `deserialize:"-"`
|
||||||
@@ -176,6 +178,10 @@ func (r *Route) validate() gperr.Error {
|
|||||||
}
|
}
|
||||||
}, r.started)
|
}, r.started)
|
||||||
|
|
||||||
|
if r.Proxmox != nil && r.Idlewatcher != nil {
|
||||||
|
r.Idlewatcher.Proxmox = r.Proxmox
|
||||||
|
}
|
||||||
|
|
||||||
if r.Idlewatcher != nil && r.Idlewatcher.Proxmox != nil {
|
if r.Idlewatcher != nil && r.Idlewatcher.Proxmox != nil {
|
||||||
node := r.Idlewatcher.Proxmox.Node
|
node := r.Idlewatcher.Proxmox.Node
|
||||||
vmid := r.Idlewatcher.Proxmox.VMID
|
vmid := r.Idlewatcher.Proxmox.VMID
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/yusing/godoxy/internal/proxmox"
|
||||||
gperr "github.com/yusing/goutils/errs"
|
gperr "github.com/yusing/goutils/errs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
IdlewatcherProviderConfig struct {
|
IdlewatcherProviderConfig struct {
|
||||||
Proxmox *ProxmoxConfig `json:"proxmox,omitempty"`
|
Proxmox *proxmox.NodeConfig `json:"proxmox,omitempty"`
|
||||||
Docker *DockerConfig `json:"docker,omitempty"`
|
Docker *DockerConfig `json:"docker,omitempty"`
|
||||||
} // @name IdlewatcherProviderConfig
|
} // @name IdlewatcherProviderConfig
|
||||||
IdlewatcherConfigBase struct {
|
IdlewatcherConfigBase struct {
|
||||||
// 0: no idle watcher.
|
// 0: no idle watcher.
|
||||||
@@ -42,10 +43,6 @@ type (
|
|||||||
ContainerID string `json:"container_id" validate:"required"`
|
ContainerID string `json:"container_id" validate:"required"`
|
||||||
ContainerName string `json:"container_name" validate:"required"`
|
ContainerName string `json:"container_name" validate:"required"`
|
||||||
} // @name DockerConfig
|
} // @name DockerConfig
|
||||||
ProxmoxConfig struct {
|
|
||||||
Node string `json:"node" validate:"required"`
|
|
||||||
VMID int `json:"vmid" validate:"required"`
|
|
||||||
} // @name ProxmoxConfig
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
Reference in New Issue
Block a user