Squashed 'k8smain/' content from commit 719158d
git-subtree-dir: k8smain git-subtree-split: 719158d2c8788c30cc9e1c51bbebb53c5801524e
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2015 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package schedulercache
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
|
||||
)
|
||||
|
||||
// FakeCache is used for testing
|
||||
type FakeCache struct {
|
||||
AssumeFunc func(*api.Pod)
|
||||
}
|
||||
|
||||
func (f *FakeCache) AssumePodIfBindSucceed(pod *api.Pod, bind func() bool) error {
|
||||
if !bind() {
|
||||
return nil
|
||||
}
|
||||
f.AssumeFunc(pod)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *FakeCache) AddPod(pod *api.Pod) error { return nil }
|
||||
|
||||
func (f *FakeCache) UpdatePod(oldPod, newPod *api.Pod) error { return nil }
|
||||
|
||||
func (f *FakeCache) RemovePod(pod *api.Pod) error { return nil }
|
||||
|
||||
func (f *FakeCache) GetNodeNameToInfoMap() (map[string]*schedulercache.NodeInfo, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (f *FakeCache) List(s labels.Selector) ([]*api.Pod, error) { return nil, nil }
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2015 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package schedulercache
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
|
||||
)
|
||||
|
||||
// PodsToCache is used for testing
|
||||
type PodsToCache []*api.Pod
|
||||
|
||||
func (p PodsToCache) AssumePodIfBindSucceed(pod *api.Pod, bind func() bool) error {
|
||||
if !bind() {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p PodsToCache) AddPod(pod *api.Pod) error { return nil }
|
||||
|
||||
func (p PodsToCache) UpdatePod(oldPod, newPod *api.Pod) error { return nil }
|
||||
|
||||
func (p PodsToCache) RemovePod(pod *api.Pod) error { return nil }
|
||||
|
||||
func (p PodsToCache) GetNodeNameToInfoMap() (map[string]*schedulercache.NodeInfo, error) {
|
||||
return schedulercache.CreateNodeNameToInfoMap(p), nil
|
||||
}
|
||||
|
||||
func (p PodsToCache) List(s labels.Selector) (selected []*api.Pod, err error) {
|
||||
for _, pod := range p {
|
||||
if s.Matches(labels.Set(pod.Labels)) {
|
||||
selected = append(selected, pod)
|
||||
}
|
||||
}
|
||||
return selected, nil
|
||||
}
|
||||
Reference in New Issue
Block a user