-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* commiting to switch * basics working * remove added flag * added in wrong ui * change back go version * reset build * update gazelle and run Close() on file * gazelle * fix recursive test from enkit //... * changes for PR, renaming to be cleaner * add in rename to fusepb * net.JoinHostPort * separate types * change package name * rename interfaces * remove allowother in test
- Loading branch information
Showing
17 changed files
with
747 additions
and
4 deletions.
There are no files selected for viewing
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
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
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,36 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"client.go", | ||
"config.go", | ||
"files.go", | ||
"server.go", | ||
], | ||
importpath = "github.com/enfabrica/enkit/proxy/enfuse", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//proxy/enfuse/rpc:go_default_library", | ||
"@org_bazil_fuse//:go_default_library", | ||
"@org_bazil_fuse//fs:go_default_library", | ||
"@org_golang_google_grpc//:go_default_library", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = ["e2e_test.go"], | ||
tags = [ | ||
"no-sandbox", | ||
], | ||
deps = [ | ||
":go_default_library", | ||
"//lib/knetwork:go_default_library", | ||
"//lib/srand:go_default_library", | ||
"//proxy/enfuse/rpc:go_default_library", | ||
"@com_github_stretchr_testify//assert:go_default_library", | ||
"@org_bazil_fuse//fs/fstestutil:go_default_library", | ||
"@org_golang_google_grpc//:go_default_library", | ||
], | ||
) |
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,41 @@ | ||
package enfuse | ||
|
||
import ( | ||
"bazil.org/fuse" | ||
"bazil.org/fuse/fs" | ||
fusepb "github.com/enfabrica/enkit/proxy/enfuse/rpc" | ||
"google.golang.org/grpc" | ||
"net" | ||
"strconv" | ||
) | ||
|
||
var ( | ||
_ fs.FS = &FuseClient{} | ||
) | ||
|
||
func NewClient(config *ConnectConfig) (*FuseClient, error) { | ||
conn, err := grpc.Dial(net.JoinHostPort(config.Url, strconv.Itoa(config.Port)), grpc.WithInsecure()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &FuseClient{fusepb.NewFuseControllerClient(conn)}, nil | ||
} | ||
|
||
func MountDirectory(mountPath string, client *FuseClient) error { | ||
c, err := fuse.Mount( | ||
mountPath, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
srv := fs.New(c, nil) | ||
return srv.Serve(client) | ||
} | ||
|
||
type FuseClient struct { | ||
ConnClient fusepb.FuseControllerClient | ||
} | ||
|
||
func (f *FuseClient) Root() (fs.Node, error) { | ||
return &Dir{Dir: "", Client: f.ConnClient}, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package enfuse | ||
|
||
import ( | ||
"net" | ||
) | ||
|
||
type ConnectConfig struct { | ||
Port int | ||
Url string | ||
L net.Listener | ||
} | ||
|
||
type ConnectMod func(c *ConnectConfig) | ||
|
||
var ( | ||
WithPort = func(p int) ConnectMod { | ||
return func(c *ConnectConfig) { | ||
c.Port = p | ||
} | ||
} | ||
WithInterface = func(u string) ConnectMod { | ||
return func(c *ConnectConfig) { | ||
c.Url = u | ||
} | ||
} | ||
WithListener = func(l net.Listener) ConnectMod { | ||
return func(c *ConnectConfig) { | ||
c.L = l | ||
} | ||
} | ||
WithConnectConfig = func(c1 *ConnectConfig) ConnectMod { | ||
return func(c *ConnectConfig) { | ||
*c = *c1 | ||
} | ||
} | ||
) | ||
|
||
type ( | ||
ServerConfig struct { | ||
*ConnectConfig | ||
Dir string | ||
} | ||
ServerConfigMod = func(sc *ServerConfig) | ||
) | ||
|
||
var ( | ||
WithConnectMods = func(c ...ConnectMod) ServerConfigMod { | ||
return func(sc *ServerConfig) { | ||
for _, m := range c { | ||
m(sc.ConnectConfig) | ||
} | ||
} | ||
} | ||
WithDir = func(d string) ServerConfigMod { | ||
return func(sc *ServerConfig) { | ||
sc.Dir = d | ||
} | ||
} | ||
) | ||
|
||
func NewServerConfig(mods ...ServerConfigMod) *ServerConfig { | ||
sc := &ServerConfig{ | ||
ConnectConfig: &ConnectConfig{}, | ||
} | ||
for _, m := range mods { | ||
m(sc) | ||
} | ||
return sc | ||
} |
Oops, something went wrong.