From 130bb03549abd9666f33409006bda3d276c0b2e2 Mon Sep 17 00:00:00 2001 From: Vladimir Vivien Date: Thu, 10 Aug 2017 11:12:15 -0400 Subject: [PATCH] Specify node labels for fakeVolumeHost when testing --- pkg/volume/testing/testing.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/volume/testing/testing.go b/pkg/volume/testing/testing.go index 9ccd840c893..eacc124e64a 100644 --- a/pkg/volume/testing/testing.go +++ b/pkg/volume/testing/testing.go @@ -50,6 +50,7 @@ type fakeVolumeHost struct { cloud cloudprovider.Interface mounter mount.Interface writer io.Writer + nodeLabels map[string]string } func NewFakeVolumeHost(rootDir string, kubeClient clientset.Interface, plugins []VolumePlugin) *fakeVolumeHost { @@ -60,6 +61,12 @@ func NewFakeVolumeHostWithCloudProvider(rootDir string, kubeClient clientset.Int 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 { host := &fakeVolumeHost{rootDir: rootDir, kubeClient: kubeClient, cloud: cloud} host.mounter = &mount.FakeMounter{} @@ -149,7 +156,10 @@ func (f *fakeVolumeHost) GetConfigMapFunc() func(namespace, name string) (*v1.Co } 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 {