mounter-defaults.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/klog"
  16. "k8s.io/kubernetes/pkg/volume"
  17. )
  18. type mounterDefaults flexVolumeMounter
  19. // SetUpAt is part of the volume.Mounter interface.
  20. // This implementation relies on the attacher's device mount path and does a bind mount to dir.
  21. func (f *mounterDefaults) SetUpAt(dir string, mounterArgs volume.MounterArgs) error {
  22. klog.Warning(logPrefix(f.plugin), "using default SetUpAt to ", dir)
  23. src, err := f.plugin.getDeviceMountPath(f.spec)
  24. if err != nil {
  25. return err
  26. }
  27. if err := doMount(f.mounter, src, dir, "auto", []string{"bind"}); err != nil {
  28. return err
  29. }
  30. return nil
  31. }
  32. // Returns the default volume attributes.
  33. func (f *mounterDefaults) GetAttributes() volume.Attributes {
  34. klog.V(5).Infof(logPrefix(f.plugin), "using default GetAttributes")
  35. return volume.Attributes{
  36. ReadOnly: f.readOnly,
  37. Managed: !f.readOnly,
  38. SupportsSELinux: f.flexVolume.plugin.capabilities.SELinuxRelabel,
  39. }
  40. }
  41. func (f *mounterDefaults) CanMount() error {
  42. return nil
  43. }