mirror of
https://github.com/drone/drone-cli.git
synced 2024-05-04 06:36:02 +02:00
Merge pull request #167 from tboerger/build-create
Integrate build create command
This commit is contained in:
commit
c17fb6b80e
|
@ -10,6 +10,7 @@ var Command = cli.Command{
|
|||
buildListCmd,
|
||||
buildLastCmd,
|
||||
buildInfoCmd,
|
||||
buildCreateCmd,
|
||||
buildStopCmd,
|
||||
buildStartCmd,
|
||||
buildApproveCmd,
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package build
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone-cli/drone/internal"
|
||||
"github.com/drone/funcmap"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var buildCreateCmd = cli.Command{
|
||||
Name: "create",
|
||||
Usage: "create a build",
|
||||
ArgsUsage: "<repo/name>",
|
||||
Action: buildCreate,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "commit",
|
||||
Usage: "source commit",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "branch",
|
||||
Usage: "source branch",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "format",
|
||||
Usage: "format output",
|
||||
Value: tmplBuildInfo,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func buildCreate(c *cli.Context) (err error) {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
build, err := client.BuildCreate(owner, name, c.String("commit"), c.String("branch"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmpl, err := template.New("_").Funcs(funcmap.Funcs).Parse(c.String("format"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tmpl.Execute(os.Stdout, build)
|
||||
}
|
2
go.mod
2
go.mod
|
@ -11,7 +11,7 @@ require (
|
|||
github.com/docker/distribution v2.7.1+incompatible
|
||||
github.com/docker/go-connections v0.3.0
|
||||
github.com/docker/go-units v0.3.3
|
||||
github.com/drone/drone-go v1.0.7-0.20191002153459-173e210cf8d6
|
||||
github.com/drone/drone-go v1.3.0
|
||||
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8
|
||||
github.com/drone/drone-yaml v0.0.0-20190729072335-70fa398b3560
|
||||
github.com/drone/envsubst v1.0.1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -27,6 +27,10 @@ github.com/drone/drone-go v1.0.7-0.20190918192642-21c14e63f89a h1:GgG6EpzcAx9Gav
|
|||
github.com/drone/drone-go v1.0.7-0.20190918192642-21c14e63f89a/go.mod h1:GxyeGClYohaKNYJv/ZpsmVHtMJ7WhoT+uDaJNcDIrk4=
|
||||
github.com/drone/drone-go v1.0.7-0.20191002153459-173e210cf8d6 h1:qwBSqbhs6hLMsqALZ/CUEqZawlK1Sui4Bn1nNTJfDHY=
|
||||
github.com/drone/drone-go v1.0.7-0.20191002153459-173e210cf8d6/go.mod h1:GxyeGClYohaKNYJv/ZpsmVHtMJ7WhoT+uDaJNcDIrk4=
|
||||
github.com/drone/drone-go v1.2.0 h1:Gnp79mJHf4Q5Kwkw2nIRQcj7ZAA/kqKNEz5dJ3n/0Uk=
|
||||
github.com/drone/drone-go v1.2.0/go.mod h1:GxyeGClYohaKNYJv/ZpsmVHtMJ7WhoT+uDaJNcDIrk4=
|
||||
github.com/drone/drone-go v1.3.0 h1:eIk79qCiw+hzmDFYSofZKrR7E0tPs7Vm13kKH80n0zs=
|
||||
github.com/drone/drone-go v1.3.0/go.mod h1:GxyeGClYohaKNYJv/ZpsmVHtMJ7WhoT+uDaJNcDIrk4=
|
||||
github.com/drone/drone-runtime v0.0.0-20190729082142-807d0aeaa221/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
|
||||
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8 h1:lcS2z7+ZySmVM+XJJjBZZPTcn6IB1BSfLWtDGyco3xo=
|
||||
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
|
||||
|
|
Loading…
Reference in New Issue