mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
feat(proxmox): better node-level routes auto-discovery with pointer VMID
- Add BaseURL field to Client for node-level route configuration - Change VMID from int to *int to support three states: - nil: auto-discover node or VM from hostname/IP/alias - 0: node-level route (direct to Proxmox node API) - >0: LXC/QEMU resource route with container control - Change Service string to Services []string for multi-service support - Implement proper node-level route handling: HTTPS scheme, hostname from node BaseURL, default port 8006 - Move initial UpdateResources call to Init before starting loop - Move proxmox auto-discovery earlier in route validation BREAKING: NodeConfig.VMID is now a pointer type; NodeConfig.Service renamed to Services (backward compatible via alias)
This commit is contained in:
@@ -96,6 +96,15 @@ func (c *Config) Init(ctx context.Context) gperr.Error {
|
||||
return gperr.New("failed to fetch proxmox cluster info").With(err)
|
||||
}
|
||||
|
||||
{
|
||||
reqCtx, reqCtxCancel := context.WithTimeout(ctx, ResourcePollInterval)
|
||||
err := c.client.UpdateResources(reqCtx)
|
||||
reqCtxCancel()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Str("cluster", c.client.Cluster.Name).Msg("[proxmox] failed to update resources")
|
||||
}
|
||||
}
|
||||
|
||||
go c.updateResourcesLoop(ctx)
|
||||
return nil
|
||||
}
|
||||
@@ -106,15 +115,6 @@ func (c *Config) updateResourcesLoop(ctx context.Context) {
|
||||
|
||||
log.Trace().Str("cluster", c.client.Cluster.Name).Msg("[proxmox] starting resources update loop")
|
||||
|
||||
{
|
||||
reqCtx, reqCtxCancel := context.WithTimeout(ctx, ResourcePollInterval)
|
||||
err := c.client.UpdateResources(reqCtx)
|
||||
reqCtxCancel()
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Str("cluster", c.client.Cluster.Name).Msg("[proxmox] failed to update resources")
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
||||
Reference in New Issue
Block a user