Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use int64 for IDs in woodpecker client lib #2703

Merged
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
4 changes: 2 additions & 2 deletions cli/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/log/log_purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pipeline/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pipeline/decline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cli/pipeline/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pipeline/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cli/pipeline/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cli/pipeline/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cli/pipeline/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pipeline/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions woodpecker-go/woodpecker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
}

// 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) {

Check warning on line 219 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L219

Added line #L219 was not covered by tests
out := new(Pipeline)
uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline)
err := c.get(uri, out)
Expand Down Expand Up @@ -259,7 +259,7 @@
}

// 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) {

Check warning on line 262 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L262

Added line #L262 was not covered by tests
out := new(Pipeline)
val := mapValues(params)
uri := fmt.Sprintf(pathPipeline, c.addr, repoID, pipeline)
Expand All @@ -268,37 +268,37 @@
}

// PipelineStop cancels the running step.
func (c *client) PipelineStop(repoID int64, pipeline int) error {
func (c *client) PipelineStop(repoID, pipeline int64) error {

Check warning on line 271 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L271

Added line #L271 was not covered by tests
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) {

Check warning on line 278 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L278

Added line #L278 was not covered by tests
out := new(Pipeline)
uri := fmt.Sprintf(pathApprove, c.addr, repoID, pipeline)
err := c.post(uri, nil, out)
return out, err
}

// PipelineDecline declines a blocked pipeline.
func (c *client) PipelineDecline(repoID int64, pipeline int) (*Pipeline, error) {
func (c *client) PipelineDecline(repoID, pipeline int64) (*Pipeline, error) {

Check warning on line 286 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L286

Added line #L286 was not covered by tests
out := new(Pipeline)
uri := fmt.Sprintf(pathDecline, c.addr, repoID, pipeline)
err := c.post(uri, nil, out)
return out, err
}

// PipelineKill force kills the running pipeline.
func (c *client) PipelineKill(repoID int64, pipeline int) error {
func (c *client) PipelineKill(repoID, pipeline int64) error {

Check warning on line 294 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L294

Added line #L294 was not covered by tests
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) {

Check warning on line 301 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L301

Added line #L301 was not covered by tests
uri := fmt.Sprintf(pathLogs, c.addr, repoID, num, step)
var out []*LogEntry
err := c.get(uri, &out)
Expand All @@ -307,7 +307,7 @@

// 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) {

Check warning on line 310 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L310

Added line #L310 was not covered by tests
out := new(Pipeline)
val := mapValues(params)
val.Set("event", EventDeploy)
Expand All @@ -318,7 +318,7 @@
}

// 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 {

Check warning on line 321 in woodpecker-go/woodpecker/client.go

View check run for this annotation

Codecov / codecov/patch

woodpecker-go/woodpecker/client.go#L321

Added line #L321 was not covered by tests
uri := fmt.Sprintf(pathLogPurge, c.addr, repoID, pipeline)
err := c.delete(uri)
return err
Expand Down
18 changes: 9 additions & 9 deletions woodpecker-go/woodpecker/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions woodpecker-go/woodpecker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down