mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: update replaced k8s.io modules to v0.33.0
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
dd77e72800
commit
107407b44b
35
e2e/vendor/k8s.io/dynamic-resource-allocation/resourceclaim/resourceclaim.go
generated
vendored
35
e2e/vendor/k8s.io/dynamic-resource-allocation/resourceclaim/resourceclaim.go
generated
vendored
@ -26,6 +26,8 @@ package resourceclaim
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1beta1"
|
||||
@ -106,3 +108,36 @@ func CanBeReserved(claim *resourceapi.ResourceClaim) bool {
|
||||
// Currently no restrictions on sharing...
|
||||
return true
|
||||
}
|
||||
|
||||
// BaseRequestRef returns the request name if the reference is to a top-level
|
||||
// request and the name of the parent request if the reference is to a subrequest.
|
||||
func BaseRequestRef(requestRef string) string {
|
||||
segments := strings.Split(requestRef, "/")
|
||||
return segments[0]
|
||||
}
|
||||
|
||||
// ConfigForResult returns the configs that are applicable to device
|
||||
// allocated for the provided result.
|
||||
func ConfigForResult(deviceConfigurations []resourceapi.DeviceAllocationConfiguration, result resourceapi.DeviceRequestAllocationResult) []resourceapi.DeviceAllocationConfiguration {
|
||||
var configs []resourceapi.DeviceAllocationConfiguration
|
||||
for _, deviceConfiguration := range deviceConfigurations {
|
||||
if deviceConfiguration.Opaque != nil &&
|
||||
isMatch(deviceConfiguration.Requests, result.Request) {
|
||||
configs = append(configs, deviceConfiguration)
|
||||
}
|
||||
}
|
||||
return configs
|
||||
}
|
||||
|
||||
func isMatch(requests []string, requestRef string) bool {
|
||||
if len(requests) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
if slices.Contains(requests, requestRef) {
|
||||
return true
|
||||
}
|
||||
|
||||
baseRequestRef := BaseRequestRef(requestRef)
|
||||
return slices.Contains(requests, baseRequestRef)
|
||||
}
|
||||
|
Reference in New Issue
Block a user