mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
refactor(types): decouple Proxmox config from proxmox package
Decouple the types package from the internal/proxmox package by defining a standalone ProxmoxConfig struct. This reduces circular dependencies and allows the types package to define its own configuration structures without importing the proxmox package. The route validation logic now converts between types.ProxmoxConfig and proxmox.NodeConfig where needed for internal operations.
This commit is contained in:
@@ -183,11 +183,17 @@ func (r *Route) validate() gperr.Error {
|
|||||||
}, r.started)
|
}, r.started)
|
||||||
|
|
||||||
if r.Proxmox != nil && r.Idlewatcher != nil {
|
if r.Proxmox != nil && r.Idlewatcher != nil {
|
||||||
r.Idlewatcher.Proxmox = r.Proxmox
|
r.Idlewatcher.Proxmox = &types.ProxmoxConfig{
|
||||||
|
Node: r.Proxmox.Node,
|
||||||
|
VMID: r.Proxmox.VMID,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Proxmox == nil && r.Idlewatcher != nil && r.Idlewatcher.Proxmox != nil {
|
if r.Proxmox == nil && r.Idlewatcher != nil && r.Idlewatcher.Proxmox != nil {
|
||||||
r.Proxmox = r.Idlewatcher.Proxmox
|
r.Proxmox = &proxmox.NodeConfig{
|
||||||
|
Node: r.Idlewatcher.Proxmox.Node,
|
||||||
|
VMID: r.Idlewatcher.Proxmox.VMID,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Proxmox != nil {
|
if r.Proxmox != nil {
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ 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 *proxmox.NodeConfig `json:"proxmox,omitempty"`
|
Proxmox *ProxmoxConfig `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.
|
||||||
@@ -43,6 +42,10 @@ 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 ProxmoxNodeConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
Reference in New Issue
Block a user