mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-02 21:58:43 +00:00
Use int64 for IDs in woodpecker client lib (#2703)
Switch from int to int64 for IDs
This commit is contained in:
parent
c75068920c
commit
dbed835b6d
13 changed files with 36 additions and 35 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"`
|
||||
|
|
Loading…
Reference in a new issue