Full web : clusters gérés dans l'UI, primaire et cibles, comptes pve

This commit is contained in:
claude Bot committed 2026-10-23 17:23:14 +02:00
1 parent 3e9cb563be
commit ec3b7c9a01
5 files changed
+617 -453

No files matched your search

+16 -12
View File
@@ -1,6 +1,6 @@
// Package model holds the generic, normalized representation of synchronized objects.
// Field values are canonical strings or sorted string lists, so that two clusters
// can be compared field by field and the result serialized to YAML without loss.
// can be compared field by field.
package model
import (
@@ -15,32 +15,36 @@ type Kind string
const (
KindDatacenter Kind = "datacenter-options"
KindGroup Kind = "pve-group" // groups of user.cfg
KindRole Kind = "pve-role" // custom roles of user.cfg
KindUser Kind = "pve-user" // accounts of the pve realm
KindPassword Kind = "pve-password" // their password hashes (SSH, priv/shadow.cfg)
KindZone Kind = "sdn-zone"
KindVNet Kind = "sdn-vnet"
KindSubnet Kind = "sdn-subnet"
)
// Kinds lists the kinds in dependency order (creation order).
var Kinds = []Kind{KindDatacenter, KindZone, KindVNet, KindSubnet}
var Kinds = []Kind{KindDatacenter, KindGroup, KindRole, KindUser, KindPassword, KindZone, KindVNet, KindSubnet}
// Object is one configuration object of a cluster.
// Field values are either string or []string (see Normalize).
type Object struct {
Kind Kind `yaml:"kind" json:"kind"`
ID string `yaml:"id" json:"id"`
Fields map[string]any `yaml:"fields" json:"fields"`
Kind Kind `json:"kind"`
ID string `json:"id"`
Fields map[string]any `json:"fields"`
}
// Key is the unique identity of an object inside a cluster.
func (o Object) Key() string { return string(o.Kind) + "/" + o.ID }
// Snapshot is the exported state of one cluster (YAML, versionable in Git).
// Snapshot is the state read from one cluster.
type Snapshot struct {
Cluster string `yaml:"cluster"`
PVEVersion string `yaml:"pve_version,omitempty"`
ExportedAt time.Time `yaml:"exported_at"`
Objects []Object `yaml:"objects"`
Warnings []string `yaml:"warnings,omitempty"`
Cluster string `json:"cluster"`
PVEVersion string `json:"pveVersion,omitempty"`
ExportedAt time.Time `json:"readAt"`
Objects []Object `json:"objects"`
Warnings []string `json:"warnings,omitempty"`
}
// Sort orders objects by kind (dependency order) then by id.
@@ -57,7 +61,7 @@ func Sort(objs []Object) {
})
}
// Normalize turns a YAML/JSON decoded field map into canonical values:
// Normalize turns a JSON decoded field map into canonical values:
// scalars become strings, lists become sorted []string.
func Normalize(fields map[string]any) map[string]any {
out := make(map[string]any, len(fields))