chore: upgrade dependencies and refine CLI configuration

- Update `github.com/stretchr/testify` from version `1.9.0` to `1.10.0`
- Update `github.com/urfave/cli` to version `v2.27.6` and change import path to include `/v2`
- Update `github.com/cpuguy83/go-md2man/v2` from version `2.0.4` to `2.0.5`
- Add `github.com/xrash/smetrics` as a new indirect dependency
- Change `cli.Author` to use a pointer type
- Update environment variable fields in multiple `cli.StringFlag` definitions to use `EnvVars` instead of `EnvVar`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2025-03-08 16:20:27 +08:00
parent 01518e5a92
commit 5e71b59c72
3 changed files with 170 additions and 174 deletions
+4 -3
View File
@@ -5,15 +5,15 @@ go 1.20
require (
github.com/appleboy/drone-template-lib v1.3.0
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.9.0
github.com/urfave/cli v1.22.15
github.com/stretchr/testify v1.10.0
github.com/urfave/cli/v2 v2.27.6
)
require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
@@ -26,6 +26,7 @@ require (
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/sys v0.21.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
+8 -13
View File
@@ -1,4 +1,3 @@
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
@@ -8,8 +7,8 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj
github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM=
github.com/appleboy/drone-template-lib v1.3.0 h1:aX36/1za3v8JsEyBeMY1Bp/VNRtZa8qPYkfkjBszW+A=
github.com/appleboy/drone-template-lib v1.3.0/go.mod h1:edlmXkFMKYAVypff8r2oN7aFlHfOZE5sLyPEnRHONeA=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -51,19 +50,15 @@ github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM=
github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g=
github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+158 -158
View File
@@ -7,7 +7,7 @@ import (
"time"
"github.com/joho/godotenv"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)
// Version set at compile-time
@@ -28,7 +28,7 @@ func main() {
app.Name = "Drone Discord"
app.Usage = "Sending message to Discord channel using Webhook"
app.Copyright = "Copyright (c) " + year + " Bo-Yi Wu"
app.Authors = []cli.Author{
app.Authors = []*cli.Author{
{
Name: "Bo-Yi Wu",
Email: "appleboy.tw@gmail.com",
@@ -37,199 +37,199 @@ func main() {
app.Action = run
app.Version = Version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "webhook-id",
Usage: "discord webhook id",
EnvVar: "PLUGIN_WEBHOOK_ID,WEBHOOK_ID,DISCORD_WEBHOOK_ID,INPUT_WEBHOOK_ID",
&cli.StringFlag{
Name: "webhook-id",
Usage: "discord webhook id",
EnvVars: []string{"PLUGIN_WEBHOOK_ID", "WEBHOOK_ID", "DISCORD_WEBHOOK_ID", "INPUT_WEBHOOK_ID"},
},
cli.StringFlag{
Name: "webhook-token",
Usage: "discord webhook token",
EnvVar: "PLUGIN_WEBHOOK_TOKEN,WEBHOOK_TOKEN,DISCORD_WEBHOOK_TOKEN,INPUT_WEBHOOK_TOKEN",
&cli.StringFlag{
Name: "webhook-token",
Usage: "discord webhook token",
EnvVars: []string{"PLUGIN_WEBHOOK_TOKEN", "WEBHOOK_TOKEN", "DISCORD_WEBHOOK_TOKEN", "INPUT_WEBHOOK_TOKEN"},
},
cli.StringSliceFlag{
Name: "message",
Usage: "the message contents (up to 2000 characters)",
EnvVar: "PLUGIN_MESSAGE,DISCORD_MESSAGE,MESSAGE,INPUT_MESSAGE",
&cli.StringSliceFlag{
Name: "message",
Usage: "the message contents (up to 2000 characters)",
EnvVars: []string{"PLUGIN_MESSAGE", "DISCORD_MESSAGE", "MESSAGE", "INPUT_MESSAGE"},
},
cli.StringSliceFlag{
Name: "file",
Usage: "the contents of the file being sent",
EnvVar: "PLUGIN_FILE,DISCORD_FILE,FILE,INPUT_FILE",
&cli.StringSliceFlag{
Name: "file",
Usage: "the contents of the file being sent",
EnvVars: []string{"PLUGIN_FILE", "DISCORD_FILE", "FILE", "INPUT_FILE"},
},
cli.StringFlag{
Name: "color",
Usage: "color code of the embed",
EnvVar: "PLUGIN_COLOR,COLOR,INPUT_COLOR",
&cli.StringFlag{
Name: "color",
Usage: "color code of the embed",
EnvVars: []string{"PLUGIN_COLOR", "COLOR", "INPUT_COLOR"},
},
cli.BoolFlag{
Name: "wait",
Usage: "waits for server confirmation of message send before response, and returns the created message body",
EnvVar: "PLUGIN_WAIT,WAIT,INPUT_WAIT",
&cli.BoolFlag{
Name: "wait",
Usage: "waits for server confirmation of message send before response, and returns the created message body",
EnvVars: []string{"PLUGIN_WAIT", "WAIT", "INPUT_WAIT"},
},
cli.BoolFlag{
Name: "tts",
Usage: "true if this is a TTS message",
EnvVar: "PLUGIN_TTS,TTS,INPUT_TTS",
&cli.BoolFlag{
Name: "tts",
Usage: "true if this is a TTS message",
EnvVars: []string{"PLUGIN_TTS", "TTS", "INPUT_TTS"},
},
cli.StringFlag{
Name: "username",
Usage: "override the default username of the webhook",
EnvVar: "PLUGIN_USERNAME,USERNAME,INPUT_USERNAME",
&cli.StringFlag{
Name: "username",
Usage: "override the default username of the webhook",
EnvVars: []string{"PLUGIN_USERNAME", "USERNAME", "INPUT_USERNAME"},
},
cli.StringFlag{
Name: "avatar-url",
Usage: "override the default avatar of the webhook",
EnvVar: "PLUGIN_AVATAR_URL,AVATAR_URL,INPUT_AVATAR_URL",
&cli.StringFlag{
Name: "avatar-url",
Usage: "override the default avatar of the webhook",
EnvVars: []string{"PLUGIN_AVATAR_URL", "AVATAR_URL", "INPUT_AVATAR_URL"},
},
cli.BoolFlag{
Name: "drone",
Usage: "environment is drone",
EnvVar: "DRONE",
&cli.BoolFlag{
Name: "drone",
Usage: "environment is drone",
EnvVars: []string{"DRONE"},
},
cli.StringFlag{
Name: "ci.environment",
Usage: "ci environment name",
EnvVar: "CI",
&cli.StringFlag{
Name: "ci.environment",
Usage: "ci environment name",
EnvVars: []string{"CI"},
},
cli.StringFlag{
Name: "repo",
Usage: "repository owner and repository name",
EnvVar: "DRONE_REPO,CI_REPO,GITHUB_REPOSITORY",
&cli.StringFlag{
Name: "repo",
Usage: "repository owner and repository name",
EnvVars: []string{"DRONE_REPO", "CI_REPO", "GITHUB_REPOSITORY"},
},
cli.StringFlag{
Name: "repo.namespace",
Usage: "repository namespace",
EnvVar: "DRONE_REPO_OWNER,DRONE_REPO_NAMESPACE,CI_REPO_OWNER,GITHUB_ACTOR",
&cli.StringFlag{
Name: "repo.namespace",
Usage: "repository namespace",
EnvVars: []string{"DRONE_REPO_OWNER", "DRONE_REPO_NAMESPACE", "CI_REPO_OWNER", "GITHUB_ACTOR"},
},
cli.StringFlag{
Name: "repo.name",
Usage: "repository name",
EnvVar: "DRONE_REPO_NAME,CI_REPO_NAME",
&cli.StringFlag{
Name: "repo.name",
Usage: "repository name",
EnvVars: []string{"DRONE_REPO_NAME", "CI_REPO_NAME"},
},
cli.StringFlag{
Name: "commit.sha",
Usage: "git commit sha",
EnvVar: "DRONE_COMMIT_SHA,CI_COMMIT_SHA,GITHUB_SHA",
&cli.StringFlag{
Name: "commit.sha",
Usage: "git commit sha",
EnvVars: []string{"DRONE_COMMIT_SHA", "CI_COMMIT_SHA", "GITHUB_SHA"},
},
cli.StringFlag{
Name: "commit.ref",
Usage: "git commit ref",
EnvVar: "DRONE_COMMIT_REF,CI_COMMIT_REF,GITHUB_REF",
&cli.StringFlag{
Name: "commit.ref",
Usage: "git commit ref",
EnvVars: []string{"DRONE_COMMIT_REF", "CI_COMMIT_REF", "GITHUB_REF"},
},
cli.StringFlag{
Name: "commit.branch",
Value: "master",
Usage: "git commit branch",
EnvVar: "DRONE_COMMIT_BRANCH,CI_COMMIT_BRANCH",
&cli.StringFlag{
Name: "commit.branch",
Value: "master",
Usage: "git commit branch",
EnvVars: []string{"DRONE_COMMIT_BRANCH", "CI_COMMIT_BRANCH"},
},
cli.StringFlag{
Name: "commit.link",
Usage: "git commit link",
EnvVar: "DRONE_COMMIT_LINK,CI_PIPELINE_FORGE_URL",
&cli.StringFlag{
Name: "commit.link",
Usage: "git commit link",
EnvVars: []string{"DRONE_COMMIT_LINK", "CI_PIPELINE_FORGE_URL"},
},
cli.StringFlag{
Name: "commit.author",
Usage: "git author name",
EnvVar: "DRONE_COMMIT_AUTHOR,CI_COMMIT_AUTHOR",
&cli.StringFlag{
Name: "commit.author",
Usage: "git author name",
EnvVars: []string{"DRONE_COMMIT_AUTHOR", "CI_COMMIT_AUTHOR"},
},
cli.StringFlag{
Name: "commit.author.email",
Usage: "git author email",
EnvVar: "DRONE_COMMIT_AUTHOR_EMAIL,CI_COMMIT_AUTHOR_EMAIL",
&cli.StringFlag{
Name: "commit.author.email",
Usage: "git author email",
EnvVars: []string{"DRONE_COMMIT_AUTHOR_EMAIL", "CI_COMMIT_AUTHOR_EMAIL"},
},
cli.StringFlag{
Name: "commit.author.avatar",
Usage: "git author avatar",
EnvVar: "DRONE_COMMIT_AUTHOR_AVATAR,CI_COMMIT_AUTHOR_AVATAR",
&cli.StringFlag{
Name: "commit.author.avatar",
Usage: "git author avatar",
EnvVars: []string{"DRONE_COMMIT_AUTHOR_AVATAR", "CI_COMMIT_AUTHOR_AVATAR"},
},
cli.StringFlag{
Name: "commit.message",
Usage: "commit message",
EnvVar: "DRONE_COMMIT_MESSAGE,CI_COMMIT_MESSAGE",
&cli.StringFlag{
Name: "commit.message",
Usage: "commit message",
EnvVars: []string{"DRONE_COMMIT_MESSAGE", "CI_COMMIT_MESSAGE"},
},
cli.StringFlag{
Name: "source.branch",
Value: "develop",
Usage: "git source branch",
EnvVar: "DRONE_SOURCE_BRANCH,CI_COMMIT_SOURCE_BRANCH",
&cli.StringFlag{
Name: "source.branch",
Value: "develop",
Usage: "git source branch",
EnvVars: []string{"DRONE_SOURCE_BRANCH", "CI_COMMIT_SOURCE_BRANCH"},
},
cli.StringFlag{
Name: "build.event",
Value: "push",
Usage: "build event",
EnvVar: "DRONE_BUILD_EVENT,CI_PIPELINE_EVENT",
&cli.StringFlag{
Name: "build.event",
Value: "push",
Usage: "build event",
EnvVars: []string{"DRONE_BUILD_EVENT", "CI_PIPELINE_EVENT"},
},
cli.IntFlag{
Name: "build.number",
Usage: "build number",
EnvVar: "DRONE_BUILD_NUMBER,CI_PIPELINE_NUMBER",
&cli.IntFlag{
Name: "build.number",
Usage: "build number",
EnvVars: []string{"DRONE_BUILD_NUMBER", "CI_PIPELINE_NUMBER"},
},
cli.StringFlag{
Name: "build.status",
Usage: "build status",
Value: "success",
EnvVar: "DRONE_BUILD_STATUS,CI_PIPELINE_STATUS",
&cli.StringFlag{
Name: "build.status",
Usage: "build status",
Value: "success",
EnvVars: []string{"DRONE_BUILD_STATUS", "CI_PIPELINE_STATUS"},
},
cli.StringFlag{
Name: "build.link",
Usage: "build link",
EnvVar: "DRONE_BUILD_LINK,CI_PIPELINE_URL",
&cli.StringFlag{
Name: "build.link",
Usage: "build link",
EnvVars: []string{"DRONE_BUILD_LINK", "CI_PIPELINE_URL"},
},
cli.StringFlag{
Name: "build.tag",
Usage: "build tag",
EnvVar: "DRONE_TAG,CI_COMMIT_TAG",
&cli.StringFlag{
Name: "build.tag",
Usage: "build tag",
EnvVars: []string{"DRONE_TAG", "CI_COMMIT_TAG"},
},
cli.StringFlag{
Name: "pull.request",
Usage: "pull request",
EnvVar: "DRONE_PULL_REQUEST,CI_COMMIT_PULL_REQUEST",
&cli.StringFlag{
Name: "pull.request",
Usage: "pull request",
EnvVars: []string{"DRONE_PULL_REQUEST", "CI_COMMIT_PULL_REQUEST"},
},
cli.Int64Flag{
Name: "build.started",
Usage: "build started",
EnvVar: "DRONE_BUILD_STARTED,CI_PIPELINE_STARTED",
&cli.Int64Flag{
Name: "build.started",
Usage: "build started",
EnvVars: []string{"DRONE_BUILD_STARTED", "CI_PIPELINE_STARTED"},
},
cli.Int64Flag{
Name: "build.finished",
Usage: "build finished",
EnvVar: "DRONE_BUILD_FINISHED,CI_PIPELINE_FINISHED",
&cli.Int64Flag{
Name: "build.finished",
Usage: "build finished",
EnvVars: []string{"DRONE_BUILD_FINISHED", "CI_PIPELINE_FINISHED"},
},
cli.BoolFlag{
Name: "github",
Usage: "Boolean value, indicates the runtime environment is GitHub Action.",
EnvVar: "PLUGIN_GITHUB,GITHUB",
&cli.BoolFlag{
Name: "github",
Usage: "Boolean value, indicates the runtime environment is GitHub Action.",
EnvVars: []string{"PLUGIN_GITHUB", "GITHUB"},
},
cli.StringFlag{
Name: "github.workflow",
Usage: "The name of the workflow.",
EnvVar: "GITHUB_WORKFLOW",
&cli.StringFlag{
Name: "github.workflow",
Usage: "The name of the workflow.",
EnvVars: []string{"GITHUB_WORKFLOW"},
},
cli.StringFlag{
Name: "github.action",
Usage: "The name of the action.",
EnvVar: "GITHUB_ACTION",
&cli.StringFlag{
Name: "github.action",
Usage: "The name of the action.",
EnvVars: []string{"GITHUB_ACTION"},
},
cli.StringFlag{
Name: "github.event.name",
Usage: "The webhook name of the event that triggered the workflow.",
EnvVar: "GITHUB_EVENT_NAME",
&cli.StringFlag{
Name: "github.event.name",
Usage: "The webhook name of the event that triggered the workflow.",
EnvVars: []string{"GITHUB_EVENT_NAME"},
},
cli.StringFlag{
Name: "github.event.path",
Usage: "The path to a file that contains the payload of the event that triggered the workflow. Value: /github/workflow/event.json.",
EnvVar: "GITHUB_EVENT_PATH",
&cli.StringFlag{
Name: "github.event.path",
Usage: "The path to a file that contains the payload of the event that triggered the workflow. Value: /github/workflow/event.json.",
EnvVars: []string{"GITHUB_EVENT_PATH"},
},
cli.StringFlag{
Name: "github.workspace",
Usage: "The GitHub workspace path. Value: /github/workspace.",
EnvVar: "GITHUB_WORKSPACE",
&cli.StringFlag{
Name: "github.workspace",
Usage: "The GitHub workspace path. Value: /github/workspace.",
EnvVars: []string{"GITHUB_WORKSPACE"},
},
cli.StringFlag{
Name: "deploy.to",
Usage: "Provides the target deployment environment for the running build. This value is only available to promotion and rollback pipelines.",
EnvVar: "DRONE_DEPLOY_TO,CI_PIPELINE_DEPLOY_TARGET",
&cli.StringFlag{
Name: "deploy.to",
Usage: "Provides the target deployment environment for the running build. This value is only available to promotion and rollback pipelines.",
EnvVars: []string{"DRONE_DEPLOY_TO", "CI_PIPELINE_DEPLOY_TARGET"},
},
}