From 5da5dd26a16ce0aa8e87ba79ecb3f6ae3aec8423 Mon Sep 17 00:00:00 2001 From: Rune Philosof Date: Thu, 2 Nov 2023 08:53:36 +0100 Subject: [PATCH] Woodpecker-go: Pipeline.ID and Step.ID are int64 --- cli/deploy/deploy.go | 4 ++-- cli/log/log_purge.go | 2 +- cli/pipeline/approve.go | 2 +- cli/pipeline/decline.go | 2 +- cli/pipeline/info.go | 4 ++-- cli/pipeline/kill.go | 2 +- cli/pipeline/logs.go | 4 ++-- cli/pipeline/ps.go | 4 ++-- cli/pipeline/start.go | 4 ++-- cli/pipeline/stop.go | 2 +- woodpecker-go/woodpecker/client.go | 18 +++++++++--------- woodpecker-go/woodpecker/interface.go | 18 +++++++++--------- woodpecker-go/woodpecker/types.go | 5 +++-- 13 files changed, 36 insertions(+), 35 deletions(-) diff --git a/cli/deploy/deploy.go b/cli/deploy/deploy.go index 109b81ecec..ce293b8dea 100644 --- a/cli/deploy/deploy.go +++ b/cli/deploy/deploy.go @@ -75,7 +75,7 @@ func deploy(c *cli.Context) error { status := c.String("status") pipelineArg := c.Args().Get(1) - var number int + var number int64 if pipelineArg == "last" { // Fetch the pipeline number from the last pipeline pipelines, berr := client.PipelineList(repoID) @@ -100,7 +100,7 @@ func deploy(c *cli.Context) error { return fmt.Errorf("Cannot deploy failure pipeline") } } else { - number, err = strconv.Atoi(pipelineArg) + number, err = strconv.ParseInt(pipelineArg, 10, 64) if err != nil { return err } diff --git a/cli/log/log_purge.go b/cli/log/log_purge.go index 851833acc8..fb3f58886e 100644 --- a/cli/log/log_purge.go +++ b/cli/log/log_purge.go @@ -42,7 +42,7 @@ func logPurge(c *cli.Context) (err error) { if err != nil { return err } - number, err := strconv.Atoi(c.Args().Get(1)) + number, err := strconv.ParseInt(c.Args().Get(1), 10, 64) if err != nil { return err } diff --git a/cli/pipeline/approve.go b/cli/pipeline/approve.go index 57ec1c05e7..f4bb4b0f86 100644 --- a/cli/pipeline/approve.go +++ b/cli/pipeline/approve.go @@ -42,7 +42,7 @@ func pipelineApprove(c *cli.Context) (err error) { if err != nil { return err } - number, err := strconv.Atoi(c.Args().Get(1)) + number, err := strconv.ParseInt(c.Args().Get(1), 10, 64) if err != nil { return err } diff --git a/cli/pipeline/decline.go b/cli/pipeline/decline.go index b1fdd9c017..54a114f239 100644 --- a/cli/pipeline/decline.go +++ b/cli/pipeline/decline.go @@ -43,7 +43,7 @@ func pipelineDecline(c *cli.Context) (err error) { return err } - number, err := strconv.Atoi(c.Args().Get(1)) + number, err := strconv.ParseInt(c.Args().Get(1), 10, 64) if err != nil { return err } diff --git a/cli/pipeline/info.go b/cli/pipeline/info.go index 43594747cb..2acd2eb225 100644 --- a/cli/pipeline/info.go +++ b/cli/pipeline/info.go @@ -47,7 +47,7 @@ func pipelineInfo(c *cli.Context) error { } pipelineArg := c.Args().Get(1) - var number int + var number int64 if pipelineArg == "last" || len(pipelineArg) == 0 { // Fetch the pipeline number from the last pipeline pipeline, err := client.PipelineLast(repoID, "") @@ -56,7 +56,7 @@ func pipelineInfo(c *cli.Context) error { } number = pipeline.Number } else { - number, err = strconv.Atoi(pipelineArg) + number, err = strconv.ParseInt(pipelineArg, 10, 64) if err != nil { return err } diff --git a/cli/pipeline/kill.go b/cli/pipeline/kill.go index a732f2086b..961c5bee07 100644 --- a/cli/pipeline/kill.go +++ b/cli/pipeline/kill.go @@ -34,7 +34,7 @@ var pipelineKillCmd = &cli.Command{ } func pipelineKill(c *cli.Context) (err error) { - number, err := strconv.Atoi(c.Args().Get(1)) + number, err := strconv.ParseInt(c.Args().Get(1), 10, 64) if err != nil { return err } diff --git a/cli/pipeline/logs.go b/cli/pipeline/logs.go index 2da28a6a43..e2a5cd43c9 100644 --- a/cli/pipeline/logs.go +++ b/cli/pipeline/logs.go @@ -43,12 +43,12 @@ func pipelineLogs(c *cli.Context) error { return err } - number, err := strconv.Atoi(c.Args().Get(1)) + number, err := strconv.ParseInt(c.Args().Get(1), 10, 64) if err != nil { return err } - step, err := strconv.Atoi(c.Args().Get(2)) + step, err := strconv.ParseInt(c.Args().Get(2), 10, 64) if err != nil { return err } diff --git a/cli/pipeline/ps.go b/cli/pipeline/ps.go index d161b7a9fc..a8bcecb61a 100644 --- a/cli/pipeline/ps.go +++ b/cli/pipeline/ps.go @@ -47,7 +47,7 @@ func pipelinePs(c *cli.Context) error { } pipelineArg := c.Args().Get(1) - var number int + var number int64 if pipelineArg == "last" || len(pipelineArg) == 0 { // Fetch the pipeline number from the last pipeline @@ -58,7 +58,7 @@ func pipelinePs(c *cli.Context) error { number = pipeline.Number } else { - number, err = strconv.Atoi(pipelineArg) + number, err = strconv.ParseInt(pipelineArg, 10, 64) if err != nil { return err } diff --git a/cli/pipeline/start.go b/cli/pipeline/start.go index d4eee4fd61..cc48c42a12 100644 --- a/cli/pipeline/start.go +++ b/cli/pipeline/start.go @@ -51,7 +51,7 @@ func pipelineStart(c *cli.Context) (err error) { } pipelineArg := c.Args().Get(1) - var number int + var number int64 if pipelineArg == "last" { // Fetch the pipeline number from the last pipeline pipeline, err := client.PipelineLast(repoID, "") @@ -63,7 +63,7 @@ func pipelineStart(c *cli.Context) (err error) { if len(pipelineArg) == 0 { return errors.New("missing step number") } - number, err = strconv.Atoi(pipelineArg) + number, err = strconv.ParseInt(pipelineArg, 10, 64) if err != nil { return err } diff --git a/cli/pipeline/stop.go b/cli/pipeline/stop.go index 55a4d8cea1..8f321361ea 100644 --- a/cli/pipeline/stop.go +++ b/cli/pipeline/stop.go @@ -42,7 +42,7 @@ func pipelineStop(c *cli.Context) (err error) { if err != nil { return err } - number, err := strconv.Atoi(c.Args().Get(1)) + number, err := strconv.ParseInt(c.Args().Get(1), 10, 64) if err != nil { return err } diff --git a/woodpecker-go/woodpecker/client.go b/woodpecker-go/woodpecker/client.go index 8b6408d752..133df11b8c 100644 --- a/woodpecker-go/woodpecker/client.go +++ b/woodpecker-go/woodpecker/client.go @@ -216,7 +216,7 @@ func (c *client) RepoMove(repoID int64, newFullName string) error { } // Pipeline returns a repository pipeline by pipeline-id. -func (c *client) Pipeline(repoID int64, pipeline int) (*Pipeline, error) { +func (c *client) Pipeline(repoID, pipeline int64) (*Pipeline, error) { out := new(Pipeline) uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline) err := c.get(uri, out) @@ -259,7 +259,7 @@ func (c *client) PipelineQueue() ([]*Feed, error) { } // PipelineStart re-starts a stopped pipeline. -func (c *client) PipelineStart(repoID int64, pipeline int, params map[string]string) (*Pipeline, error) { +func (c *client) PipelineStart(repoID, pipeline int64, params map[string]string) (*Pipeline, error) { out := new(Pipeline) val := mapValues(params) uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline) @@ -268,14 +268,14 @@ func (c *client) PipelineStart(repoID int64, pipeline int, params map[string]str } // PipelineStop cancels the running step. -func (c *client) PipelineStop(repoID int64, pipeline int) error { +func (c *client) PipelineStop(repoID, pipeline int64) error { uri := fmt.Sprintf(pathStop, c.addr, repoID, pipeline) err := c.post(uri, nil, nil) return err } // PipelineApprove approves a blocked pipeline. -func (c *client) PipelineApprove(repoID int64, pipeline int) (*Pipeline, error) { +func (c *client) PipelineApprove(repoID, pipeline int64) (*Pipeline, error) { out := new(Pipeline) uri := fmt.Sprintf(pathApprove, c.addr, repoID, pipeline) err := c.post(uri, nil, out) @@ -283,7 +283,7 @@ func (c *client) PipelineApprove(repoID int64, pipeline int) (*Pipeline, error) } // PipelineDecline declines a blocked pipeline. -func (c *client) PipelineDecline(repoID int64, pipeline int) (*Pipeline, error) { +func (c *client) PipelineDecline(repoID, pipeline int64) (*Pipeline, error) { out := new(Pipeline) uri := fmt.Sprintf(pathDecline, c.addr, repoID, pipeline) err := c.post(uri, nil, out) @@ -291,14 +291,14 @@ func (c *client) PipelineDecline(repoID int64, pipeline int) (*Pipeline, error) } // PipelineKill force kills the running pipeline. -func (c *client) PipelineKill(repoID int64, pipeline int) error { +func (c *client) PipelineKill(repoID, pipeline int64) error { uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline) err := c.delete(uri) return err } // PipelineLogs returns the pipeline logs for the specified step. -func (c *client) StepLogEntries(repoID int64, num, step int) ([]*LogEntry, error) { +func (c *client) StepLogEntries(repoID, num, step int64) ([]*LogEntry, error) { uri := fmt.Sprintf(pathLogs, c.addr, repoID, num, step) var out []*LogEntry err := c.get(uri, &out) @@ -307,7 +307,7 @@ func (c *client) StepLogEntries(repoID int64, num, step int) ([]*LogEntry, error // Deploy triggers a deployment for an existing pipeline using the // specified target environment. -func (c *client) Deploy(repoID int64, pipeline int, env string, params map[string]string) (*Pipeline, error) { +func (c *client) Deploy(repoID, pipeline int64, env string, params map[string]string) (*Pipeline, error) { out := new(Pipeline) val := mapValues(params) val.Set("event", EventDeploy) @@ -318,7 +318,7 @@ func (c *client) Deploy(repoID int64, pipeline int, env string, params map[strin } // LogsPurge purges the pipeline logs for the specified pipeline. -func (c *client) LogsPurge(repoID int64, pipeline int) error { +func (c *client) LogsPurge(repoID, pipeline int64) error { uri := fmt.Sprintf(pathLogPurge, c.addr, repoID, pipeline) err := c.delete(uri) return err diff --git a/woodpecker-go/woodpecker/interface.go b/woodpecker-go/woodpecker/interface.go index f15e74f81a..f82c1e68e7 100644 --- a/woodpecker-go/woodpecker/interface.go +++ b/woodpecker-go/woodpecker/interface.go @@ -77,7 +77,7 @@ type Client interface { RepoDel(repoID int64) error // Pipeline returns a repository pipeline by number. - Pipeline(repoID int64, pipeline int) (*Pipeline, error) + Pipeline(repoID, pipeline int64) (*Pipeline, error) // PipelineLast returns the latest repository pipeline by branch. An empty branch // will result in the default branch. @@ -94,29 +94,29 @@ type Client interface { PipelineCreate(repoID int64, opts *PipelineOptions) (*Pipeline, error) // PipelineStart re-starts a stopped pipeline. - PipelineStart(repoID int64, num int, params map[string]string) (*Pipeline, error) + PipelineStart(repoID, num int64, params map[string]string) (*Pipeline, error) // PipelineStop stops the given pipeline. - PipelineStop(repoID int64, pipeline int) error + PipelineStop(repoID, pipeline int64) error // PipelineApprove approves a blocked pipeline. - PipelineApprove(repoID int64, pipeline int) (*Pipeline, error) + PipelineApprove(repoID, pipeline int64) (*Pipeline, error) // PipelineDecline declines a blocked pipeline. - PipelineDecline(repoID int64, pipeline int) (*Pipeline, error) + PipelineDecline(repoID, pipeline int64) (*Pipeline, error) // PipelineKill force kills the running pipeline. - PipelineKill(repoID int64, pipeline int) error + PipelineKill(repoID, pipeline int64) error // StepLogEntries returns the LogEntries for the given pipeline step - StepLogEntries(repoID int64, pipeline, stepID int) ([]*LogEntry, error) + StepLogEntries(repoID, pipeline, stepID int64) ([]*LogEntry, error) // Deploy triggers a deployment for an existing pipeline using the specified // target environment. - Deploy(repoID int64, pipeline int, env string, params map[string]string) (*Pipeline, error) + Deploy(repoID, pipeline int64, env string, params map[string]string) (*Pipeline, error) // LogsPurge purges the pipeline logs for the specified pipeline. - LogsPurge(repoID int64, pipeline int) error + LogsPurge(repoID, pipeline int64) error // Registry returns a registry by hostname. Registry(repoID int64, hostname string) (*Registry, error) diff --git a/woodpecker-go/woodpecker/types.go b/woodpecker-go/woodpecker/types.go index 2dde96dcd8..538ba3affc 100644 --- a/woodpecker-go/woodpecker/types.go +++ b/woodpecker-go/woodpecker/types.go @@ -63,13 +63,14 @@ type ( // Pipeline defines a pipeline object. Pipeline struct { ID int64 `json:"id"` - Number int `json:"number"` - Parent int `json:"parent"` + Number int64 `json:"number"` + Parent int64 `json:"parent"` Event string `json:"event"` Status string `json:"status"` Error string `json:"error"` Enqueued int64 `json:"enqueued_at"` Created int64 `json:"created_at"` + Updated int64 `json:"updated_at"` Started int64 `json:"started_at"` Finished int64 `json:"finished_at"` Deploy string `json:"deploy_to"`