Fixed storage content label sorting

This commit is contained in:
Jan Lošťák
2024-05-30 13:48:07 +02:00
parent 6a5167c14f
commit 1be0aac715
2 changed files with 11 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ package proxmox
import (
"errors"
"fmt"
"sort"
"strings"
)
// PveVersion represents the version information of a PVE (Proxmox Virtual Environment).
@@ -492,3 +494,11 @@ func (r *PveClusterStatus) GetClusterName() string {
}
return r.Name
}
// GetContentSorted returns sorted storage content.
// This is crucial for labeling because PVE API returns these walues randomly sorted.
func (r *PveStorage) GetContentSorted() string {
parts := strings.Split(r.Content, ",")
sort.Strings(parts)
return strings.Join(parts, ",")
}