Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion action/log/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ func (c *Config) Get(client *vela.Client) error {

logrus.Tracef("capturing logs for build %s/%s/%d", c.Org, c.Repo, c.Build)

// set the pagination options for list of build logs
//
// https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#ListOptions
opts := &vela.ListOptions{
Page: c.Page,
PerPage: c.PerPage,
}

// send API call to capture a list of build logs
//
// https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#BuildService.GetLogs
logs, _, err := client.Build.GetLogs(c.Org, c.Repo, c.Build)
logs, _, err := client.Build.GetLogs(c.Org, c.Repo, c.Build, opts)
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions action/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ type Config struct {
Build int
Service int
Step int
Page int
PerPage int
Output string
}
29 changes: 24 additions & 5 deletions command/log/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ var CommandGet = &cli.Command{
Aliases: []string{"op"},
Usage: "format the output in json, spew or yaml",
},

// Pagination Flags

&cli.IntFlag{
EnvVars: []string{"VELA_PAGE", "LOG_PAGE"},
Name: internal.FlagPage,
Aliases: []string{"p"},
Usage: "print a specific page of build logs",
Value: 1,
},
&cli.IntFlag{
EnvVars: []string{"VELA_PER_PAGE", "LOG_PER_PAGE"},
Name: internal.FlagPerPage,
Aliases: []string{"pp"},
Usage: "number of build logs to print per page",
Value: 100, // server defaults to 10
},
},
CustomHelpTemplate: fmt.Sprintf(`%s
EXAMPLES:
Expand Down Expand Up @@ -96,11 +113,13 @@ func get(c *cli.Context) error {
//
// https://pkg.go.dev/github.com/go-vela/cli/action/log?tab=doc#Config
l := &log.Config{
Action: internal.ActionGet,
Org: c.String(internal.FlagOrg),
Repo: c.String(internal.FlagRepo),
Build: c.Int(internal.FlagBuild),
Output: c.String(internal.FlagOutput),
Action: internal.ActionGet,
Org: c.String(internal.FlagOrg),
Repo: c.String(internal.FlagRepo),
Build: c.Int(internal.FlagBuild),
Page: c.Int(internal.FlagPage),
PerPage: c.Int(internal.FlagPerPage),
Output: c.String(internal.FlagOutput),
}

// validate log configuration
Expand Down