From 48790b4756b1e56d60d6504c7c3987ac48d8101c Mon Sep 17 00:00:00 2001 From: yusing Date: Sun, 25 Jan 2026 17:19:25 +0800 Subject: [PATCH] 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. --- internal/route/route.go | 10 ++++++++-- internal/types/idlewatcher.go | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/internal/route/route.go b/internal/route/route.go index ceb2bf03..9277dd29 100644 --- a/internal/route/route.go +++ b/internal/route/route.go @@ -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 { diff --git a/internal/types/idlewatcher.go b/internal/types/idlewatcher.go index 9e01d1a1..a83d1449 100644 --- a/internal/types/idlewatcher.go +++ b/internal/types/idlewatcher.go @@ -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 (