mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Pass pod metadata to flex plugin
This commit is contained in:
@@ -19,6 +19,7 @@ package flexvolume
|
||||
import (
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
"k8s.io/kubernetes/pkg/util/mount"
|
||||
@@ -26,7 +27,16 @@ import (
|
||||
|
||||
func TestSetUpAt(t *testing.T) {
|
||||
spec := fakeVolumeSpec()
|
||||
pod := &v1.Pod{}
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "my-pod",
|
||||
Namespace: "my-ns",
|
||||
UID: types.UID("my-uid"),
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
ServiceAccountName: "my-sa",
|
||||
},
|
||||
}
|
||||
mounter := &mount.FakeMounter{}
|
||||
|
||||
plugin, rootDir := testPlugin()
|
||||
@@ -34,12 +44,21 @@ func TestSetUpAt(t *testing.T) {
|
||||
plugin.runner = fakeRunner(
|
||||
// first call without fsGroup
|
||||
assertDriverCall(t, successOutput(), mountCmd, rootDir+"/mount-dir",
|
||||
specJson(plugin, spec, nil)),
|
||||
specJson(plugin, spec, map[string]string{
|
||||
optionKeyPodName: "my-pod",
|
||||
optionKeyPodNamespace: "my-ns",
|
||||
optionKeyPodUID: "my-uid",
|
||||
optionKeyServiceAccountName: "my-sa",
|
||||
})),
|
||||
|
||||
// second test has fsGroup
|
||||
assertDriverCall(t, notSupportedOutput(), mountCmd, rootDir+"/mount-dir",
|
||||
specJson(plugin, spec, map[string]string{
|
||||
optionFSGroup: "42",
|
||||
optionFSGroup: "42",
|
||||
optionKeyPodName: "my-pod",
|
||||
optionKeyPodNamespace: "my-ns",
|
||||
optionKeyPodUID: "my-uid",
|
||||
optionKeyServiceAccountName: "my-sa",
|
||||
})),
|
||||
assertDriverCall(t, fakeVolumeNameOutput("sdx"), getVolumeNameCmd,
|
||||
specJson(plugin, spec, nil)),
|
||||
|
||||
Reference in New Issue
Block a user