mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-26 02:51:07 +01: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)
|
||||
|
||||
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 {
|
||||
r.Proxmox = r.Idlewatcher.Proxmox
|
||||
r.Proxmox = &proxmox.NodeConfig{
|
||||
Node: r.Idlewatcher.Proxmox.Node,
|
||||
VMID: r.Idlewatcher.Proxmox.VMID,
|
||||
}
|
||||
}
|
||||
|
||||
if r.Proxmox != nil {
|
||||
|
||||
@@ -6,14 +6,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yusing/godoxy/internal/proxmox"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type (
|
||||
IdlewatcherProviderConfig struct {
|
||||
Proxmox *proxmox.NodeConfig `json:"proxmox,omitempty"`
|
||||
Docker *DockerConfig `json:"docker,omitempty"`
|
||||
Proxmox *ProxmoxConfig `json:"proxmox,omitempty"`
|
||||
Docker *DockerConfig `json:"docker,omitempty"`
|
||||
} // @name IdlewatcherProviderConfig
|
||||
IdlewatcherConfigBase struct {
|
||||
// 0: no idle watcher.
|
||||
@@ -43,6 +42,10 @@ type (
|
||||
ContainerID string `json:"container_id" validate:"required"`
|
||||
ContainerName string `json:"container_name" validate:"required"`
|
||||
} // @name DockerConfig
|
||||
ProxmoxConfig struct {
|
||||
Node string `json:"node" validate:"required"`
|
||||
VMID int `json:"vmid" validate:"required"`
|
||||
} // @name ProxmoxNodeConfig
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user