Merge branch 'origin/main' into 'next-release/main'

This commit is contained in:
oauth 2024-11-30 09:30:18 +00:00
commit 727e4df8e1
4 changed files with 12 additions and 11 deletions

View file

@ -23,6 +23,7 @@ var Command = &cli.Command{
Name: "log", Name: "log",
Usage: "manage logs", Usage: "manage logs",
Commands: []*cli.Command{ Commands: []*cli.Command{
logShowCmd,
logPurgeCmd, logPurgeCmd,
}, },
} }

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package pipeline package log
import ( import (
"context" "context"
@ -27,14 +27,14 @@ import (
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker" "go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
) )
var pipelineLogsCmd = &cli.Command{ var logShowCmd = &cli.Command{
Name: "logs", Name: "show",
Usage: "show pipeline logs", Usage: "show pipeline logs",
ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-number|step-name]", ArgsUsage: "<repo-id|repo-full-name> <pipeline> [step-number|step-name]",
Action: pipelineLogs, Action: logShow,
} }
func pipelineLogs(ctx context.Context, c *cli.Command) error { func logShow(ctx context.Context, c *cli.Command) error {
repoIDOrFullName := c.Args().First() repoIDOrFullName := c.Args().First()
client, err := internal.NewClient(ctx, c) client, err := internal.NewClient(ctx, c)
if err != nil { if err != nil {
@ -59,17 +59,17 @@ func pipelineLogs(ctx context.Context, c *cli.Command) error {
stepArg := c.Args().Get(2) //nolint:mnd stepArg := c.Args().Get(2) //nolint:mnd
if len(stepArg) == 0 { if len(stepArg) == 0 {
return showPipelineLog(client, repoID, number) return pipelineLog(client, repoID, number)
} }
step, err := internal.ParseStep(client, repoID, number, stepArg) step, err := internal.ParseStep(client, repoID, number, stepArg)
if err != nil { if err != nil {
return fmt.Errorf("invalid step '%s': %w", stepArg, err) return fmt.Errorf("invalid step '%s': %w", stepArg, err)
} }
return showStepLog(client, repoID, number, step) return stepLog(client, repoID, number, step)
} }
func showPipelineLog(client woodpecker.Client, repoID, number int64) error { func pipelineLog(client woodpecker.Client, repoID, number int64) error {
pipeline, err := client.Pipeline(repoID, number) pipeline, err := client.Pipeline(repoID, number)
if err != nil { if err != nil {
return err return err
@ -85,7 +85,7 @@ func showPipelineLog(client woodpecker.Client, repoID, number int64) error {
if err := tmpl.Execute(os.Stdout, map[string]any{"workflow": workflow, "step": step}); err != nil { if err := tmpl.Execute(os.Stdout, map[string]any{"workflow": workflow, "step": step}); err != nil {
return err return err
} }
err := showStepLog(client, repoID, number, step.ID) err := stepLog(client, repoID, number, step.ID)
if err != nil { if err != nil {
return err return err
} }
@ -95,7 +95,7 @@ func showPipelineLog(client woodpecker.Client, repoID, number int64) error {
return nil return nil
} }
func showStepLog(client woodpecker.Client, repoID, number, step int64) error { func stepLog(client woodpecker.Client, repoID, number, step int64) error {
logs, err := client.StepLogEntries(repoID, number, step) logs, err := client.StepLogEntries(repoID, number, step)
if err != nil { if err != nil {
return err return err

View file

@ -35,7 +35,6 @@ var Command = &cli.Command{
Commands: []*cli.Command{ Commands: []*cli.Command{
buildPipelineListCmd(), buildPipelineListCmd(),
pipelineLastCmd, pipelineLastCmd,
pipelineLogsCmd,
pipelineInfoCmd, pipelineInfoCmd,
pipelineStopCmd, pipelineStopCmd,
pipelineStartCmd, pipelineStartCmd,

View file

@ -42,6 +42,7 @@ This will be the next version of Woodpecker.
- `woodpecker-cli log` is now `woodpecker-cli pipeline log` - `woodpecker-cli log` is now `woodpecker-cli pipeline log`
- `woodpecker-cli cron` is now `woodpecker-cli repo cron` - `woodpecker-cli cron` is now `woodpecker-cli repo cron`
- `woodpecker-cli secret [add|rm|...] --repository` is now `woodpecker-cli repo secret [add|rm|...]` - `woodpecker-cli secret [add|rm|...] --repository` is now `woodpecker-cli repo secret [add|rm|...]`
- `woodpecker-cli pipeline logs` is now `woodpecker-cli pipeline log show`
## Admin migrations ## Admin migrations