mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-19 14:05:31 +00:00
Refactor cli (#329)
- move cli files from `cli/drone` to `cli/` - move cli main to `cmd/cli/main.go` to match agent and server - use version from `version/version.go` to match agent and server
This commit is contained in:
parent
ac46ee9345
commit
188b9e6eb5
51 changed files with 69 additions and 124 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -33,7 +33,7 @@ docker-compose.yml
|
|||
/.env
|
||||
extras/
|
||||
release/
|
||||
build/
|
||||
/build/
|
||||
cli/release/
|
||||
|
||||
server/swagger/files/*.json
|
||||
|
|
20
Makefile
20
Makefile
|
@ -74,17 +74,17 @@ release-cli:
|
|||
# disable CGO for cross-compiling
|
||||
export CGO_ENABLED=0
|
||||
# compile for all architectures
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
|
||||
GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/arm64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
|
||||
GOOS=linux GOARCH=arm go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/linux/arm/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/windows/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=${DRONE_TAG##v}" -o cli/release/darwin/amd64/woodpecker github.com/woodpecker-ci/woodpecker/cli/drone
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o cli/release/linux/amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
||||
GOOS=linux GOARCH=arm64 go build -ldflags '${LDFLAGS}' -o cli/release/linux/arm64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
||||
GOOS=linux GOARCH=arm go build -ldflags '${LDFLAGS}' -o cli/release/linux/arm/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
||||
GOOS=windows GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o cli/release/windows/amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags '${LDFLAGS}' -o cli/release/darwin/amd64/woodpecker-cli github.com/woodpecker-ci/woodpecker/cmd/cli
|
||||
# tar binary files prior to upload
|
||||
tar -cvzf cli/release/woodpecker_linux_amd64.tar.gz -C cli/release/linux/amd64 woodpecker
|
||||
tar -cvzf cli/release/woodpecker_linux_arm64.tar.gz -C cli/release/linux/arm64 woodpecker
|
||||
tar -cvzf cli/release/woodpecker_linux_arm.tar.gz -C cli/release/linux/arm woodpecker
|
||||
tar -cvzf cli/release/woodpecker_windows_amd64.tar.gz -C cli/release/windows/amd64 woodpecker
|
||||
tar -cvzf cli/release/woodpecker_darwin_amd64.tar.gz -C cli/release/darwin/amd64 woodpecker
|
||||
tar -cvzf cli/release/woodpecker_linux_amd64.tar.gz -C cli/release/linux/amd64 woodpecker-cli
|
||||
tar -cvzf cli/release/woodpecker_linux_arm64.tar.gz -C cli/release/linux/arm64 woodpecker-cli
|
||||
tar -cvzf cli/release/woodpecker_linux_arm.tar.gz -C cli/release/linux/arm woodpecker-cli
|
||||
tar -cvzf cli/release/woodpecker_windows_amd64.tar.gz -C cli/release/windows/amd64 woodpecker-cli
|
||||
tar -cvzf cli/release/woodpecker_darwin_amd64.tar.gz -C cli/release/darwin/amd64 woodpecker-cli
|
||||
# generate shas for tar files
|
||||
sha256sum cli/release/*.tar.gz > cli/release/woodpecker_checksums.txt
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
workspace:
|
||||
base: /go
|
||||
path: src/github.com/drone/drone-cli
|
||||
|
||||
pipeline:
|
||||
build:
|
||||
image: golang:1.9
|
||||
commands: sh .drone.sh
|
||||
|
||||
publish_latest:
|
||||
image: plugins/docker
|
||||
repo: drone/cli
|
||||
secrets: [docker_username, docker_password]
|
||||
auto_tag: true
|
||||
when:
|
||||
event: [push, tag]
|
||||
|
||||
publish_alpine:
|
||||
image: plugins/docker
|
||||
repo: drone/cli
|
||||
secrets: [docker_username, docker_password]
|
||||
auto_tag: true
|
||||
auto_tag_suffix: alpine
|
||||
dockerfile: Dockerfile.alpine
|
||||
when:
|
||||
event: [push, tag]
|
||||
|
||||
publish_linux_arm:
|
||||
image: plugins/docker
|
||||
repo: drone/cli
|
||||
secrets: [docker_username, docker_password]
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
dockerfile: Dockerfile.linux.arm
|
||||
when:
|
||||
event: [push, tag]
|
||||
|
||||
publish_linux_arm64:
|
||||
image: plugins/docker
|
||||
repo: drone/cli
|
||||
secrets: [docker_username, docker_password]
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
dockerfile: Dockerfile.linux.arm64
|
||||
when:
|
||||
event: [push, tag]
|
||||
|
||||
release:
|
||||
image: plugins/github-release
|
||||
files:
|
||||
- release/woodpecker_*.tar.gz
|
||||
- release/woodpecker_checksums.txt
|
||||
secrets:
|
||||
- source: github_token
|
||||
target: github_release_api_key
|
||||
when:
|
||||
event: tag
|
|
@ -1 +1,5 @@
|
|||
Command line client for the Drone continuous integration server. Please see the official documentation at http://docs.drone.io/cli-installation/
|
||||
# Woodpecker CLI
|
||||
|
||||
Command line client for the Woodpecker continuous integration server.
|
||||
|
||||
Please see the official documentation at https://woodpecker-ci.github.io/docs/cli
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildApproveCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildDeclineCmd = cli.Command{
|
|
@ -6,7 +6,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildInfoCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildKillCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildLastCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildListCmd = cli.Command{
|
|
@ -6,7 +6,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildPsCmd = cli.Command{
|
|
@ -6,7 +6,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildQueueCmd = cli.Command{
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildStartCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var buildStopCmd = cli.Command{
|
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/urfave/cli"
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
// Command exports the info command.
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var logPurgeCmd = cli.Command{
|
|
@ -4,7 +4,7 @@ import (
|
|||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/urfave/cli"
|
|
@ -4,7 +4,7 @@ import (
|
|||
"html/template"
|
||||
"os"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var registryListCmd = cli.Command{
|
|
@ -1,7 +1,7 @@
|
|||
package registry
|
||||
|
||||
import (
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
|
@ -4,7 +4,7 @@ import (
|
|||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/urfave/cli"
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var repoAddCmd = cli.Command{
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var repoChownCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var repoInfoCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var repoListCmd = cli.Command{
|
|
@ -2,7 +2,7 @@ package repo
|
|||
|
||||
import (
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var repoRepairCmd = cli.Command{
|
|
@ -3,7 +3,7 @@ package repo
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
|
@ -5,7 +5,7 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var repoSyncCmd = cli.Command{
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/urfave/cli"
|
|
@ -4,7 +4,7 @@ import (
|
|||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/urfave/cli"
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var secretInfoCmd = cli.Command{
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var secretListCmd = cli.Command{
|
|
@ -3,7 +3,7 @@ package secret
|
|||
import (
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var secretDeleteCmd = cli.Command{
|
|
@ -4,7 +4,7 @@ import (
|
|||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/urfave/cli"
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/urfave/cli"
|
||||
"github.com/woodpecker-ci/woodpecker/drone-go/drone"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var userAddCmd = cli.Command{
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var userInfoCmd = cli.Command{
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var userListCmd = cli.Command{
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/internal"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/internal"
|
||||
)
|
||||
|
||||
var userRemoveCmd = cli.Command{
|
|
@ -4,57 +4,55 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/build"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/deploy"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/exec"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/info"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/log"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/registry"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/repo"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/secret"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/drone/user"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/build"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/deploy"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/exec"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/info"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/log"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/registry"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/repo"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/secret"
|
||||
"github.com/woodpecker-ci/woodpecker/cli/user"
|
||||
"github.com/woodpecker-ci/woodpecker/version"
|
||||
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
// drone version number
|
||||
var version string
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "drone"
|
||||
app.Version = version
|
||||
app.Name = "woodpecker-cli"
|
||||
app.Version = version.String()
|
||||
app.Usage = "command line utility"
|
||||
app.EnableBashCompletion = true
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
EnvVar: "DRONE_TOKEN,WOODPECKER_TOKEN",
|
||||
Name: "t, token",
|
||||
Usage: "server auth token",
|
||||
EnvVar: "DRONE_TOKEN,WOODPECKER_TOKEN",
|
||||
},
|
||||
|
||||
cli.StringFlag{
|
||||
EnvVar: "DRONE_SERVER,WOODPECKER_SERVER",
|
||||
Name: "s, server",
|
||||
Usage: "server address",
|
||||
EnvVar: "DRONE_SERVER,WOODPECKER_SERVER",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-verify",
|
||||
Usage: "skip ssl verfification",
|
||||
EnvVar: "DRONE_SKIP_VERIFY,WOODPECKER_SKIP_VERIFY",
|
||||
Name: "skip-verify",
|
||||
Usage: "skip ssl verification",
|
||||
Hidden: true,
|
||||
},
|
||||
cli.StringFlag{
|
||||
EnvVar: "SOCKS_PROXY",
|
||||
Name: "socks-proxy",
|
||||
Usage: "socks proxy address",
|
||||
EnvVar: "SOCKS_PROXY",
|
||||
Hidden: true,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
EnvVar: "SOCKS_PROXY_OFF",
|
||||
Name: "socks-proxy-off",
|
||||
Usage: "socks proxy ignored",
|
||||
EnvVar: "SOCKS_PROXY_OFF",
|
||||
Hidden: true,
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue