Added cluster mode metric
Build Docker image on push / docker (push) Successful in 22s
Build and push Docker image on tag / docker (push) Successful in 22s

This commit is contained in:
2026-08-17 21:29:09 +02:00
parent c4287c37bc
commit e5a5e6416b
4 changed files with 59 additions and 4 deletions
+9
View File
@@ -486,6 +486,15 @@ func (r *PveQemuStatus) IsRunning() bool {
return false
}
// GetClusterModeNumeric returns whether the PVE installation is configured as a cluster.
// The cluster status API includes an object with type "cluster" only in cluster mode.
func (r *PveClusterStatus) GetClusterModeNumeric() float64 {
if r.Type == "cluster" {
return 1
}
return 0
}
// GetClusterName returns name of cluster for labeling purposes.
// If there is no cluster then return standalone node with node name. Otherwise, it returns cluster name.
func (r *PveClusterStatus) GetClusterName() string {
+30
View File
@@ -0,0 +1,30 @@
package proxmox
import "testing"
func TestPveClusterStatusGetClusterModeNumeric(t *testing.T) {
tests := []struct {
name string
status PveClusterStatus
want float64
}{
{
name: "cluster mode",
status: PveClusterStatus{Type: "cluster"},
want: 1,
},
{
name: "standalone node",
status: PveClusterStatus{},
want: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.status.GetClusterModeNumeric(); got != tt.want {
t.Fatalf("GetClusterModeNumeric() = %v, want %v", got, tt.want)
}
})
}
}