Commit 6a644c25 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #50460 from vladimirvivien/set_fakeHost_node_labels_for_test

Automatic merge from submit-queue (batch tested with PRs 50626, 50683, 50679, 50684, 50460) Specify node labels for fakeVolumeHost **What this PR does / why we need it**: Adds ability to set arbitrary node labels to type `fakeVolumeHost`. Allows creation of tests of code that depends on reading node labels using `fakeVolumeHost.GetNodeLabels() `. **Release note**: ```release-note NONE ```
parents 9d732080 130bb035
...@@ -50,6 +50,7 @@ type fakeVolumeHost struct { ...@@ -50,6 +50,7 @@ type fakeVolumeHost struct {
cloud cloudprovider.Interface cloud cloudprovider.Interface
mounter mount.Interface mounter mount.Interface
writer io.Writer writer io.Writer
nodeLabels map[string]string
} }
func NewFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin) *fakeVolumeHost { func NewFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin) *fakeVolumeHost {
...@@ -60,6 +61,12 @@ func NewFakeVolumeHostWithCloudProvider(rootDir string, kubeClient clientset.Int ...@@ -60,6 +61,12 @@ func NewFakeVolumeHostWithCloudProvider(rootDir string, kubeClient clientset.Int
return newFakeVolumeHost(rootDir, kubeClient, plugins, cloud) return newFakeVolumeHost(rootDir, kubeClient, plugins, cloud)
} }
func NewFakeVolumeHostWithNodeLabels(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin, labels map[string]string) *fakeVolumeHost {
volHost := newFakeVolumeHost(rootDir, kubeClient, plugins, nil)
volHost.nodeLabels = labels
return volHost
}
func newFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin, cloud cloudprovider.Interface) *fakeVolumeHost { func newFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin, cloud cloudprovider.Interface) *fakeVolumeHost {
host := &fakeVolumeHost{rootDir: rootDir, kubeClient: kubeClient, cloud: cloud} host := &fakeVolumeHost{rootDir: rootDir, kubeClient: kubeClient, cloud: cloud}
host.mounter = &mount.FakeMounter{} host.mounter = &mount.FakeMounter{}
...@@ -149,7 +156,10 @@ func (f *fakeVolumeHost) GetConfigMapFunc() func(namespace, name string) (*v1.Co ...@@ -149,7 +156,10 @@ func (f *fakeVolumeHost) GetConfigMapFunc() func(namespace, name string) (*v1.Co
} }
func (f *fakeVolumeHost) GetNodeLabels() (map[string]string, error) { func (f *fakeVolumeHost) GetNodeLabels() (map[string]string, error) {
return map[string]string{"test-label": "test-value"}, nil if f.nodeLabels == nil {
f.nodeLabels = map[string]string{"test-label": "test-value"}
}
return f.nodeLabels, nil
} }
func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin { func ProbeVolumePlugins(config VolumeConfig) []VolumePlugin {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment