nd002test/on-premise/main/rancher_v2.9.1/source/rancher-2.9.1/pkg/utils/utils.go

20 lines
443 B
Go

package utils
import (
"fmt"
"sort"
"strings"
v1 "k8s.io/api/core/v1"
)
func FormatResourceList(resources v1.ResourceList) string {
resourceStrings := make([]string, 0, len(resources))
for key, value := range resources {
resourceStrings = append(resourceStrings, fmt.Sprintf("%v=%v", key, value.String()))
}
// sort the results for consistent log output
sort.Strings(resourceStrings)
return strings.Join(resourceStrings, ",")
}