1
0
mirror of https://github.com/drone/drone-cli.git synced 2026-01-20 09:51:34 +01:00

Merge pull request #83 from tonglil/log-purge-command

Log purge command
This commit is contained in:
Brad Rydzewski 2018-03-12 14:28:11 -07:00 committed by GitHub
commit 94a96d9041
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 1 deletions

2
Gopkg.lock generated

@ -216,6 +216,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "adf49f8b501fa5d3ee778c63607482e72d073343bf7171e180d8bec26138da91"
inputs-digest = "c010f0b5f991b258398c74a8a181b3b69b97c61690a2baeaad764b0c9da0a86c"
solver-name = "gps-cdcl"
solver-version = 1

12
drone/log/log.go Normal file

@ -0,0 +1,12 @@
package log
import "github.com/urfave/cli"
// Command exports the build command set.
var Command = cli.Command{
Name: "log",
Usage: "manage logs",
Subcommands: []cli.Command{
logPurgeCmd,
},
}

41
drone/log/log_purge.go Normal file

@ -0,0 +1,41 @@
package log
import (
"fmt"
"strconv"
"github.com/drone/drone-cli/drone/internal"
"github.com/urfave/cli"
)
var logPurgeCmd = cli.Command{
Name: "purge",
Usage: "purge a log",
ArgsUsage: "<repo/name> <build>",
Action: logPurge,
}
func logPurge(c *cli.Context) (err error) {
repo := c.Args().First()
owner, name, err := internal.ParseRepo(repo)
if err != nil {
return err
}
number, err := strconv.Atoi(c.Args().Get(1))
if err != nil {
return err
}
client, err := internal.NewClient(c)
if err != nil {
return err
}
err = client.LogsPurge(owner, name, number)
if err != nil {
return err
}
fmt.Printf("Purging logs for build %s/%s#%d\n", owner, name, number)
return nil
}

@ -9,6 +9,7 @@ import (
"github.com/drone/drone-cli/drone/deploy"
"github.com/drone/drone-cli/drone/exec"
"github.com/drone/drone-cli/drone/info"
"github.com/drone/drone-cli/drone/log"
"github.com/drone/drone-cli/drone/registry"
"github.com/drone/drone-cli/drone/repo"
"github.com/drone/drone-cli/drone/secret"
@ -66,6 +67,7 @@ func main() {
}
app.Commands = []cli.Command{
build.Command,
log.Command,
deploy.Command,
exec.Command,
info.Command,