1/*
2Copyright 2017 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package flexvolume
18
19import (
20	"k8s.io/mount-utils"
21	utilstrings "k8s.io/utils/strings"
22
23	"k8s.io/apimachinery/pkg/types"
24	"k8s.io/kubernetes/pkg/volume"
25)
26
27type flexVolume struct {
28	// driverName is the name of the plugin driverName.
29	driverName string
30	// Driver executable used to setup the volume.
31	execPath string
32	// mounter provides the interface that is used to mount the actual
33	// block device.
34	mounter mount.Interface
35	// podName is the name of the pod, if available.
36	podName string
37	// podUID is the UID of the pod.
38	podUID types.UID
39	// podNamespace is the namespace of the pod, if available.
40	podNamespace string
41	// podServiceAccountName is the service account name of the pod, if available.
42	podServiceAccountName string
43	// volName is the name of the pod's volume.
44	volName string
45	// the underlying plugin
46	plugin *flexVolumePlugin
47	// the metric plugin
48	volume.MetricsProvider
49}
50
51// volume.Volume interface
52
53func (f *flexVolume) GetPath() string {
54	name := f.driverName
55	return f.plugin.host.GetPodVolumeDir(f.podUID, utilstrings.EscapeQualifiedName(name), f.volName)
56}
57