Skip to content

Commit 371876e

Browse files
committed
chore(volumes): modify volumes:client cmd annotation and can not cp dir
1 parent 5cf9d52 commit 371876e

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

cmd/volumes.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ func (d *DryccCmd) volumesClientCp(appID, src, dst string) error {
291291
if err != nil {
292292
return err
293293
}
294+
if urlpath == "" || urlpath == "/" {
295+
return fmt.Errorf("path is a directory, not a file")
296+
}
294297
res, err := volumes.GetFile(s.Client, appID, name, urlpath)
295298
if err != nil {
296299
return err
@@ -302,7 +305,7 @@ func (d *DryccCmd) volumesClientCp(appID, src, dst string) error {
302305
dst = path.Join(dst, arrays[len(arrays)-1])
303306
}
304307
}
305-
w, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY, 0644)
308+
w, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
306309
if err != nil {
307310
return err
308311
}

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22
55
require (
66
github.com/containerd/console v1.0.4
77
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
8-
github.com/drycc/controller-sdk-go v0.0.0-20240710072101-82db20de8e4a
8+
github.com/drycc/controller-sdk-go v0.0.0-20240712012621-75bd5ebae3da
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f
1010
github.com/olekukonko/tablewriter v0.0.5
1111
github.com/stretchr/testify v1.9.0
@@ -21,5 +21,3 @@ require (
2121
github.com/pmezard/go-difflib v1.0.0 // indirect
2222
golang.org/x/sys v0.18.0 // indirect
2323
)
24-
25-
replace github.com/drycc/controller-sdk-go => github.com/jianxiaoguo/controller-sdk-go v0.0.0-20240711022759-a09abdeedfea

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
66
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
7+
github.com/drycc/controller-sdk-go v0.0.0-20240712012621-75bd5ebae3da h1:tNidQf7Aey4QTNC5oFHG8SAEwuXA74DZQjJYABKToVg=
8+
github.com/drycc/controller-sdk-go v0.0.0-20240712012621-75bd5ebae3da/go.mod h1:n6eQe1irJqjwLo/7t9+Dhdv6faSESQN+ATnZRBP3/Uc=
79
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f h1:kgjvUQJeAszDoU1Vo4vTTE92KI8Av3JPb6Qn890niXg=
810
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f/go.mod h1:n+QxGif6ha9CEoxVnlipxb9IdmerybcUSzTEDFkvjiA=
911
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
1012
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
11-
github.com/jianxiaoguo/controller-sdk-go v0.0.0-20240711022759-a09abdeedfea h1:okAAbWoGmFBtVwSl451+CHlhRl+sxXQ36wbnPLKMqN8=
12-
github.com/jianxiaoguo/controller-sdk-go v0.0.0-20240711022759-a09abdeedfea/go.mod h1:n6eQe1irJqjwLo/7t9+Dhdv6faSESQN+ATnZRBP3/Uc=
1313
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
1414
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
1515
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=

parser/volumes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ Arguments:
232232
cp copy volume files
233233
rm remove volume files
234234
<args>
235-
arguments for running commands
235+
arguments for running commands, when cmd is 'cp', args should be '[source] [dest]'.
236+
volume path format 'vol://volumename/', '/' is equivalent to the mount path.
236237
237238
Options:
238239
-a --app=<app>

0 commit comments

Comments
 (0)