Skip to content

Commit 236bf2a

Browse files
committed
feat(ps): add pod logs support
1 parent 1c06300 commit 236bf2a

7 files changed

Lines changed: 15 additions & 9 deletions

File tree

cmd/apps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (d *DryccCmd) AppLogs(appID string, lines int, follow bool, timeout int) er
237237
}
238238

239239
// AppRun runs a one time command in the app.
240-
func (d *DryccCmd) AppRun(appID, command string, volumeVars []string) error {
240+
func (d *DryccCmd) AppRun(appID, command string, volumeVars []string, timeout, expires uint32) error {
241241
s, appID, err := load(d.ConfigFile, appID)
242242

243243
if err != nil {
@@ -250,7 +250,7 @@ func (d *DryccCmd) AppRun(appID, command string, volumeVars []string) error {
250250
return err
251251
}
252252

253-
if err := apps.Run(s.Client, appID, command, volumeMap); d.checkAPICompatibility(s.Client, err) != nil {
253+
if err := apps.Run(s.Client, appID, command, volumeMap, timeout, expires); d.checkAPICompatibility(s.Client, err) != nil {
254254
return err
255255
}
256256
return nil

cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Commander interface {
1414
AppInfo(string) error
1515
AppOpen(string) error
1616
AppLogs(string, int, bool, int) error
17-
AppRun(string, string, []string) error
17+
AppRun(string, string, []string, uint32, uint32) error
1818
AppDestroy(string, string) error
1919
AppTransfer(string, string) error
2020
AutoscaleList(string) error

go.mod

Lines changed: 1 addition & 1 deletion
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-20240301062701-f528b91c1759
8+
github.com/drycc/controller-sdk-go v0.0.0-20240304053455-0352ebbb02dc
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f
1010
github.com/olekukonko/tablewriter v0.0.5
1111
github.com/stretchr/testify v1.8.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ 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-20240301062701-f528b91c1759 h1:yBhvNVINJ+FSwZupsik4QzJR/DXPiJ8SvUFrZ/89ISA=
8-
github.com/drycc/controller-sdk-go v0.0.0-20240301062701-f528b91c1759/go.mod h1:EAzlvB5kQq4pFP+h+zl0mx2q1GUlHgzdQ92tlYtDQfQ=
7+
github.com/drycc/controller-sdk-go v0.0.0-20240304053455-0352ebbb02dc h1:tRMSrNX3qFzQsfVhij1pO2pwHIWTdSvCbrAcsX+wwrQ=
8+
github.com/drycc/controller-sdk-go v0.0.0-20240304053455-0352ebbb02dc/go.mod h1:EAzlvB5kQq4pFP+h+zl0mx2q1GUlHgzdQ92tlYtDQfQ=
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f h1:kgjvUQJeAszDoU1Vo4vTTE92KI8Av3JPb6Qn890niXg=
1010
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f/go.mod h1:n+QxGif6ha9CEoxVnlipxb9IdmerybcUSzTEDFkvjiA=
1111
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=

parser/apps.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ Arguments:
213213
Options:
214214
-a --app=<app>
215215
the uniquely identifiable name for the application.
216+
--timeout=<timeout>
217+
the timeout for command run, default to 3600 seconds.
218+
--expires=<expires>
219+
retention time of running records, default to 3600 seconds.
216220
`
217221

218222
args, err := docopt.ParseArgs(usage, argv, "")
@@ -222,9 +226,11 @@ Options:
222226
}
223227

224228
app := safeGetString(args, "--app")
229+
timeout := uint32(safeGetInt(args, "--timeout"))
230+
expires := uint32(safeGetInt(args, "--expires"))
225231
command := strings.Join(args["<command>"].([]string), " ")
226232
mounts := args["--mount"].([]string)
227-
return cmdr.AppRun(app, command, mounts)
233+
return cmdr.AppRun(app, command, mounts, timeout, expires)
228234
}
229235

230236
func appDestroy(argv []string, cmdr cmd.Commander) error {

parser/apps_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (d FakeDryccCmd) AppLogs(string, int, bool, int) error {
3232
return errors.New("apps:logs")
3333
}
3434

35-
func (d FakeDryccCmd) AppRun(string, string, []string) error {
35+
func (d FakeDryccCmd) AppRun(string, string, []string, uint32, uint32) error {
3636
return errors.New("apps:run")
3737
}
3838

parser/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Options:
8585
app := safeGetString(args, "--app")
8686
vType := safeGetValue(args, "--type", "csi")
8787
name := safeGetString(args, "<name>")
88-
size := safeGetValue(args, "<size>", "0G")
88+
size := safeGetString(args, "<size>")
8989
parameters := map[string]interface{}{}
9090
if vType == "nfs" {
9191
server := safeGetString(args, "--nfs-server")

0 commit comments

Comments
 (0)