move commands to subfolders
This commit is contained in:
parent
cc530301fe
commit
45e67985a9
43 changed files with 220 additions and 146 deletions
|
@ -24,8 +24,8 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// AgentCmd is the exported command for starting the drone agent.
|
||||
var AgentCmd = cli.Command{
|
||||
// Command exports the agent command.
|
||||
var Command = cli.Command{
|
||||
Name: "agent",
|
||||
Usage: "starts the drone agent",
|
||||
Action: loop,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
|
||||
var buildCmd = cli.Command{
|
||||
// Command exports the build command set.
|
||||
var Command = cli.Command{
|
||||
Name: "build",
|
||||
Usage: "manage builds",
|
||||
Subcommands: []cli.Command{
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -15,7 +16,7 @@ var buildApproveCmd = cli.Command{
|
|||
|
||||
func buildApprove(c *cli.Context) (err error) {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -24,7 +25,7 @@ func buildApprove(c *cli.Context) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -15,7 +16,7 @@ var buildDeclineCmd = cli.Command{
|
|||
|
||||
func buildDecline(c *cli.Context) (err error) {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -24,7 +25,7 @@ func buildDecline(c *cli.Context) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -23,13 +24,13 @@ var buildInfoCmd = cli.Command{
|
|||
|
||||
func buildInfo(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
buildArg := c.Args().Get(1)
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -27,12 +28,12 @@ var buildLastCmd = cli.Command{
|
|||
|
||||
func buildLast(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -39,12 +40,12 @@ var buildListCmd = cli.Command{
|
|||
|
||||
func buildList(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/cncd/pipeline/pipeline/rpc"
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -21,12 +22,12 @@ func buildLogsDisabled(c *cli.Context) error {
|
|||
|
||||
func buildLogs(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -23,7 +24,7 @@ var buildQueueCmd = cli.Command{
|
|||
|
||||
func buildQueue(c *cli.Context) error {
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -26,12 +27,12 @@ var buildStartCmd = cli.Command{
|
|||
|
||||
func buildStart(c *cli.Context) (err error) {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -52,7 +53,7 @@ func buildStart(c *cli.Context) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
params := parseKVPairs(c.StringSlice("param"))
|
||||
params := internal.ParseKeyPair(c.StringSlice("param"))
|
||||
|
||||
var build *model.Build
|
||||
if c.Bool("fork") {
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -15,7 +16,7 @@ var buildStopCmd = cli.Command{
|
|||
|
||||
func buildStop(c *cli.Context) (err error) {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -28,7 +29,7 @@ func buildStop(c *cli.Context) (err error) {
|
|||
job = 1
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -6,11 +6,14 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var deployCmd = cli.Command{
|
||||
// Command exports the deploy command.
|
||||
var Command = cli.Command{
|
||||
Name: "deploy",
|
||||
Usage: "deploy code",
|
||||
Action: deploy,
|
||||
|
@ -44,12 +47,12 @@ var deployCmd = cli.Command{
|
|||
|
||||
func deploy(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -62,9 +65,9 @@ func deploy(c *cli.Context) error {
|
|||
var number int
|
||||
if buildArg == "last" {
|
||||
// Fetch the build number from the last build
|
||||
builds, err := client.BuildList(owner, name)
|
||||
if err != nil {
|
||||
return err
|
||||
builds, berr := client.BuildList(owner, name)
|
||||
if berr != nil {
|
||||
return berr
|
||||
}
|
||||
for _, build := range builds {
|
||||
if branch != "" && build.Branch != branch {
|
||||
|
@ -95,7 +98,7 @@ func deploy(c *cli.Context) error {
|
|||
return fmt.Errorf("Please specify the target environment (ie production)")
|
||||
}
|
||||
|
||||
params := parseKVPairs(c.StringSlice("param"))
|
||||
params := internal.ParseKeyPair(c.StringSlice("param"))
|
||||
|
||||
deploy, err := client.Deploy(owner, name, number, env, params)
|
||||
if err != nil {
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package exec
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -23,7 +23,8 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var execCmd = cli.Command{
|
||||
// Command exports the exec command.
|
||||
var Command = cli.Command{
|
||||
Name: "exec",
|
||||
Usage: "execute a local build",
|
||||
Action: func(c *cli.Context) {
|
|
@ -1,27 +1,31 @@
|
|||
package main
|
||||
package info
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var infoCmd = cli.Command{
|
||||
// Command exports the info command.
|
||||
var Command = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "show information about the current user",
|
||||
Action: info,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "format",
|
||||
Usage: "format output",
|
||||
Value: tmplUserInfo,
|
||||
Name: "format",
|
||||
Usage: "format output",
|
||||
Value: tmplInfo,
|
||||
Hidden: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func info(c *cli.Context) error {
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package internal
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
@ -13,7 +13,8 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func newClient(c *cli.Context) (client.Client, error) {
|
||||
// NewClient returns a new client from the CLI context.
|
||||
func NewClient(c *cli.Context) (client.Client, error) {
|
||||
var token = c.GlobalString("token")
|
||||
var server = strings.TrimRight(c.GlobalString("server"), "/")
|
||||
|
||||
|
@ -34,7 +35,8 @@ func newClient(c *cli.Context) (client.Client, error) {
|
|||
return client.NewClientTokenTLS(server, token, tlsConfig)
|
||||
}
|
||||
|
||||
func parseRepo(str string) (user, repo string, err error) {
|
||||
// ParseRepo parses the repository owner and name from a string.
|
||||
func ParseRepo(str string) (user, repo string, err error) {
|
||||
var parts = strings.Split(str, "/")
|
||||
if len(parts) != 2 {
|
||||
err = fmt.Errorf("Error: Invalid or missing repository. eg octocat/hello-world.")
|
||||
|
@ -62,7 +64,8 @@ func stringInSlice(a string, list []string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func parseKVPairs(p []string) map[string]string {
|
||||
// ParseKeyPair parses a key=value pair.
|
||||
func ParseKeyPair(p []string) map[string]string {
|
||||
params := map[string]string{}
|
||||
for _, i := range p {
|
||||
parts := strings.Split(i, "=")
|
|
@ -1,10 +1,10 @@
|
|||
package main
|
||||
package internal
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_parseKVPairs(t *testing.T) {
|
||||
func TestParseKeyPair(t *testing.T) {
|
||||
s := []string{"FOO=bar", "BAR=", "INVALID"}
|
||||
p := parseKVPairs(s)
|
||||
p := ParseKeyPair(s)
|
||||
if p["FOO"] != "bar" {
|
||||
t.Errorf("Wanted %q, got %q.", "bar", p["FOO"])
|
||||
}
|
|
@ -5,6 +5,15 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/drone/drone/drone/agent"
|
||||
"github.com/drone/drone/drone/build"
|
||||
"github.com/drone/drone/drone/deploy"
|
||||
"github.com/drone/drone/drone/exec"
|
||||
"github.com/drone/drone/drone/info"
|
||||
"github.com/drone/drone/drone/registry"
|
||||
"github.com/drone/drone/drone/repo"
|
||||
"github.com/drone/drone/drone/secret"
|
||||
"github.com/drone/drone/drone/server"
|
||||
"github.com/drone/drone/drone/user"
|
||||
"github.com/drone/drone/version"
|
||||
|
||||
"github.com/ianschenck/envflag"
|
||||
|
@ -32,16 +41,16 @@ func main() {
|
|||
},
|
||||
}
|
||||
app.Commands = []cli.Command{
|
||||
agent.AgentCmd,
|
||||
buildCmd,
|
||||
deployCmd,
|
||||
execCmd,
|
||||
infoCmd,
|
||||
registryCmd,
|
||||
secretCmd,
|
||||
serverCmd,
|
||||
repoCmd,
|
||||
userCmd,
|
||||
agent.Command,
|
||||
build.Command,
|
||||
deploy.Command,
|
||||
exec.Command,
|
||||
info.Command,
|
||||
registry.Command,
|
||||
secret.Command,
|
||||
server.Command,
|
||||
repo.Command,
|
||||
user.Command,
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package registry
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
|
||||
var registryCmd = cli.Command{
|
||||
// Command exports the registry command set.
|
||||
var Command = cli.Command{
|
||||
Name: "registry",
|
||||
Usage: "manage registries",
|
||||
Subcommands: []cli.Command{
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package registry
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -43,11 +45,11 @@ func registryCreate(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -58,9 +60,9 @@ func registryCreate(c *cli.Context) error {
|
|||
}
|
||||
if strings.HasPrefix(registry.Password, "@") {
|
||||
path := strings.TrimPrefix(registry.Password, "@")
|
||||
out, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
out, ferr := ioutil.ReadFile(path)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
registry.Password = string(out)
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package main
|
||||
package registry
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"os"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -39,11 +41,11 @@ func registryInfo(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package registry
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var registryListCmd = cli.Command{
|
||||
|
@ -33,11 +35,11 @@ func registryList(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
package main
|
||||
package registry
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
import (
|
||||
"github.com/drone/drone/drone/internal"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var registryDeleteCmd = cli.Command{
|
||||
Name: "rm",
|
||||
|
@ -27,11 +31,11 @@ func registryDelete(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package registry
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -43,11 +45,11 @@ func registryUpdate(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -58,9 +60,9 @@ func registryUpdate(c *cli.Context) error {
|
|||
}
|
||||
if strings.HasPrefix(registry.Password, "@") {
|
||||
path := strings.TrimPrefix(registry.Password, "@")
|
||||
out, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
out, ferr := ioutil.ReadFile(path)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
registry.Password = string(out)
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
|
||||
var repoCmd = cli.Command{
|
||||
// Command exports the repository command.
|
||||
var Command = cli.Command{
|
||||
Name: "repo",
|
||||
Usage: "manage repositories",
|
||||
Subcommands: []cli.Command{
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -14,12 +15,12 @@ var repoAddCmd = cli.Command{
|
|||
|
||||
func repoAdd(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -14,12 +15,12 @@ var repoChownCmd = cli.Command{
|
|||
|
||||
func repoChown(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -22,12 +23,12 @@ var repoInfoCmd = cli.Command{
|
|||
|
||||
func repoInfo(c *cli.Context) error {
|
||||
arg := c.Args().First()
|
||||
owner, name, err := parseRepo(arg)
|
||||
owner, name, err := internal.ParseRepo(arg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -25,7 +26,7 @@ var repoListCmd = cli.Command{
|
|||
}
|
||||
|
||||
func repoList(c *cli.Context) error {
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -12,11 +13,11 @@ var repoRepairCmd = cli.Command{
|
|||
|
||||
func repoRepair(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -14,12 +15,12 @@ var repoRemoveCmd = cli.Command{
|
|||
|
||||
func repoRemove(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package main
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
@ -34,12 +35,12 @@ var repoUpdateCmd = cli.Command{
|
|||
|
||||
func repoUpdate(c *cli.Context) error {
|
||||
repo := c.Args().First()
|
||||
owner, name, err := parseRepo(repo)
|
||||
owner, name, err := internal.ParseRepo(repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package secret
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
|
||||
var secretCmd = cli.Command{
|
||||
// Command exports the secret command.
|
||||
var Command = cli.Command{
|
||||
Name: "secret",
|
||||
Usage: "manage secrets",
|
||||
Subcommands: []cli.Command{
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package secret
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -41,11 +43,11 @@ func secretCreate(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -60,9 +62,9 @@ func secretCreate(c *cli.Context) error {
|
|||
}
|
||||
if strings.HasPrefix(secret.Value, "@") {
|
||||
path := strings.TrimPrefix(secret.Value, "@")
|
||||
out, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
out, ferr := ioutil.ReadFile(path)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
secret.Value = string(out)
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package secret
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var secretInfoCmd = cli.Command{
|
||||
|
@ -38,11 +40,11 @@ func secretInfo(c *cli.Context) error {
|
|||
if repoName == "" {
|
||||
repoName = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(repoName)
|
||||
owner, name, err := internal.ParseRepo(repoName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package secret
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
|
@ -6,6 +6,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var secretListCmd = cli.Command{
|
||||
|
@ -34,11 +36,11 @@ func secretList(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
package main
|
||||
package secret
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
import (
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var secretDeleteCmd = cli.Command{
|
||||
Name: "rm",
|
||||
|
@ -26,11 +30,11 @@ func secretDelete(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package secret
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
"github.com/drone/drone/model"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -41,11 +43,11 @@ func secretUpdate(c *cli.Context) error {
|
|||
if reponame == "" {
|
||||
reponame = c.Args().First()
|
||||
}
|
||||
owner, name, err := parseRepo(reponame)
|
||||
owner, name, err := internal.ParseRepo(reponame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -57,9 +59,9 @@ func secretUpdate(c *cli.Context) error {
|
|||
}
|
||||
if strings.HasPrefix(secret.Value, "@") {
|
||||
path := strings.TrimPrefix(secret.Value, "@")
|
||||
out, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
out, ferr := ioutil.ReadFile(path)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
secret.Value = string(out)
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
@ -12,7 +12,8 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var serverCmd = cli.Command{
|
||||
// Command exports the server command.
|
||||
var Command = cli.Command{
|
||||
Name: "server",
|
||||
Usage: "starts the drone server daemon",
|
||||
Action: server,
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
package user
|
||||
|
||||
import "github.com/urfave/cli"
|
||||
|
||||
var userCmd = cli.Command{
|
||||
// Command exports the user command set.
|
||||
var Command = cli.Command{
|
||||
Name: "user",
|
||||
Usage: "manage users",
|
||||
Subcommands: []cli.Command{
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/drone/drone/model"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var userAddCmd = cli.Command{
|
||||
|
@ -16,7 +18,7 @@ var userAddCmd = cli.Command{
|
|||
func userAdd(c *cli.Context) error {
|
||||
login := c.Args().First()
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -6,6 +6,8 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var userInfoCmd = cli.Command{
|
||||
|
@ -22,7 +24,7 @@ var userInfoCmd = cli.Command{
|
|||
}
|
||||
|
||||
func userInfo(c *cli.Context) error {
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
package user
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var userListCmd = cli.Command{
|
||||
|
@ -21,7 +23,7 @@ var userListCmd = cli.Command{
|
|||
}
|
||||
|
||||
func userList(c *cli.Context) error {
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package main
|
||||
package user
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/drone/drone/drone/internal"
|
||||
)
|
||||
|
||||
var userRemoveCmd = cli.Command{
|
||||
|
@ -15,7 +17,7 @@ var userRemoveCmd = cli.Command{
|
|||
func userRemove(c *cli.Context) error {
|
||||
login := c.Args().First()
|
||||
|
||||
client, err := newClient(c)
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
Loading…
Reference in a new issue