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:
yusing
2026-01-25 17:19:25 +08:00
parent 727a3e9452
commit 48790b4756
2 changed files with 14 additions and 5 deletions

View File

@@ -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 {

View File

@@ -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 (