volume.go 1.6 KB

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