mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Add support for multiple label values in test cases
They are assigned in a round robin fashion Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
parent
1616525eac
commit
c9314dde59
@ -162,7 +162,7 @@
|
||||
nodeTemplatePath: config/node-default.yaml
|
||||
labelNodePrepareStrategy:
|
||||
labelKey: "failure-domain.beta.kubernetes.io/zone"
|
||||
labelValue: "zone1"
|
||||
labelValues: ["zone1"]
|
||||
initPods:
|
||||
- podTemplatePath: config/pod-with-node-affinity.yaml
|
||||
podsToSchedule:
|
||||
|
@ -980,22 +980,27 @@ func (*TrivialNodePrepareStrategy) CleanupDependentObjects(nodeName string, clie
|
||||
}
|
||||
|
||||
type LabelNodePrepareStrategy struct {
|
||||
LabelKey string
|
||||
LabelValue string
|
||||
LabelKey string
|
||||
LabelValues []string
|
||||
roundRobinIdx int
|
||||
}
|
||||
|
||||
var _ PrepareNodeStrategy = &LabelNodePrepareStrategy{}
|
||||
|
||||
func NewLabelNodePrepareStrategy(labelKey string, labelValue string) *LabelNodePrepareStrategy {
|
||||
func NewLabelNodePrepareStrategy(labelKey string, labelValues ...string) *LabelNodePrepareStrategy {
|
||||
return &LabelNodePrepareStrategy{
|
||||
LabelKey: labelKey,
|
||||
LabelValue: labelValue,
|
||||
LabelKey: labelKey,
|
||||
LabelValues: labelValues,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *LabelNodePrepareStrategy) PreparePatch(*v1.Node) []byte {
|
||||
labelString := fmt.Sprintf("{\"%v\":\"%v\"}", s.LabelKey, s.LabelValue)
|
||||
labelString := fmt.Sprintf("{\"%v\":\"%v\"}", s.LabelKey, s.LabelValues[s.roundRobinIdx])
|
||||
patch := fmt.Sprintf(`{"metadata":{"labels":%v}}`, labelString)
|
||||
s.roundRobinIdx++
|
||||
if s.roundRobinIdx == len(s.LabelValues) {
|
||||
s.roundRobinIdx = 0
|
||||
}
|
||||
return []byte(patch)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user