hostutil_unsupported.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // +build !linux,!windows
  2. /*
  3. Copyright 2014 The Kubernetes Authors.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. package hostutil
  15. import (
  16. "errors"
  17. "os"
  18. "k8s.io/utils/mount"
  19. )
  20. // HostUtil is an HostUtils implementation that allows compilation on
  21. // unsupported platforms
  22. type HostUtil struct{}
  23. // NewHostUtil returns a struct that implements the HostUtils interface on
  24. // unsupported platforms
  25. func NewHostUtil() *HostUtil {
  26. return &HostUtil{}
  27. }
  28. var errUnsupported = errors.New("volume/util/hostutil on this platform is not supported")
  29. // DeviceOpened always returns an error on unsupported platforms
  30. func (hu *HostUtil) DeviceOpened(pathname string) (bool, error) {
  31. return false, errUnsupported
  32. }
  33. // PathIsDevice always returns an error on unsupported platforms
  34. func (hu *HostUtil) PathIsDevice(pathname string) (bool, error) {
  35. return true, errUnsupported
  36. }
  37. // GetDeviceNameFromMount always returns an error on unsupported platforms
  38. func (hu *HostUtil) GetDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error) {
  39. return getDeviceNameFromMount(mounter, mountPath, pluginMountDir)
  40. }
  41. // MakeRShared always returns an error on unsupported platforms
  42. func (hu *HostUtil) MakeRShared(path string) error {
  43. return errUnsupported
  44. }
  45. // GetFileType always returns an error on unsupported platforms
  46. func (hu *HostUtil) GetFileType(pathname string) (FileType, error) {
  47. return FileType("fake"), errUnsupported
  48. }
  49. // MakeFile always returns an error on unsupported platforms
  50. func (hu *HostUtil) MakeFile(pathname string) error {
  51. return errUnsupported
  52. }
  53. // MakeDir always returns an error on unsupported platforms
  54. func (hu *HostUtil) MakeDir(pathname string) error {
  55. return errUnsupported
  56. }
  57. // PathExists always returns an error on unsupported platforms
  58. func (hu *HostUtil) PathExists(pathname string) (bool, error) {
  59. return true, errUnsupported
  60. }
  61. // EvalHostSymlinks always returns an error on unsupported platforms
  62. func (hu *HostUtil) EvalHostSymlinks(pathname string) (string, error) {
  63. return "", errUnsupported
  64. }
  65. // GetOwner always returns an error on unsupported platforms
  66. func (hu *HostUtil) GetOwner(pathname string) (int64, int64, error) {
  67. return -1, -1, errUnsupported
  68. }
  69. // GetSELinuxSupport always returns an error on unsupported platforms
  70. func (hu *HostUtil) GetSELinuxSupport(pathname string) (bool, error) {
  71. return false, errUnsupported
  72. }
  73. //GetMode always returns an error on unsupported platforms
  74. func (hu *HostUtil) GetMode(pathname string) (os.FileMode, error) {
  75. return 0, errUnsupported
  76. }
  77. func getDeviceNameFromMount(mounter mount.Interface, mountPath, pluginMountDir string) (string, error) {
  78. return "", errUnsupported
  79. }