mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 06:08:42 +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")
|
status := c.String("status")
|
||||||
|
|
||||||
pipelineArg := c.Args().Get(1)
|
pipelineArg := c.Args().Get(1)
|
||||||
var number int
|
var number int64
|
||||||
if pipelineArg == "last" {
|
if pipelineArg == "last" {
|
||||||
// Fetch the pipeline number from the last pipeline
|
// Fetch the pipeline number from the last pipeline
|
||||||
pipelines, berr := client.PipelineList(repoID)
|
pipelines, berr := client.PipelineList(repoID)
|
||||||
|
@ -100,7 +100,7 @@ func deploy(c *cli.Context) error {
|
||||||
return fmt.Errorf("Cannot deploy failure pipeline")
|
return fmt.Errorf("Cannot deploy failure pipeline")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
number, err = strconv.Atoi(pipelineArg)
|
number, err = strconv.ParseInt(pipelineArg, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ func logPurge(c *cli.Context) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
number, err := strconv.Atoi(c.Args().Get(1))
|
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ func pipelineApprove(c *cli.Context) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
number, err := strconv.Atoi(c.Args().Get(1))
|
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func pipelineDecline(c *cli.Context) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
number, err := strconv.Atoi(c.Args().Get(1))
|
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func pipelineInfo(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
pipelineArg := c.Args().Get(1)
|
pipelineArg := c.Args().Get(1)
|
||||||
|
|
||||||
var number int
|
var number int64
|
||||||
if pipelineArg == "last" || len(pipelineArg) == 0 {
|
if pipelineArg == "last" || len(pipelineArg) == 0 {
|
||||||
// Fetch the pipeline number from the last pipeline
|
// Fetch the pipeline number from the last pipeline
|
||||||
pipeline, err := client.PipelineLast(repoID, "")
|
pipeline, err := client.PipelineLast(repoID, "")
|
||||||
|
@ -56,7 +56,7 @@ func pipelineInfo(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
number = pipeline.Number
|
number = pipeline.Number
|
||||||
} else {
|
} else {
|
||||||
number, err = strconv.Atoi(pipelineArg)
|
number, err = strconv.ParseInt(pipelineArg, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ var pipelineKillCmd = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineKill(c *cli.Context) (err error) {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,12 @@ func pipelineLogs(c *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
number, err := strconv.Atoi(c.Args().Get(1))
|
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
step, err := strconv.Atoi(c.Args().Get(2))
|
step, err := strconv.ParseInt(c.Args().Get(2), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func pipelinePs(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
pipelineArg := c.Args().Get(1)
|
pipelineArg := c.Args().Get(1)
|
||||||
var number int
|
var number int64
|
||||||
|
|
||||||
if pipelineArg == "last" || len(pipelineArg) == 0 {
|
if pipelineArg == "last" || len(pipelineArg) == 0 {
|
||||||
// Fetch the pipeline number from the last pipeline
|
// Fetch the pipeline number from the last pipeline
|
||||||
|
@ -58,7 +58,7 @@ func pipelinePs(c *cli.Context) error {
|
||||||
|
|
||||||
number = pipeline.Number
|
number = pipeline.Number
|
||||||
} else {
|
} else {
|
||||||
number, err = strconv.Atoi(pipelineArg)
|
number, err = strconv.ParseInt(pipelineArg, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func pipelineStart(c *cli.Context) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pipelineArg := c.Args().Get(1)
|
pipelineArg := c.Args().Get(1)
|
||||||
var number int
|
var number int64
|
||||||
if pipelineArg == "last" {
|
if pipelineArg == "last" {
|
||||||
// Fetch the pipeline number from the last pipeline
|
// Fetch the pipeline number from the last pipeline
|
||||||
pipeline, err := client.PipelineLast(repoID, "")
|
pipeline, err := client.PipelineLast(repoID, "")
|
||||||
|
@ -63,7 +63,7 @@ func pipelineStart(c *cli.Context) (err error) {
|
||||||
if len(pipelineArg) == 0 {
|
if len(pipelineArg) == 0 {
|
||||||
return errors.New("missing step number")
|
return errors.New("missing step number")
|
||||||
}
|
}
|
||||||
number, err = strconv.Atoi(pipelineArg)
|
number, err = strconv.ParseInt(pipelineArg, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ func pipelineStop(c *cli.Context) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
number, err := strconv.Atoi(c.Args().Get(1))
|
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ func (c *client) RepoMove(repoID int64, newFullName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pipeline returns a repository pipeline by pipeline-id.
|
// 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)
|
out := new(Pipeline)
|
||||||
uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline)
|
uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline)
|
||||||
err := c.get(uri, out)
|
err := c.get(uri, out)
|
||||||
|
@ -259,7 +259,7 @@ func (c *client) PipelineQueue() ([]*Feed, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PipelineStart re-starts a stopped pipeline.
|
// 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)
|
out := new(Pipeline)
|
||||||
val := mapValues(params)
|
val := mapValues(params)
|
||||||
uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline)
|
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.
|
// 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)
|
uri := fmt.Sprintf(pathStop, c.addr, repoID, pipeline)
|
||||||
err := c.post(uri, nil, nil)
|
err := c.post(uri, nil, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// PipelineApprove approves a blocked pipeline.
|
// 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)
|
out := new(Pipeline)
|
||||||
uri := fmt.Sprintf(pathApprove, c.addr, repoID, pipeline)
|
uri := fmt.Sprintf(pathApprove, c.addr, repoID, pipeline)
|
||||||
err := c.post(uri, nil, out)
|
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.
|
// 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)
|
out := new(Pipeline)
|
||||||
uri := fmt.Sprintf(pathDecline, c.addr, repoID, pipeline)
|
uri := fmt.Sprintf(pathDecline, c.addr, repoID, pipeline)
|
||||||
err := c.post(uri, nil, out)
|
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.
|
// 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)
|
uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline)
|
||||||
err := c.delete(uri)
|
err := c.delete(uri)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// PipelineLogs returns the pipeline logs for the specified step.
|
// 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)
|
uri := fmt.Sprintf(pathLogs, c.addr, repoID, num, step)
|
||||||
var out []*LogEntry
|
var out []*LogEntry
|
||||||
err := c.get(uri, &out)
|
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
|
// Deploy triggers a deployment for an existing pipeline using the
|
||||||
// specified target environment.
|
// 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)
|
out := new(Pipeline)
|
||||||
val := mapValues(params)
|
val := mapValues(params)
|
||||||
val.Set("event", EventDeploy)
|
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.
|
// 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)
|
uri := fmt.Sprintf(pathLogPurge, c.addr, repoID, pipeline)
|
||||||
err := c.delete(uri)
|
err := c.delete(uri)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -77,7 +77,7 @@ type Client interface {
|
||||||
RepoDel(repoID int64) error
|
RepoDel(repoID int64) error
|
||||||
|
|
||||||
// Pipeline returns a repository pipeline by number.
|
// 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
|
// PipelineLast returns the latest repository pipeline by branch. An empty branch
|
||||||
// will result in the default branch.
|
// will result in the default branch.
|
||||||
|
@ -94,29 +94,29 @@ type Client interface {
|
||||||
PipelineCreate(repoID int64, opts *PipelineOptions) (*Pipeline, error)
|
PipelineCreate(repoID int64, opts *PipelineOptions) (*Pipeline, error)
|
||||||
|
|
||||||
// PipelineStart re-starts a stopped pipeline.
|
// 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 stops the given pipeline.
|
||||||
PipelineStop(repoID int64, pipeline int) error
|
PipelineStop(repoID, pipeline int64) error
|
||||||
|
|
||||||
// PipelineApprove approves a blocked pipeline.
|
// PipelineApprove approves a blocked pipeline.
|
||||||
PipelineApprove(repoID int64, pipeline int) (*Pipeline, error)
|
PipelineApprove(repoID, pipeline int64) (*Pipeline, error)
|
||||||
|
|
||||||
// PipelineDecline declines a blocked pipeline.
|
// 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 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 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
|
// Deploy triggers a deployment for an existing pipeline using the specified
|
||||||
// target environment.
|
// 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 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 returns a registry by hostname.
|
||||||
Registry(repoID int64, hostname string) (*Registry, error)
|
Registry(repoID int64, hostname string) (*Registry, error)
|
||||||
|
|
|
@ -63,13 +63,14 @@ type (
|
||||||
// Pipeline defines a pipeline object.
|
// Pipeline defines a pipeline object.
|
||||||
Pipeline struct {
|
Pipeline struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Number int `json:"number"`
|
Number int64 `json:"number"`
|
||||||
Parent int `json:"parent"`
|
Parent int64 `json:"parent"`
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Error string `json:"error"`
|
Error string `json:"error"`
|
||||||
Enqueued int64 `json:"enqueued_at"`
|
Enqueued int64 `json:"enqueued_at"`
|
||||||
Created int64 `json:"created_at"`
|
Created int64 `json:"created_at"`
|
||||||
|
Updated int64 `json:"updated_at"`
|
||||||
Started int64 `json:"started_at"`
|
Started int64 `json:"started_at"`
|
||||||
Finished int64 `json:"finished_at"`
|
Finished int64 `json:"finished_at"`
|
||||||
Deploy string `json:"deploy_to"`
|
Deploy string `json:"deploy_to"`
|
||||||
|
|
Loading…
Reference in a new issue