mirror of
https://github.com/drone/drone-cli.git
synced 2024-11-23 01:11:57 +01:00
(dron-124) Add new command for build incomplete V2
This commit is contained in:
parent
f535034d07
commit
3ef2c9b7f0
@ -18,5 +18,6 @@ var Command = cli.Command{
|
|||||||
buildPromoteCmd,
|
buildPromoteCmd,
|
||||||
buildRollbackCmd,
|
buildRollbackCmd,
|
||||||
buildQueueCmd,
|
buildQueueCmd,
|
||||||
|
buildQueueV2Cmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
88
drone/build/build_queue_v2.go
Normal file
88
drone/build/build_queue_v2.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/drone/drone-cli/drone/internal"
|
||||||
|
"github.com/drone/funcmap"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
var buildQueueV2Cmd = cli.Command{
|
||||||
|
Name: "queue-v2",
|
||||||
|
Usage: "show build queue",
|
||||||
|
ArgsUsage: "",
|
||||||
|
Action: buildQueueV2,
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "format",
|
||||||
|
Usage: "format output",
|
||||||
|
Value: tmplQueueV2Status,
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "repo",
|
||||||
|
Usage: "repo filter",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildQueueV2(c *cli.Context) error {
|
||||||
|
client, err := internal.NewClient(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
instances, err := client.IncompleteV2()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format") + "\n")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
slug := c.String("repo")
|
||||||
|
|
||||||
|
for _, instance := range instances {
|
||||||
|
if slug != "" && instance.RepoSlug != slug {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
templateErr := tmpl.Execute(os.Stdout, instance)
|
||||||
|
if templateErr != nil {
|
||||||
|
return templateErr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// template for build queue v2 information
|
||||||
|
var tmplQueueV2Status = "\x1b[33m{{ .RepoSlug }}#{{ .BuildNumber }} \x1b[0m" + `
|
||||||
|
Repo Namespace: {{ .RepoNamespace }}
|
||||||
|
Repo Name: {{ .RepoName }}
|
||||||
|
Repo Slug: {{ .RepoSlug }}
|
||||||
|
Build Number: {{ .BuildNumber }}
|
||||||
|
Build Author: {{ .BuildAuthor }}
|
||||||
|
Build Author Name : {{ .BuildAuthorName }}
|
||||||
|
Build Author Email: {{ .BuildAuthorEmail }}
|
||||||
|
Build Author Avatar : {{ .BuildAuthorAvatar }}
|
||||||
|
Build Sender: {{ .BuildSender }}
|
||||||
|
Build Started: {{ .BuildStarted | time }}
|
||||||
|
Build Finished: {{ .BuildFinished | time}}
|
||||||
|
Build Created: {{ .BuildCreated | time}}
|
||||||
|
Build Updated: {{ .BuildUpdated | time }}
|
||||||
|
Stage Name: {{ .StageName }}
|
||||||
|
Stage Kind: {{ .StageKind }}
|
||||||
|
Stage Type: {{ .StageType }}
|
||||||
|
Stage Status: {{ .StageStatus }}
|
||||||
|
Stage Machine: {{ .StageMachine }}
|
||||||
|
Stage OS: {{ .StageOS }}
|
||||||
|
Stage Arch: {{ .StageArch }}
|
||||||
|
Stage Variant: {{ .StageVariant }}
|
||||||
|
Stage Kernel: {{ .StageKernel }}
|
||||||
|
Stage Limit: {{ .StageLimit }}
|
||||||
|
Stage Limit Repo: {{ .StageLimitRepo }}
|
||||||
|
Stage Started: {{ .StageStarted | time }}
|
||||||
|
Stage Stopped: {{ .StageStopped | time }}
|
||||||
|
`
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ replace github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.2
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/docker/go-units v0.3.3
|
github.com/docker/go-units v0.3.3
|
||||||
github.com/drone/drone-go v1.6.2
|
github.com/drone/drone-go v1.7.0
|
||||||
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
|
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
|
||||||
github.com/drone/drone-yaml v0.0.0-20190729072335-70fa398b3560
|
github.com/drone/drone-yaml v0.0.0-20190729072335-70fa398b3560
|
||||||
github.com/drone/envsubst v1.0.3
|
github.com/drone/envsubst v1.0.3
|
||||||
|
4
go.sum
4
go.sum
@ -33,8 +33,8 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF
|
|||||||
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
|
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
|
||||||
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
|
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
|
||||||
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
github.com/drone/drone-go v1.6.2 h1:QT7o6Bfe5UCUea4ZU74JfzgkwFYbBNduuSQZTr1fQJE=
|
github.com/drone/drone-go v1.7.0 h1:oEFWVcagBmAkVuFBpBq9lImZX1caDM+zRsmC4O1vXgQ=
|
||||||
github.com/drone/drone-go v1.6.2/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
|
github.com/drone/drone-go v1.7.0/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
|
||||||
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
|
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
|
||||||
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
|
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
|
||||||
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
|
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
|
||||||
|
Loading…
Reference in New Issue
Block a user