forked from kubernetes-csi/csi-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubernetes-csi#11 from ddebroy/filesystem1
FileSystem APIs
- Loading branch information
Showing
16 changed files
with
1,609 additions
and
108 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
filesystemapi "github.com/kubernetes-csi/csi-proxy/internal/os/filesystem" | ||
"github.com/kubernetes-csi/csi-proxy/internal/server" | ||
filesystem "github.com/kubernetes-csi/csi-proxy/internal/server/filesystem" | ||
filesystemsrv "github.com/kubernetes-csi/csi-proxy/internal/server/filesystem" | ||
srvtypes "github.com/kubernetes-csi/csi-proxy/internal/server/types" | ||
flag "github.com/spf13/pflag" | ||
) | ||
|
||
var ( | ||
kubeletCSIPluginsPath = flag.String("kubelet-csi-plugins-path", `C:\var\lib\kubelet\plugins`, "Absolute path of the Kubelet plugin directory in the host file system") | ||
kubeletPodPath = flag.String("kubelet-pod-path", `C:\var\lib\kubelet\pods`, "Absolute path of the kubelet pod directory in the host file system") | ||
) | ||
|
||
func main() { | ||
s := server.NewServer(apiGroups()...) | ||
flag.Parse() | ||
apiGroups, err := apiGroups() | ||
if err != nil { | ||
panic(err) | ||
} | ||
s := server.NewServer(apiGroups...) | ||
if err := s.Start(nil); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// apiGroups returns the list of enabled API groups. | ||
func apiGroups() []server.APIGroup { | ||
return []server.APIGroup{ | ||
&filesystem.Server{}, | ||
func apiGroups() ([]srvtypes.APIGroup, error) { | ||
fssrv, err := filesystemsrv.NewServer(*kubeletCSIPluginsPath, *kubeletPodPath, filesystemapi.New()) | ||
if err != nil { | ||
return []srvtypes.APIGroup{}, err | ||
} | ||
return []srvtypes.APIGroup{ | ||
fssrv, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package filesystem | ||
|
||
import ( | ||
// "fmt" | ||
"os" | ||
// "os/exec" | ||
// "runtime" | ||
) | ||
|
||
// Implements the Filesystem OS API calls. All code here should be very simple | ||
// pass-through to the OS APIs. Any logic around the APIs should go in | ||
// internal/server/filesystem/server.go so that logic can be easily unit-tested | ||
// without requiring specific OS environments. | ||
|
||
type APIImplementor struct{} | ||
|
||
func New() APIImplementor { | ||
return APIImplementor{} | ||
} | ||
|
||
func (APIImplementor) PathExists(path string) (bool, error) { | ||
_, err := os.Stat(path) | ||
if err == nil { | ||
return true, nil | ||
} | ||
if os.IsNotExist(err) { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
|
||
func (APIImplementor) Mkdir(path string) error { | ||
return os.MkdirAll(path, 0755) | ||
} | ||
|
||
func (APIImplementor) Rmdir(path string, force bool) error { | ||
if force { | ||
return os.RemoveAll(path) | ||
} | ||
return os.Remove(path) | ||
} | ||
|
||
func (APIImplementor) LinkPath(tgt string, src string) error { | ||
return os.Symlink(tgt, src) | ||
} |
Oops, something went wrong.