Skip to content

Commit cc535b1

Browse files
committed
chore(volumes): add endpoint for serve
1 parent 079d76b commit cc535b1

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

volumes/volumes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ func Expand(c *drycc.Client, appID string, volume api.Volume) (api.Volume, error
8282

8383
// Serve serves an app's volume.
8484
func Serve(parent context.Context, c *drycc.Client, appID, name string) (context.Context, map[string]string, error) {
85-
u := fmt.Sprintf("/v2/apps/%s/volumes/%s/filer/_/bind", appID, name)
86-
res, err := c.Request("POST", u, nil)
85+
basePath := fmt.Sprintf("/v2/apps/%s/volumes/%s/filer", appID, name)
86+
res, err := c.Request("POST", fmt.Sprintf("%s/_/bind", basePath), nil)
8787
if err != nil {
8888
return nil, nil, err
8989
}
@@ -100,8 +100,7 @@ func Serve(parent context.Context, c *drycc.Client, appID, name string) (context
100100
case <-parent.Done():
101101
return
102102
default:
103-
u := fmt.Sprintf("/v2/apps/%s/volumes/%s/filer/_/ping", appID, name)
104-
res, err := c.Request("GET", u, nil)
103+
res, err := c.Request("GET", fmt.Sprintf("%s/_/ping", basePath), nil)
105104
if err != nil {
106105
return
107106
}
@@ -112,6 +111,7 @@ func Serve(parent context.Context, c *drycc.Client, appID, name string) (context
112111
}
113112
}
114113
}()
114+
filer["endpoint"] = fmt.Sprintf("%s%s/webdav/", c.ControllerURL, basePath)
115115
return ctx, filer, nil
116116
}
117117

volumes/volumes_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ const volumeUnmountFixture string = `
118118
`
119119

120120
const (
121-
volumeMountExpected string = `{"path":{"cmd":"/data/cmd1","web":"/data/web1"}}`
122-
volumeUnmountExpected string = `{"path":{"cmd":null,"web":null}}`
123-
volumeFileContentExpected string = `test file content`
121+
volumeMountExpected string = `{"path":{"cmd":"/data/cmd1","web":"/data/web1"}}`
122+
volumeUnmountExpected string = `{"path":{"cmd":null,"web":null}}`
124123
)
125124

126125
type fakeHTTPServer struct{}
@@ -231,7 +230,7 @@ func (f *fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
231230
if req.URL.Path == "/v2/apps/example-go/volumes/myvolume/filer/_/bind" && req.Method == "POST" {
232231
res.Header().Add("Content-Type", "application/json")
233232
res.WriteHeader(http.StatusOK)
234-
res.Write([]byte(`{"host":"localhost","port":"8080"}`))
233+
res.Write([]byte(`{"username":"user","password":"pass"}`))
235234
return
236235
}
237236

@@ -505,8 +504,9 @@ func TestVolumeServe(t *testing.T) {
505504
}
506505

507506
expectedFiler := map[string]string{
508-
"host": "localhost",
509-
"port": "8080",
507+
"endpoint": fmt.Sprintf("%s/v2/apps/example-go/volumes/myvolume/filer/webdav/", server.URL),
508+
"username": "user",
509+
"password": "pass",
510510
}
511511

512512
parentCtx, cancel := context.WithCancel(context.Background())

0 commit comments

Comments
 (0)