mirror of
https://codeberg.org/woodpecker-plugins/go-plugin.git
synced 2024-06-16 05:40:53 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1842b6efa6 | ||
|
d493cf5c51 | ||
|
19c216c533 | ||
|
c182818d82 | ||
|
38dcac787e | ||
|
5c32612e8d | ||
|
567908df09 | ||
|
72d3ea674d | ||
|
ca1f8e48fe | ||
|
b67c23ab79 | ||
|
f6037e6127 | ||
|
fa7f39a739 | ||
|
0ab802ca5b | ||
|
090b4571b4 | ||
|
6a59bd9561 | ||
|
f3134af984 | ||
|
890edaf1c3 | ||
|
a969947601 |
|
@ -6,16 +6,28 @@ when:
|
|||
- 'renovate/*'
|
||||
|
||||
variables:
|
||||
- &golang "golang:1.21"
|
||||
- &golang "golang:1.22"
|
||||
- &golangci-lint "golangci/golangci-lint:v1.59-alpine"
|
||||
- &reviewdog-golangci-lint "woodpeckerci/plugin-reviewdog-golangci-lint:1.59"
|
||||
|
||||
steps:
|
||||
vendor:
|
||||
image: *golang
|
||||
commands: go mod vendor
|
||||
|
||||
review-go:
|
||||
image: *reviewdog-golangci-lint
|
||||
settings:
|
||||
token:
|
||||
from_secret: reviewdog_token
|
||||
when:
|
||||
event: pull_request
|
||||
|
||||
lint:
|
||||
image: golangci/golangci-lint:v1.55-alpine
|
||||
commands: golangci-lint run
|
||||
image: *golangci-lint
|
||||
commands: golangci-lint run --timeout 5m
|
||||
when:
|
||||
event: [push, tag, cron]
|
||||
|
||||
test:
|
||||
image: *golang
|
||||
|
|
|
@ -41,7 +41,7 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
func currFlags() []cli.Flag {
|
||||
func commitFlags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "commit.sha",
|
||||
|
@ -106,7 +106,7 @@ func currFlags() []cli.Flag {
|
|||
}
|
||||
}
|
||||
|
||||
func currFromContext(c *cli.Context) Commit {
|
||||
func commitFromContext(c *cli.Context) Commit {
|
||||
return Commit{
|
||||
Sha: c.String("commit.sha"),
|
||||
Ref: c.String("commit.ref"),
|
||||
|
@ -125,7 +125,7 @@ func currFromContext(c *cli.Context) Commit {
|
|||
}
|
||||
}
|
||||
|
||||
func prevFlags() []cli.Flag {
|
||||
func previousCommitFlags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "prev.commit.sha",
|
||||
|
@ -170,7 +170,7 @@ func prevFlags() []cli.Flag {
|
|||
}
|
||||
}
|
||||
|
||||
func prevFromContext(c *cli.Context) Commit {
|
||||
func previousCommitFromContext(c *cli.Context) Commit {
|
||||
return Commit{
|
||||
Sha: c.String("prev.commit.sha"),
|
||||
Ref: c.String("prev.commit.ref"),
|
||||
|
|
4
flags.go
4
flags.go
|
@ -25,8 +25,8 @@ func Flags() []cli.Flag {
|
|||
// Pipeline flags
|
||||
flags = append(flags, repositoryFlags()...)
|
||||
flags = append(flags, pipelineFlags()...)
|
||||
flags = append(flags, currFlags()...)
|
||||
flags = append(flags, prevFlags()...)
|
||||
flags = append(flags, commitFlags()...)
|
||||
flags = append(flags, previousCommitFlags()...)
|
||||
flags = append(flags, stepFlags()...)
|
||||
flags = append(flags, systemFlags()...)
|
||||
flags = append(flags, forgeFlags()...)
|
||||
|
|
13
forge.go
13
forge.go
|
@ -28,6 +28,9 @@ const (
|
|||
// Forge defines metadata for integration with a forge.
|
||||
type Forge struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
|
||||
// Deprecated: Please use URL instead.
|
||||
Link string `json:"link,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -35,14 +38,15 @@ func forgeFlags() []cli.Flag {
|
|||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "forge.type",
|
||||
Usage: "forge type (gitea, github, gitlab, bitbucker)",
|
||||
Usage: "forge type (gitea, github, gitlab, bitbucket)",
|
||||
EnvVars: []string{
|
||||
"CI_FORGE_TYPE",
|
||||
},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "forge.link",
|
||||
Usage: "forge link",
|
||||
Name: "forge.url",
|
||||
Aliases: []string{"forge.link"},
|
||||
Usage: "forge url",
|
||||
EnvVars: []string{
|
||||
"CI_FORGE_URL",
|
||||
"CI_FORGE_LINK",
|
||||
|
@ -54,6 +58,7 @@ func forgeFlags() []cli.Flag {
|
|||
func forgeFromContext(ctx *cli.Context) Forge {
|
||||
return Forge{
|
||||
Type: ctx.String("forge.type"),
|
||||
Link: ctx.String("forge.link"),
|
||||
Link: ctx.String("forge.url"),
|
||||
URL: ctx.String("forge.url"),
|
||||
}
|
||||
}
|
||||
|
|
14
go.mod
14
go.mod
|
@ -4,20 +4,20 @@ go 1.19
|
|||
|
||||
require (
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/rs/zerolog v1.31.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/urfave/cli/v2 v2.27.1
|
||||
golang.org/x/net v0.20.0
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/urfave/cli/v2 v2.27.2
|
||||
golang.org/x/net v0.26.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
74
go.sum
74
go.sum
|
@ -1,84 +1,38 @@
|
|||
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
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/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=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
|
||||
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
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/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.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/urfave/cli/v2 v2.23.7 h1:YHDQ46s3VghFHFf1DdF+Sh7H4RqhcM+t0TmZRJx4oJY=
|
||||
github.com/urfave/cli/v2 v2.23.7/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI=
|
||||
github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/urfave/cli/v2 v2.27.0 h1:uNs1K8JwTFL84X68j5Fjny6hfANh9nTlJ6dRtZAFAHY=
|
||||
github.com/urfave/cli/v2 v2.27.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
|
||||
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
|
||||
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
|
||||
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
|
||||
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
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/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
|
||||
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
|
||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
|
||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
|
||||
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
||||
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
40
metadata.go
40
metadata.go
|
@ -20,24 +20,36 @@ import (
|
|||
|
||||
// Metadata defines runtime metadata.
|
||||
type Metadata struct {
|
||||
Repository Repository `json:"repo,omitempty"`
|
||||
Pipeline Pipeline `json:"curr,omitempty"`
|
||||
Curr Commit `json:"commit,omitempty"`
|
||||
Prev Commit `json:"prev,omitempty"`
|
||||
Step Step `json:"step,omitempty"`
|
||||
System System `json:"sys,omitempty"`
|
||||
Forge Forge `json:"forge,omitempty"`
|
||||
Repository Repository `json:"repo,omitempty"`
|
||||
Pipeline Pipeline `json:"curr,omitempty"`
|
||||
Commit Commit `json:"commit,omitempty"`
|
||||
PreviousCommit Commit `json:"previous_commit,omitempty"`
|
||||
Step Step `json:"step,omitempty"`
|
||||
System System `json:"sys,omitempty"`
|
||||
Forge Forge `json:"forge,omitempty"`
|
||||
|
||||
// Deprecated: Please use Commit instead.
|
||||
Curr Commit
|
||||
|
||||
// Deprecated: Please use PreviousCommit instead.
|
||||
Prev Commit `json:"prev,omitempty"`
|
||||
}
|
||||
|
||||
// MetadataFromContext creates a Metadata from the cli.Context.
|
||||
func MetadataFromContext(ctx *cli.Context) Metadata {
|
||||
commit := commitFromContext(ctx)
|
||||
previousCommit := previousCommitFromContext(ctx)
|
||||
|
||||
return Metadata{
|
||||
Repository: repositoryFromContext(ctx),
|
||||
Pipeline: pipelineFromContext(ctx),
|
||||
Curr: currFromContext(ctx),
|
||||
Prev: prevFromContext(ctx),
|
||||
Step: stepFromContext(ctx),
|
||||
System: systemFromContext(ctx),
|
||||
Forge: forgeFromContext(ctx),
|
||||
Repository: repositoryFromContext(ctx),
|
||||
Pipeline: pipelineFromContext(ctx),
|
||||
Commit: commit,
|
||||
PreviousCommit: previousCommit,
|
||||
Step: stepFromContext(ctx),
|
||||
System: systemFromContext(ctx),
|
||||
Forge: forgeFromContext(ctx),
|
||||
|
||||
Curr: commit,
|
||||
Prev: previousCommit,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ func TestMetadata(t *testing.T) {
|
|||
// Repository
|
||||
assert.Equal(t, "woodpecker", plugin.Metadata.Repository.Name)
|
||||
assert.Equal(t, "woodpecker-ci", plugin.Metadata.Repository.Owner)
|
||||
assert.Equal(t, "https://codeberg.org/woodpecker-plugins/go-plugin", plugin.Metadata.Repository.Link)
|
||||
assert.Equal(t, "https://codeberg.org/woodpecker-plugins/go-plugin", plugin.Metadata.Repository.URL)
|
||||
assert.Equal(t, "https://codeberg.org/woodpecker-plugins/go-plugin.git", plugin.Metadata.Repository.CloneURL)
|
||||
assert.Equal(t, "main", plugin.Metadata.Repository.Branch)
|
||||
assert.False(t, plugin.Metadata.Repository.Private)
|
||||
|
@ -103,7 +103,7 @@ func TestMetadata(t *testing.T) {
|
|||
// Pipeline
|
||||
assert.Equal(t, int64(1), plugin.Metadata.Pipeline.Number)
|
||||
assert.Equal(t, EventTypePush, plugin.Metadata.Pipeline.Event)
|
||||
assert.Equal(t, "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1", plugin.Metadata.Pipeline.Link)
|
||||
assert.Equal(t, "https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/1", plugin.Metadata.Pipeline.URL)
|
||||
assert.Equal(t, "running", plugin.Metadata.Pipeline.Status)
|
||||
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Created)
|
||||
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Started)
|
||||
|
@ -114,11 +114,11 @@ func TestMetadata(t *testing.T) {
|
|||
|
||||
// System
|
||||
assert.Equal(t, "woodpecker", plugin.Metadata.System.Name)
|
||||
assert.Equal(t, "https://ci.woodpecker-ci.org", plugin.Metadata.System.Link)
|
||||
assert.Equal(t, "https://ci.woodpecker-ci.org", plugin.Metadata.System.URL)
|
||||
assert.Equal(t, "1.0.0", plugin.Metadata.System.Version)
|
||||
assert.Equal(t, "woodpecker-ci.org", plugin.Metadata.System.Host)
|
||||
|
||||
// Forge
|
||||
assert.Equal(t, ForgeTypeGitea, plugin.Metadata.Forge.Type)
|
||||
assert.Equal(t, "https://codeberg.org", plugin.Metadata.Forge.Link)
|
||||
assert.Equal(t, "https://codeberg.org", plugin.Metadata.Forge.URL)
|
||||
}
|
||||
|
|
13
pipeline.go
13
pipeline.go
|
@ -34,12 +34,15 @@ type Pipeline struct {
|
|||
Number int64 `json:"number,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Event string `json:"event,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
DeployTarget string `json:"target,omitempty"`
|
||||
Created time.Time `json:"created,omitempty"`
|
||||
Started time.Time `json:"started,omitempty"`
|
||||
Finished time.Time `json:"finished,omitempty"`
|
||||
Parent int64 `json:"parent,omitempty"`
|
||||
|
||||
// Deprecated: Please use URL instead.
|
||||
Link string `json:"link,omitempty"`
|
||||
}
|
||||
|
||||
func pipelineFlags() []cli.Flag {
|
||||
|
@ -69,8 +72,9 @@ func pipelineFlags() []cli.Flag {
|
|||
},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "pipeline.link",
|
||||
Usage: "pipeline link",
|
||||
Name: "pipeline.url",
|
||||
Aliases: []string{"pipeline.link"},
|
||||
Usage: "pipeline url",
|
||||
EnvVars: []string{
|
||||
"CI_PIPELINE_URL",
|
||||
"CI_PIPELINE_LINK",
|
||||
|
@ -125,7 +129,8 @@ func pipelineFromContext(c *cli.Context) Pipeline {
|
|||
Number: c.Int64("pipeline.number"),
|
||||
Status: c.String("pipeline.status"),
|
||||
Event: c.String("pipeline.event"),
|
||||
Link: c.String("pipeline.link"),
|
||||
URL: c.String("pipeline.url"),
|
||||
Link: c.String("pipeline.url"),
|
||||
DeployTarget: c.String("pipeline.deploy-target"),
|
||||
Created: time.Unix(c.Int64("pipeline.created"), 0),
|
||||
Started: time.Unix(c.Int64("pipeline.started"), 0),
|
||||
|
|
|
@ -58,6 +58,7 @@ func New(opt Options) *Plugin {
|
|||
|
||||
app := &cli.App{
|
||||
Name: opt.Name,
|
||||
Usage: "Run the Woodpecker CI plugin",
|
||||
Description: opt.Description,
|
||||
Version: opt.Version,
|
||||
Flags: append(opt.Flags, Flags()...),
|
||||
|
|
44
repo.go
44
repo.go
|
@ -20,16 +20,28 @@ import (
|
|||
|
||||
// Repository defines runtime metadata for a repository.
|
||||
type Repository struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Owner string `json:"owner,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
CloneURL string `json:"clone_url,omitempty"`
|
||||
Private bool `json:"private,omitempty"`
|
||||
Branch string `json:"default_branch,omitempty"`
|
||||
RemoteID string `json:"remote_id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Owner string `json:"owner,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
CloneURL string `json:"clone_url,omitempty"`
|
||||
Private bool `json:"private,omitempty"`
|
||||
DefaultBranch string `json:"default_branch,omitempty"`
|
||||
|
||||
// Deprecated: Please use DefaultBranch instead.
|
||||
Branch string
|
||||
}
|
||||
|
||||
func repositoryFlags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "repo.remote-id",
|
||||
Usage: "repo remote id",
|
||||
EnvVars: []string{
|
||||
"CI_REPO_REMOTE_ID",
|
||||
},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo.name",
|
||||
Usage: "repo name",
|
||||
|
@ -47,8 +59,9 @@ func repositoryFlags() []cli.Flag {
|
|||
},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "repo.link",
|
||||
Usage: "repo link",
|
||||
Name: "repo.url",
|
||||
Aliases: []string{"repo.link"},
|
||||
Usage: "repo url",
|
||||
EnvVars: []string{
|
||||
"CI_REPO_URL",
|
||||
"CI_REPO_LINK",
|
||||
|
@ -84,11 +97,14 @@ func repositoryFlags() []cli.Flag {
|
|||
|
||||
func repositoryFromContext(c *cli.Context) Repository {
|
||||
return Repository{
|
||||
Name: c.String("repo.name"),
|
||||
Owner: c.String("repo.owner"),
|
||||
Link: c.String("repo.link"),
|
||||
CloneURL: c.String("repo.clone-url"),
|
||||
Private: c.Bool("repo.private"),
|
||||
Branch: c.String("repo.default-branch"),
|
||||
RemoteID: c.String("repo.remote-id"),
|
||||
Name: c.String("repo.name"),
|
||||
Owner: c.String("repo.owner"),
|
||||
URL: c.String("repo.url"),
|
||||
Link: c.String("repo.url"),
|
||||
CloneURL: c.String("repo.clone-url"),
|
||||
Private: c.Bool("repo.private"),
|
||||
Branch: c.String("repo.default-branch"),
|
||||
DefaultBranch: c.String("repo.default-branch"),
|
||||
}
|
||||
}
|
||||
|
|
21
system.go
21
system.go
|
@ -24,9 +24,12 @@ import (
|
|||
type System struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
Platform string `json:"arch,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
|
||||
// Deprecated: Please use URL instead.
|
||||
Link string `json:"link,omitempty"`
|
||||
}
|
||||
|
||||
func systemFlags() []cli.Flag {
|
||||
|
@ -48,8 +51,9 @@ func systemFlags() []cli.Flag {
|
|||
},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "system.link",
|
||||
Usage: "system link",
|
||||
Name: "system.url",
|
||||
Aliases: []string{"system.link"},
|
||||
Usage: "system url",
|
||||
EnvVars: []string{
|
||||
"CI_SYSTEM_URL",
|
||||
"CI_SYSTEM_LINK",
|
||||
|
@ -75,19 +79,20 @@ func systemFlags() []cli.Flag {
|
|||
}
|
||||
|
||||
func systemFromContext(ctx *cli.Context) System {
|
||||
link := ctx.String("system.link")
|
||||
url := ctx.String("system.url")
|
||||
host := ctx.String("system.host")
|
||||
if link == "" && host != "" {
|
||||
// Alternative link format used by Drone.
|
||||
if url == "" && host != "" {
|
||||
// Alternative url format used by Drone.
|
||||
proto := os.Getenv("DRONE_SYSTEM_PROTO")
|
||||
if proto != "" {
|
||||
link = proto + "://" + host
|
||||
url = proto + "://" + host
|
||||
}
|
||||
}
|
||||
return System{
|
||||
Name: ctx.String("system.name"),
|
||||
Host: host,
|
||||
Link: link,
|
||||
URL: url,
|
||||
Link: url,
|
||||
Platform: ctx.String("system.arch"),
|
||||
Version: ctx.String("system.version"),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user