From e5d70e584b408178a411b1a2a9090b91dfc1ed57 Mon Sep 17 00:00:00 2001 From: wsan3 Date: Tue, 5 Mar 2024 10:44:32 -0600 Subject: [PATCH 01/10] Process PR label event 1. Add API changes for updating repos to leverage label events 2. Process PR label events in scm package 3. Update compiler to use label value in its purging process --- api/webhook/post.go | 1 + compiler/engine.go | 3 +++ compiler/native/compile.go | 1 + compiler/native/native.go | 10 ++++++++++ scm/github/webhook.go | 6 ++++-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/api/webhook/post.go b/api/webhook/post.go index 39bf93430..991b88a5c 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -505,6 +505,7 @@ func PostWebhook(c *gin.Context) { WithMetadata(m). WithRepo(repo). WithUser(u). + WithLabel(webhook.PullRequest.Label). Compile(config) if err != nil { // format the error message with extra information diff --git a/compiler/engine.go b/compiler/engine.go index 69812a519..f1f416cce 100644 --- a/compiler/engine.go +++ b/compiler/engine.go @@ -140,6 +140,9 @@ type Engine interface { // WithUser defines a function that sets // the library user type in the Engine. WithUser(*library.User) Engine + // WithLabel defines a function that sets + // the label in the Engine. + WithLabel(string) Engine // WithUser defines a function that sets // the private github client in the Engine. WithPrivateGitHub(string, string) Engine diff --git a/compiler/native/compile.go b/compiler/native/compile.go index 08d1c8f11..dcabd395f 100644 --- a/compiler/native/compile.go +++ b/compiler/native/compile.go @@ -70,6 +70,7 @@ func (c *client) Compile(v interface{}) (*pipeline.Build, *library.Pipeline, err Repo: c.repo.GetFullName(), Tag: strings.TrimPrefix(c.build.GetRef(), "refs/tags/"), Target: c.build.GetDeploy(), + Label: c.label, } switch { diff --git a/compiler/native/native.go b/compiler/native/native.go index a93c6fd50..c5acf0a2d 100644 --- a/compiler/native/native.go +++ b/compiler/native/native.go @@ -42,6 +42,7 @@ type client struct { metadata *types.Metadata repo *library.Repo user *library.User + label string } // New returns a Pipeline implementation that integrates with the supported registries. @@ -210,3 +211,12 @@ func (c *client) WithUser(u *library.User) compiler.Engine { return c } + +// WithComment sets the comment in the Engine. +func (c *client) WithLabel(label string) compiler.Engine { + if label != "" { + c.label = label + } + + return c +} diff --git a/scm/github/webhook.go b/scm/github/webhook.go index 9b489a3e2..02b658f42 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -250,11 +250,12 @@ func (c *client) processPREvent(h *library.Hook, payload *github.PullRequestEven return &types.Webhook{Hook: h}, nil } - // skip if the pull request action is not opened, synchronize, reopened, or edited + // skip if the pull request action is not opened, synchronize, reopened, edited, or labeled if !strings.EqualFold(payload.GetAction(), "opened") && !strings.EqualFold(payload.GetAction(), "synchronize") && !strings.EqualFold(payload.GetAction(), "reopened") && - !strings.EqualFold(payload.GetAction(), "edited") { + !strings.EqualFold(payload.GetAction(), "edited") && + !strings.EqualFold(payload.GetAction(), "labeled") { return &types.Webhook{Hook: h}, nil } @@ -313,6 +314,7 @@ func (c *client) processPREvent(h *library.Hook, payload *github.PullRequestEven PullRequest: types.PullRequest{ Number: payload.GetNumber(), IsFromFork: payload.GetPullRequest().GetHead().GetRepo().GetFork(), + Label: payload.GetLabel().GetName(), }, Hook: h, Repo: r, From 34f98d9b6379d634a120f842eda85663c35e7117 Mon Sep 17 00:00:00 2001 From: wsan3 Date: Tue, 12 Mar 2024 10:40:06 -0500 Subject: [PATCH 02/10] Add labeled event to PR struct --- database/repo/repo_test.go | 1 + database/secret/secret_test.go | 1 + go.mod | 16 +++++++++------- go.sum | 26 ++++++++++++-------------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/database/repo/repo_test.go b/database/repo/repo_test.go index 597ef1623..f8d5dd179 100644 --- a/database/repo/repo_test.go +++ b/database/repo/repo_test.go @@ -216,6 +216,7 @@ func testEvents() *library.Events { Edited: new(bool), Synchronize: new(bool), Reopened: new(bool), + Labeled: new(bool), }, Deployment: &actions.Deploy{ Created: new(bool), diff --git a/database/secret/secret_test.go b/database/secret/secret_test.go index 31156ebca..239c094fa 100644 --- a/database/secret/secret_test.go +++ b/database/secret/secret_test.go @@ -241,6 +241,7 @@ func testEvents() *library.Events { Edited: new(bool), Synchronize: new(bool), Reopened: new(bool), + Labeled: new(bool), }, Deployment: &actions.Deploy{ Created: new(bool), diff --git a/go.mod b/go.mod index 3cfaeb5fb..d44d8b104 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/go-vela/server go 1.21 +replace github.com/go-vela/types => ../types + require ( github.com/Bose/minisentinel v0.0.0-20200130220412-917c5a9223bb github.com/DATA-DOG/go-sqlmock v1.5.2 @@ -9,12 +11,12 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 github.com/adhocore/gronx v1.6.7 github.com/alicebob/miniredis/v2 v2.31.1 - github.com/aws/aws-sdk-go v1.50.24 + github.com/aws/aws-sdk-go v1.50.15 github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3 github.com/drone/envsubst v1.0.3 github.com/gin-gonic/gin v1.9.1 github.com/go-playground/assert/v2 v2.2.0 - github.com/go-vela/types v0.23.1 + github.com/go-vela/types v0.23.0 github.com/golang-jwt/jwt/v5 v5.2.0 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v59 v59.0.0 @@ -27,7 +29,7 @@ require ( github.com/joho/godotenv v1.5.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.18.0 - github.com/redis/go-redis/v9 v9.5.1 + github.com/redis/go-redis/v9 v9.4.0 github.com/sirupsen/logrus v1.9.3 github.com/spf13/afero v1.11.0 github.com/urfave/cli/v2 v2.27.1 @@ -36,10 +38,10 @@ require ( golang.org/x/oauth2 v0.17.0 golang.org/x/sync v0.6.0 gopkg.in/square/go-jose.v2 v2.6.0 - gorm.io/driver/postgres v1.5.6 - gorm.io/driver/sqlite v1.5.5 - gorm.io/gorm v1.25.7 - k8s.io/apimachinery v0.29.2 + gorm.io/driver/postgres v1.5.4 + gorm.io/driver/sqlite v1.5.4 + gorm.io/gorm v1.25.6 + k8s.io/apimachinery v0.29.1 ) require ( diff --git a/go.sum b/go.sum index d2dde2a27..bf8ddec66 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/alicebob/miniredis/v2 v2.11.1/go.mod h1:UA48pmi7aSazcGAvcdKcBB49z521I github.com/alicebob/miniredis/v2 v2.31.1 h1:7XAt0uUg3DtwEKW5ZAGa+K7FZV2DdKQo5K/6TTnfX8Y= github.com/alicebob/miniredis/v2 v2.31.1/go.mod h1:UB/T2Uztp7MlFSDakaX1sTXUv5CASoprx0wulRT6HBg= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aws/aws-sdk-go v1.50.24 h1:3o2Pg7mOoVL0jv54vWtuafoZqAeEXLhm1tltWA2GcEw= -github.com/aws/aws-sdk-go v1.50.24/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.50.15 h1:wEMnPfEQQFaoIJwuO18zq/vtG4Ft7NxQ3r9xlEi/8zg= +github.com/aws/aws-sdk-go v1.50.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -86,8 +86,6 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-vela/types v0.23.1 h1:st4BeDcYVyaaFqblU1YroztNvmYLBgmfZpWq0En0Sg0= -github.com/go-vela/types v0.23.1/go.mod h1:AAqgxIw1aRBgPkE/5juGuiwh/JZuOtL8fcPaEkjFWwQ= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -231,8 +229,8 @@ github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lne github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= -github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.4.0 h1:Yzoz33UZw9I/mFhx4MNrB6Fk+XHO1VukNcCa1+lwyKk= +github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -370,14 +368,14 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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= -gorm.io/driver/postgres v1.5.6 h1:ydr9xEd5YAM0vxVDY0X139dyzNz10spDiDlC7+ibLeU= -gorm.io/driver/postgres v1.5.6/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA= -gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E= -gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= -gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A= -gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= -k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo= +gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0= +gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0= +gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4= +gorm.io/gorm v1.25.6 h1:V92+vVda1wEISSOMtodHVRcUIOPYa2tgQtyF+DfFx+A= +gorm.io/gorm v1.25.6/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= +k8s.io/apimachinery v0.29.1/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= From dafa7bef49395a84213355eec57bde99c17eea8f Mon Sep 17 00:00:00 2001 From: wsan3 Date: Tue, 12 Mar 2024 11:05:28 -0500 Subject: [PATCH 03/10] Merge branch 'main' into feat/pr-labeled-action --- api/build/approve.go | 14 ++++++++++++-- go.mod | 16 +++++++--------- go.sum | 26 ++++++++++++++------------ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/api/build/approve.go b/api/build/approve.go index 84aedb418..037160282 100644 --- a/api/build/approve.go +++ b/api/build/approve.go @@ -86,6 +86,7 @@ func ApproveBuild(c *gin.Context) { "user": u.GetName(), }) + // verify build is in correct status if !strings.EqualFold(b.GetStatus(), constants.StatusPendingApproval) { retErr := fmt.Errorf("unable to approve build %s/%d: build not in pending approval state", r.GetFullName(), b.GetNumber()) util.HandleError(c, http.StatusBadRequest, retErr) @@ -93,10 +94,18 @@ func ApproveBuild(c *gin.Context) { return } + // verify user is not the sender of the build + if strings.EqualFold(u.GetName(), b.GetSender()) { + retErr := fmt.Errorf("unable to approve build %s/%d: approver cannot be the sender of the build", r.GetFullName(), b.GetNumber()) + util.HandleError(c, http.StatusBadRequest, retErr) + + return + } + logger.Debugf("user %s approved build %s/%d for execution", u.GetName(), r.GetFullName(), b.GetNumber()) // send API call to capture the repo owner - u, err := database.FromContext(c).GetUser(ctx, r.GetUserID()) + owner, err := database.FromContext(c).GetUser(ctx, r.GetUserID()) if err != nil { retErr := fmt.Errorf("unable to get owner for %s: %w", r.GetFullName(), err) @@ -105,6 +114,7 @@ func ApproveBuild(c *gin.Context) { return } + // set fields b.SetStatus(constants.StatusPending) b.SetApprovedAt(time.Now().Unix()) b.SetApprovedBy(u.GetName()) @@ -122,7 +132,7 @@ func ApproveBuild(c *gin.Context) { database.FromContext(c), b, r, - u, + owner, b.GetHost(), ) diff --git a/go.mod b/go.mod index d44d8b104..3cfaeb5fb 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/go-vela/server go 1.21 -replace github.com/go-vela/types => ../types - require ( github.com/Bose/minisentinel v0.0.0-20200130220412-917c5a9223bb github.com/DATA-DOG/go-sqlmock v1.5.2 @@ -11,12 +9,12 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 github.com/adhocore/gronx v1.6.7 github.com/alicebob/miniredis/v2 v2.31.1 - github.com/aws/aws-sdk-go v1.50.15 + github.com/aws/aws-sdk-go v1.50.24 github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3 github.com/drone/envsubst v1.0.3 github.com/gin-gonic/gin v1.9.1 github.com/go-playground/assert/v2 v2.2.0 - github.com/go-vela/types v0.23.0 + github.com/go-vela/types v0.23.1 github.com/golang-jwt/jwt/v5 v5.2.0 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v59 v59.0.0 @@ -29,7 +27,7 @@ require ( github.com/joho/godotenv v1.5.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.18.0 - github.com/redis/go-redis/v9 v9.4.0 + github.com/redis/go-redis/v9 v9.5.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/afero v1.11.0 github.com/urfave/cli/v2 v2.27.1 @@ -38,10 +36,10 @@ require ( golang.org/x/oauth2 v0.17.0 golang.org/x/sync v0.6.0 gopkg.in/square/go-jose.v2 v2.6.0 - gorm.io/driver/postgres v1.5.4 - gorm.io/driver/sqlite v1.5.4 - gorm.io/gorm v1.25.6 - k8s.io/apimachinery v0.29.1 + gorm.io/driver/postgres v1.5.6 + gorm.io/driver/sqlite v1.5.5 + gorm.io/gorm v1.25.7 + k8s.io/apimachinery v0.29.2 ) require ( diff --git a/go.sum b/go.sum index bf8ddec66..d2dde2a27 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/alicebob/miniredis/v2 v2.11.1/go.mod h1:UA48pmi7aSazcGAvcdKcBB49z521I github.com/alicebob/miniredis/v2 v2.31.1 h1:7XAt0uUg3DtwEKW5ZAGa+K7FZV2DdKQo5K/6TTnfX8Y= github.com/alicebob/miniredis/v2 v2.31.1/go.mod h1:UB/T2Uztp7MlFSDakaX1sTXUv5CASoprx0wulRT6HBg= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aws/aws-sdk-go v1.50.15 h1:wEMnPfEQQFaoIJwuO18zq/vtG4Ft7NxQ3r9xlEi/8zg= -github.com/aws/aws-sdk-go v1.50.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.50.24 h1:3o2Pg7mOoVL0jv54vWtuafoZqAeEXLhm1tltWA2GcEw= +github.com/aws/aws-sdk-go v1.50.24/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -86,6 +86,8 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-vela/types v0.23.1 h1:st4BeDcYVyaaFqblU1YroztNvmYLBgmfZpWq0En0Sg0= +github.com/go-vela/types v0.23.1/go.mod h1:AAqgxIw1aRBgPkE/5juGuiwh/JZuOtL8fcPaEkjFWwQ= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -229,8 +231,8 @@ github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lne github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/redis/go-redis/v9 v9.4.0 h1:Yzoz33UZw9I/mFhx4MNrB6Fk+XHO1VukNcCa1+lwyKk= -github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= +github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -368,14 +370,14 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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= -gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo= -gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0= -gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0= -gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4= -gorm.io/gorm v1.25.6 h1:V92+vVda1wEISSOMtodHVRcUIOPYa2tgQtyF+DfFx+A= -gorm.io/gorm v1.25.6/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= -k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= -k8s.io/apimachinery v0.29.1/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +gorm.io/driver/postgres v1.5.6 h1:ydr9xEd5YAM0vxVDY0X139dyzNz10spDiDlC7+ibLeU= +gorm.io/driver/postgres v1.5.6/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA= +gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E= +gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= +gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A= +gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= +k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= From 0d9268393d581d75a5ebf2ed1178af3a1c8241d3 Mon Sep 17 00:00:00 2001 From: wsan3 Date: Tue, 19 Mar 2024 12:34:55 -0500 Subject: [PATCH 04/10] Add support for PR unlabeled event 1. Update process PR event helper function 2. Update tests --- database/repo/repo_test.go | 1 + database/secret/secret_test.go | 1 + scm/github/webhook.go | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/database/repo/repo_test.go b/database/repo/repo_test.go index f8d5dd179..2d1ade568 100644 --- a/database/repo/repo_test.go +++ b/database/repo/repo_test.go @@ -217,6 +217,7 @@ func testEvents() *library.Events { Synchronize: new(bool), Reopened: new(bool), Labeled: new(bool), + Unlabeled: new(bool), }, Deployment: &actions.Deploy{ Created: new(bool), diff --git a/database/secret/secret_test.go b/database/secret/secret_test.go index 08d22724f..a7718edc7 100644 --- a/database/secret/secret_test.go +++ b/database/secret/secret_test.go @@ -243,6 +243,7 @@ func testEvents() *library.Events { Synchronize: new(bool), Reopened: new(bool), Labeled: new(bool), + Unlabeled: new(bool), }, Deployment: &actions.Deploy{ Created: new(bool), diff --git a/scm/github/webhook.go b/scm/github/webhook.go index 695fbd788..2bc510c5c 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -250,12 +250,13 @@ func (c *client) processPREvent(h *library.Hook, payload *github.PullRequestEven return &types.Webhook{Hook: h}, nil } - // skip if the pull request action is not opened, synchronize, reopened, edited, or labeled + // skip if the pull request action is not opened, synchronize, reopened, edited, labeled, or unlabeled if !strings.EqualFold(payload.GetAction(), "opened") && !strings.EqualFold(payload.GetAction(), "synchronize") && !strings.EqualFold(payload.GetAction(), "reopened") && !strings.EqualFold(payload.GetAction(), "edited") && - !strings.EqualFold(payload.GetAction(), "labeled") { + !strings.EqualFold(payload.GetAction(), "labeled") && + !strings.EqualFold(payload.GetAction(), "unlabeled") { return &types.Webhook{Hook: h}, nil } From b8a017c15d8b5458c3a84501abd2300af7f6add4 Mon Sep 17 00:00:00 2001 From: ecrupper Date: Mon, 1 Apr 2024 09:36:55 -0500 Subject: [PATCH 05/10] chore: remove legacy event code from repo and secret --- api/repo/create.go | 34 +- api/repo/update.go | 45 -- api/secret/create.go | 5 - api/secret/update.go | 4 - compiler/native/environment_test.go | 648 ++++++++++++------------- database/build/build_test.go | 5 - database/deployment/deployment_test.go | 5 - database/hook/hook_test.go | 5 - database/integration_test.go | 13 - database/repo/create_test.go | 6 +- database/repo/get_org_test.go | 4 +- database/repo/get_test.go | 4 +- database/repo/list_org_test.go | 12 +- database/repo/list_test.go | 6 +- database/repo/list_user_test.go | 12 +- database/repo/repo_test.go | 5 - database/repo/table.go | 10 - database/repo/update_test.go | 6 +- database/schedule/schedule_test.go | 5 - database/secret/create_test.go | 18 +- database/secret/get_org_test.go | 4 +- database/secret/get_repo_test.go | 4 +- database/secret/get_team_test.go | 4 +- database/secret/get_test.go | 4 +- database/secret/list_org_test.go | 6 +- database/secret/list_repo_test.go | 6 +- database/secret/list_team_test.go | 14 +- database/secret/list_test.go | 6 +- database/secret/secret_test.go | 6 - database/secret/table.go | 2 - database/secret/update_test.go | 18 +- go.mod | 2 +- go.sum | 4 +- mock/server/repo.go | 17 +- mock/server/secret.go | 10 - queue/redis/redis_test.go | 28 +- router/middleware/org/org_test.go | 5 - router/middleware/repo/repo_test.go | 5 - scm/github/repo_test.go | 6 - secret/native/count_test.go | 1 - secret/native/create_test.go | 4 - secret/native/delete_test.go | 1 - secret/native/get_test.go | 1 - secret/native/list_test.go | 2 - secret/native/update.go | 5 - secret/native/update_test.go | 2 - secret/vault/create_test.go | 6 - secret/vault/get_test.go | 3 - secret/vault/list_test.go | 3 - secret/vault/update.go | 3 - secret/vault/update_test.go | 7 - secret/vault/vault.go | 21 +- secret/vault/vault_test.go | 4 - 53 files changed, 396 insertions(+), 670 deletions(-) diff --git a/api/repo/create.go b/api/repo/create.go index 9fe69dfad..59ccbf857 100644 --- a/api/repo/create.go +++ b/api/repo/create.go @@ -182,34 +182,6 @@ func CreateRepo(c *gin.Context) { r.SetAllowEvents(defaultAllowedEvents(defaultRepoEvents, defaultRepoEventsMask)) } - // -- DEPRECATED SECTION -- - // set default events if no events are passed in - if !input.GetAllowPull() && !input.GetAllowPush() && - !input.GetAllowDeploy() && !input.GetAllowTag() && - !input.GetAllowComment() { - for _, event := range defaultRepoEvents { - switch event { - case constants.EventPull: - r.SetAllowPull(true) - case constants.EventPush: - r.SetAllowPush(true) - case constants.EventDeploy: - r.SetAllowDeploy(true) - case constants.EventTag: - r.SetAllowTag(true) - case constants.EventComment: - r.SetAllowComment(true) - } - } - } else { - r.SetAllowComment(input.GetAllowComment()) - r.SetAllowDeploy(input.GetAllowDeploy()) - r.SetAllowPull(input.GetAllowPull()) - r.SetAllowPush(input.GetAllowPush()) - r.SetAllowTag(input.GetAllowTag()) - } - // -- END DEPRECATED SECTION -- - if len(input.GetPipelineType()) == 0 { r.SetPipelineType(constants.PipelineTypeYAML) } else { @@ -275,11 +247,7 @@ func CreateRepo(c *gin.Context) { // make sure our record of the repo allowed events matches what we send to SCM // what the dbRepo has should override default events on enable - r.SetAllowComment(dbRepo.GetAllowComment()) - r.SetAllowDeploy(dbRepo.GetAllowDeploy()) - r.SetAllowPull(dbRepo.GetAllowPull()) - r.SetAllowPush(dbRepo.GetAllowPush()) - r.SetAllowTag(dbRepo.GetAllowTag()) + r.SetAllowEvents(dbRepo.GetAllowEvents()) } // check if we should create the webhook diff --git a/api/repo/update.go b/api/repo/update.go index ba21996d3..efdb1a366 100644 --- a/api/repo/update.go +++ b/api/repo/update.go @@ -191,51 +191,6 @@ func UpdateRepo(c *gin.Context) { eventsChanged = true } - // -- DEPRECATED SECTION -- - if input.AllowPull != nil { - // update allow_pull if set - r.SetAllowPull(input.GetAllowPull()) - - eventsChanged = true - } - - if input.AllowPush != nil { - // update allow_push if set - r.SetAllowPush(input.GetAllowPush()) - - eventsChanged = true - } - - if input.AllowDeploy != nil { - // update allow_deploy if set - r.SetAllowDeploy(input.GetAllowDeploy()) - - eventsChanged = true - } - - if input.AllowTag != nil { - // update allow_tag if set - r.SetAllowTag(input.GetAllowTag()) - - eventsChanged = true - } - - if input.AllowComment != nil { - // update allow_comment if set - r.SetAllowComment(input.GetAllowComment()) - - eventsChanged = true - } - - // set default events if no events are enabled - if !r.GetAllowPull() && !r.GetAllowPush() && - !r.GetAllowDeploy() && !r.GetAllowTag() && - !r.GetAllowComment() { - r.SetAllowPull(true) - r.SetAllowPush(true) - } - // -- END DEPRECATED SECTION -- - // set default events if no events are enabled if r.GetAllowEvents().ToDatabase() == 0 { r.SetAllowEvents(defaultAllowedEvents(defaultRepoEvents, defaultRepoEventsMask)) diff --git a/api/secret/create.go b/api/secret/create.go index 3845f4b7c..e398647c6 100644 --- a/api/secret/create.go +++ b/api/secret/create.go @@ -225,11 +225,6 @@ func CreateSecret(c *gin.Context) { input.SetAllowEvents(e) } - if len(input.GetEvents()) == 0 { - // set default events to enable for the secret - input.SetEvents([]string{constants.EventPush, constants.EventTag, constants.EventDeploy}) - } - if input.AllowCommand == nil { input.SetAllowCommand(true) } diff --git a/api/secret/update.go b/api/secret/update.go index 98c78e031..aecadcc86 100644 --- a/api/secret/update.go +++ b/api/secret/update.go @@ -143,10 +143,6 @@ func UpdateSecret(c *gin.Context) { input.SetImages(util.Unique(input.GetImages())) } - if len(input.GetEvents()) > 0 { - input.SetEvents(util.Unique(input.GetEvents())) - } - if input.AllowCommand != nil { // update allow_command if set input.SetAllowCommand(input.GetAllowCommand()) diff --git a/compiler/native/environment_test.go b/compiler/native/environment_test.go index a6a598acc..01755972e 100644 --- a/compiler/native/environment_test.go +++ b/compiler/native/environment_test.go @@ -103,113 +103,103 @@ func TestNative_EnvironmentSteps(t *testing.T) { Name: str, Pull: "always", Environment: raw.StringSliceMap{ - "BUILD_AUTHOR": "", - "BUILD_AUTHOR_EMAIL": "", - "BUILD_BASE_REF": "", - "BUILD_BRANCH": "", - "BUILD_CHANNEL": "TODO", - "BUILD_CLONE": "", - "BUILD_COMMIT": "", - "BUILD_CREATED": "0", - "BUILD_ENQUEUED": "0", - "BUILD_EVENT": "", - "BUILD_HOST": "", - "BUILD_LINK": "", - "BUILD_MESSAGE": "", - "BUILD_NUMBER": "0", - "BUILD_PARENT": "0", - "BUILD_REF": "", - "BUILD_SENDER": "", - "BUILD_SOURCE": "", - "BUILD_STARTED": "0", - "BUILD_STATUS": "", - "BUILD_TITLE": "", - "BUILD_WORKSPACE": "/vela/src", - "CI": "true", - "REPOSITORY_ACTIVE": "false", - "REPOSITORY_ALLOW_COMMENT": "false", - "REPOSITORY_ALLOW_DEPLOY": "false", - "REPOSITORY_ALLOW_PULL": "false", - "REPOSITORY_ALLOW_PUSH": "false", - "REPOSITORY_ALLOW_TAG": "false", - "REPOSITORY_ALLOW_EVENTS": "", - "REPOSITORY_BRANCH": "", - "REPOSITORY_CLONE": "", - "REPOSITORY_FULL_NAME": "", - "REPOSITORY_LINK": "", - "REPOSITORY_NAME": "", - "REPOSITORY_ORG": "", - "REPOSITORY_PRIVATE": "false", - "REPOSITORY_TIMEOUT": "0", - "REPOSITORY_TRUSTED": "false", - "REPOSITORY_VISIBILITY": "", - "VELA": "true", - "VELA_ADDR": "TODO", - "VELA_BUILD_APPROVED_AT": "0", - "VELA_BUILD_APPROVED_BY": "", - "VELA_BUILD_AUTHOR": "", - "VELA_BUILD_AUTHOR_EMAIL": "", - "VELA_BUILD_BASE_REF": "", - "VELA_BUILD_BRANCH": "", - "VELA_BUILD_CHANNEL": "TODO", - "VELA_BUILD_CLONE": "", - "VELA_BUILD_COMMIT": "", - "VELA_BUILD_CREATED": "0", - "VELA_BUILD_DISTRIBUTION": "", - "VELA_BUILD_ENQUEUED": "0", - "VELA_BUILD_EVENT": "", - "VELA_BUILD_EVENT_ACTION": "", - "VELA_BUILD_HOST": "", - "VELA_BUILD_LINK": "", - "VELA_BUILD_MESSAGE": "", - "VELA_BUILD_NUMBER": "0", - "VELA_BUILD_PARENT": "0", - "VELA_BUILD_REF": "", - "VELA_BUILD_RUNTIME": "", - "VELA_BUILD_SENDER": "", - "VELA_BUILD_SOURCE": "", - "VELA_BUILD_STARTED": "0", - "VELA_BUILD_STATUS": "", - "VELA_BUILD_TITLE": "", - "VELA_BUILD_WORKSPACE": "/vela/src", - "VELA_CHANNEL": "TODO", - "VELA_DATABASE": "TODO", - "VELA_DISTRIBUTION": "TODO", - "VELA_HOST": "TODO", - "VELA_NETRC_MACHINE": "TODO", - "VELA_NETRC_PASSWORD": "", - "VELA_NETRC_USERNAME": "x-oauth-basic", - "VELA_QUEUE": "TODO", - "VELA_REPO_ACTIVE": "false", - "VELA_REPO_ALLOW_COMMENT": "false", - "VELA_REPO_ALLOW_DEPLOY": "false", - "VELA_REPO_ALLOW_PULL": "false", - "VELA_REPO_ALLOW_PUSH": "false", - "VELA_REPO_ALLOW_TAG": "false", - "VELA_REPO_ALLOW_EVENTS": "", - "VELA_REPO_APPROVE_BUILD": "", - "VELA_REPO_BRANCH": "", - "VELA_REPO_TOPICS": "", - "VELA_REPO_BUILD_LIMIT": "0", - "VELA_REPO_CLONE": "", - "VELA_REPO_FULL_NAME": "", - "VELA_REPO_LINK": "", - "VELA_REPO_NAME": "", - "VELA_REPO_ORG": "", - "VELA_REPO_PIPELINE_TYPE": "", - "VELA_REPO_PRIVATE": "false", - "VELA_REPO_TIMEOUT": "0", - "VELA_REPO_TRUSTED": "false", - "VELA_REPO_VISIBILITY": "", - "VELA_RUNTIME": "TODO", - "VELA_SOURCE": "TODO", - "VELA_USER_ACTIVE": "false", - "VELA_USER_ADMIN": "false", - "VELA_USER_FAVORITES": "[]", - "VELA_USER_NAME": "", - "VELA_VERSION": "TODO", - "VELA_WORKSPACE": "/vela/src", - "HELLO": "Hello, Stage Message", + "BUILD_AUTHOR": "", + "BUILD_AUTHOR_EMAIL": "", + "BUILD_BASE_REF": "", + "BUILD_BRANCH": "", + "BUILD_CHANNEL": "TODO", + "BUILD_CLONE": "", + "BUILD_COMMIT": "", + "BUILD_CREATED": "0", + "BUILD_ENQUEUED": "0", + "BUILD_EVENT": "", + "BUILD_HOST": "", + "BUILD_LINK": "", + "BUILD_MESSAGE": "", + "BUILD_NUMBER": "0", + "BUILD_PARENT": "0", + "BUILD_REF": "", + "BUILD_SENDER": "", + "BUILD_SOURCE": "", + "BUILD_STARTED": "0", + "BUILD_STATUS": "", + "BUILD_TITLE": "", + "BUILD_WORKSPACE": "/vela/src", + "CI": "true", + "REPOSITORY_ACTIVE": "false", + "REPOSITORY_ALLOW_EVENTS": "", + "REPOSITORY_BRANCH": "", + "REPOSITORY_CLONE": "", + "REPOSITORY_FULL_NAME": "", + "REPOSITORY_LINK": "", + "REPOSITORY_NAME": "", + "REPOSITORY_ORG": "", + "REPOSITORY_PRIVATE": "false", + "REPOSITORY_TIMEOUT": "0", + "REPOSITORY_TRUSTED": "false", + "REPOSITORY_VISIBILITY": "", + "VELA": "true", + "VELA_ADDR": "TODO", + "VELA_BUILD_APPROVED_AT": "0", + "VELA_BUILD_APPROVED_BY": "", + "VELA_BUILD_AUTHOR": "", + "VELA_BUILD_AUTHOR_EMAIL": "", + "VELA_BUILD_BASE_REF": "", + "VELA_BUILD_BRANCH": "", + "VELA_BUILD_CHANNEL": "TODO", + "VELA_BUILD_CLONE": "", + "VELA_BUILD_COMMIT": "", + "VELA_BUILD_CREATED": "0", + "VELA_BUILD_DISTRIBUTION": "", + "VELA_BUILD_ENQUEUED": "0", + "VELA_BUILD_EVENT": "", + "VELA_BUILD_EVENT_ACTION": "", + "VELA_BUILD_HOST": "", + "VELA_BUILD_LINK": "", + "VELA_BUILD_MESSAGE": "", + "VELA_BUILD_NUMBER": "0", + "VELA_BUILD_PARENT": "0", + "VELA_BUILD_REF": "", + "VELA_BUILD_RUNTIME": "", + "VELA_BUILD_SENDER": "", + "VELA_BUILD_SOURCE": "", + "VELA_BUILD_STARTED": "0", + "VELA_BUILD_STATUS": "", + "VELA_BUILD_TITLE": "", + "VELA_BUILD_WORKSPACE": "/vela/src", + "VELA_CHANNEL": "TODO", + "VELA_DATABASE": "TODO", + "VELA_DISTRIBUTION": "TODO", + "VELA_HOST": "TODO", + "VELA_NETRC_MACHINE": "TODO", + "VELA_NETRC_PASSWORD": "", + "VELA_NETRC_USERNAME": "x-oauth-basic", + "VELA_QUEUE": "TODO", + "VELA_REPO_ACTIVE": "false", + "VELA_REPO_ALLOW_EVENTS": "", + "VELA_REPO_APPROVE_BUILD": "", + "VELA_REPO_BRANCH": "", + "VELA_REPO_TOPICS": "", + "VELA_REPO_BUILD_LIMIT": "0", + "VELA_REPO_CLONE": "", + "VELA_REPO_FULL_NAME": "", + "VELA_REPO_LINK": "", + "VELA_REPO_NAME": "", + "VELA_REPO_ORG": "", + "VELA_REPO_PIPELINE_TYPE": "", + "VELA_REPO_PRIVATE": "false", + "VELA_REPO_TIMEOUT": "0", + "VELA_REPO_TRUSTED": "false", + "VELA_REPO_VISIBILITY": "", + "VELA_RUNTIME": "TODO", + "VELA_SOURCE": "TODO", + "VELA_USER_ACTIVE": "false", + "VELA_USER_ADMIN": "false", + "VELA_USER_FAVORITES": "[]", + "VELA_USER_NAME": "", + "VELA_VERSION": "TODO", + "VELA_WORKSPACE": "/vela/src", + "HELLO": "Hello, Stage Message", }, }, } @@ -287,113 +277,103 @@ func TestNative_EnvironmentServices(t *testing.T) { Name: str, Pull: "always", Environment: raw.StringSliceMap{ - "BUILD_AUTHOR": "", - "BUILD_AUTHOR_EMAIL": "", - "BUILD_BASE_REF": "", - "BUILD_BRANCH": "", - "BUILD_CHANNEL": "TODO", - "BUILD_CLONE": "", - "BUILD_COMMIT": "", - "BUILD_CREATED": "0", - "BUILD_ENQUEUED": "0", - "BUILD_EVENT": "", - "BUILD_HOST": "", - "BUILD_LINK": "", - "BUILD_MESSAGE": "", - "BUILD_NUMBER": "0", - "BUILD_PARENT": "0", - "BUILD_REF": "", - "BUILD_SENDER": "", - "BUILD_SOURCE": "", - "BUILD_STARTED": "0", - "BUILD_STATUS": "", - "BUILD_TITLE": "", - "BUILD_WORKSPACE": "/vela/src", - "CI": "true", - "REPOSITORY_ACTIVE": "false", - "REPOSITORY_ALLOW_COMMENT": "false", - "REPOSITORY_ALLOW_DEPLOY": "false", - "REPOSITORY_ALLOW_PULL": "false", - "REPOSITORY_ALLOW_PUSH": "false", - "REPOSITORY_ALLOW_TAG": "false", - "REPOSITORY_ALLOW_EVENTS": "", - "REPOSITORY_BRANCH": "", - "REPOSITORY_CLONE": "", - "REPOSITORY_FULL_NAME": "", - "REPOSITORY_LINK": "", - "REPOSITORY_NAME": "", - "REPOSITORY_ORG": "", - "REPOSITORY_PRIVATE": "false", - "REPOSITORY_TIMEOUT": "0", - "REPOSITORY_TRUSTED": "false", - "REPOSITORY_VISIBILITY": "", - "VELA": "true", - "VELA_ADDR": "TODO", - "VELA_BUILD_APPROVED_AT": "0", - "VELA_BUILD_APPROVED_BY": "", - "VELA_BUILD_AUTHOR": "", - "VELA_BUILD_AUTHOR_EMAIL": "", - "VELA_BUILD_BASE_REF": "", - "VELA_BUILD_BRANCH": "", - "VELA_BUILD_CHANNEL": "TODO", - "VELA_BUILD_CLONE": "", - "VELA_BUILD_COMMIT": "", - "VELA_BUILD_CREATED": "0", - "VELA_BUILD_DISTRIBUTION": "", - "VELA_BUILD_ENQUEUED": "0", - "VELA_BUILD_EVENT": "", - "VELA_BUILD_EVENT_ACTION": "", - "VELA_BUILD_HOST": "", - "VELA_BUILD_LINK": "", - "VELA_BUILD_MESSAGE": "", - "VELA_BUILD_NUMBER": "0", - "VELA_BUILD_PARENT": "0", - "VELA_BUILD_REF": "", - "VELA_BUILD_RUNTIME": "", - "VELA_BUILD_SENDER": "", - "VELA_BUILD_SOURCE": "", - "VELA_BUILD_STARTED": "0", - "VELA_BUILD_STATUS": "", - "VELA_BUILD_TITLE": "", - "VELA_BUILD_WORKSPACE": "/vela/src", - "VELA_CHANNEL": "TODO", - "VELA_DATABASE": "TODO", - "VELA_DISTRIBUTION": "TODO", - "VELA_HOST": "TODO", - "VELA_NETRC_MACHINE": "TODO", - "VELA_NETRC_PASSWORD": "", - "VELA_NETRC_USERNAME": "x-oauth-basic", - "VELA_QUEUE": "TODO", - "VELA_REPO_ACTIVE": "false", - "VELA_REPO_ALLOW_COMMENT": "false", - "VELA_REPO_ALLOW_DEPLOY": "false", - "VELA_REPO_ALLOW_PULL": "false", - "VELA_REPO_ALLOW_PUSH": "false", - "VELA_REPO_ALLOW_TAG": "false", - "VELA_REPO_ALLOW_EVENTS": "", - "VELA_REPO_APPROVE_BUILD": "", - "VELA_REPO_BRANCH": "", - "VELA_REPO_TOPICS": "", - "VELA_REPO_BUILD_LIMIT": "0", - "VELA_REPO_CLONE": "", - "VELA_REPO_FULL_NAME": "", - "VELA_REPO_LINK": "", - "VELA_REPO_NAME": "", - "VELA_REPO_ORG": "", - "VELA_REPO_PIPELINE_TYPE": "", - "VELA_REPO_PRIVATE": "false", - "VELA_REPO_TIMEOUT": "0", - "VELA_REPO_TRUSTED": "false", - "VELA_REPO_VISIBILITY": "", - "VELA_RUNTIME": "TODO", - "VELA_SOURCE": "TODO", - "VELA_USER_ACTIVE": "false", - "VELA_USER_ADMIN": "false", - "VELA_USER_FAVORITES": "[]", - "VELA_USER_NAME": "", - "VELA_VERSION": "TODO", - "VELA_WORKSPACE": "/vela/src", - "HELLO": "Hello, Global Message", + "BUILD_AUTHOR": "", + "BUILD_AUTHOR_EMAIL": "", + "BUILD_BASE_REF": "", + "BUILD_BRANCH": "", + "BUILD_CHANNEL": "TODO", + "BUILD_CLONE": "", + "BUILD_COMMIT": "", + "BUILD_CREATED": "0", + "BUILD_ENQUEUED": "0", + "BUILD_EVENT": "", + "BUILD_HOST": "", + "BUILD_LINK": "", + "BUILD_MESSAGE": "", + "BUILD_NUMBER": "0", + "BUILD_PARENT": "0", + "BUILD_REF": "", + "BUILD_SENDER": "", + "BUILD_SOURCE": "", + "BUILD_STARTED": "0", + "BUILD_STATUS": "", + "BUILD_TITLE": "", + "BUILD_WORKSPACE": "/vela/src", + "CI": "true", + "REPOSITORY_ACTIVE": "false", + "REPOSITORY_ALLOW_EVENTS": "", + "REPOSITORY_BRANCH": "", + "REPOSITORY_CLONE": "", + "REPOSITORY_FULL_NAME": "", + "REPOSITORY_LINK": "", + "REPOSITORY_NAME": "", + "REPOSITORY_ORG": "", + "REPOSITORY_PRIVATE": "false", + "REPOSITORY_TIMEOUT": "0", + "REPOSITORY_TRUSTED": "false", + "REPOSITORY_VISIBILITY": "", + "VELA": "true", + "VELA_ADDR": "TODO", + "VELA_BUILD_APPROVED_AT": "0", + "VELA_BUILD_APPROVED_BY": "", + "VELA_BUILD_AUTHOR": "", + "VELA_BUILD_AUTHOR_EMAIL": "", + "VELA_BUILD_BASE_REF": "", + "VELA_BUILD_BRANCH": "", + "VELA_BUILD_CHANNEL": "TODO", + "VELA_BUILD_CLONE": "", + "VELA_BUILD_COMMIT": "", + "VELA_BUILD_CREATED": "0", + "VELA_BUILD_DISTRIBUTION": "", + "VELA_BUILD_ENQUEUED": "0", + "VELA_BUILD_EVENT": "", + "VELA_BUILD_EVENT_ACTION": "", + "VELA_BUILD_HOST": "", + "VELA_BUILD_LINK": "", + "VELA_BUILD_MESSAGE": "", + "VELA_BUILD_NUMBER": "0", + "VELA_BUILD_PARENT": "0", + "VELA_BUILD_REF": "", + "VELA_BUILD_RUNTIME": "", + "VELA_BUILD_SENDER": "", + "VELA_BUILD_SOURCE": "", + "VELA_BUILD_STARTED": "0", + "VELA_BUILD_STATUS": "", + "VELA_BUILD_TITLE": "", + "VELA_BUILD_WORKSPACE": "/vela/src", + "VELA_CHANNEL": "TODO", + "VELA_DATABASE": "TODO", + "VELA_DISTRIBUTION": "TODO", + "VELA_HOST": "TODO", + "VELA_NETRC_MACHINE": "TODO", + "VELA_NETRC_PASSWORD": "", + "VELA_NETRC_USERNAME": "x-oauth-basic", + "VELA_QUEUE": "TODO", + "VELA_REPO_ACTIVE": "false", + "VELA_REPO_ALLOW_EVENTS": "", + "VELA_REPO_APPROVE_BUILD": "", + "VELA_REPO_BRANCH": "", + "VELA_REPO_TOPICS": "", + "VELA_REPO_BUILD_LIMIT": "0", + "VELA_REPO_CLONE": "", + "VELA_REPO_FULL_NAME": "", + "VELA_REPO_LINK": "", + "VELA_REPO_NAME": "", + "VELA_REPO_ORG": "", + "VELA_REPO_PIPELINE_TYPE": "", + "VELA_REPO_PRIVATE": "false", + "VELA_REPO_TIMEOUT": "0", + "VELA_REPO_TRUSTED": "false", + "VELA_REPO_VISIBILITY": "", + "VELA_RUNTIME": "TODO", + "VELA_SOURCE": "TODO", + "VELA_USER_ACTIVE": "false", + "VELA_USER_ADMIN": "false", + "VELA_USER_FAVORITES": "[]", + "VELA_USER_NAME": "", + "VELA_VERSION": "TODO", + "VELA_WORKSPACE": "/vela/src", + "HELLO": "Hello, Global Message", }, }, } @@ -452,114 +432,104 @@ func TestNative_EnvironmentSecrets(t *testing.T) { "foo": "bar", }, Environment: raw.StringSliceMap{ - "BUILD_AUTHOR": "", - "BUILD_AUTHOR_EMAIL": "", - "BUILD_BASE_REF": "", - "BUILD_BRANCH": "", - "BUILD_CHANNEL": "TODO", - "BUILD_CLONE": "", - "BUILD_COMMIT": "", - "BUILD_CREATED": "0", - "BUILD_ENQUEUED": "0", - "BUILD_EVENT": "", - "BUILD_HOST": "", - "BUILD_LINK": "", - "BUILD_MESSAGE": "", - "BUILD_NUMBER": "0", - "BUILD_PARENT": "0", - "BUILD_REF": "", - "BUILD_SENDER": "", - "BUILD_SOURCE": "", - "BUILD_STARTED": "0", - "BUILD_STATUS": "", - "BUILD_TITLE": "", - "BUILD_WORKSPACE": "/vela/src", - "CI": "true", - "PARAMETER_FOO": "bar", - "REPOSITORY_ACTIVE": "false", - "REPOSITORY_ALLOW_COMMENT": "false", - "REPOSITORY_ALLOW_DEPLOY": "false", - "REPOSITORY_ALLOW_PULL": "false", - "REPOSITORY_ALLOW_PUSH": "false", - "REPOSITORY_ALLOW_TAG": "false", - "REPOSITORY_ALLOW_EVENTS": "", - "REPOSITORY_BRANCH": "", - "REPOSITORY_CLONE": "", - "REPOSITORY_FULL_NAME": "", - "REPOSITORY_LINK": "", - "REPOSITORY_NAME": "", - "REPOSITORY_ORG": "", - "REPOSITORY_PRIVATE": "false", - "REPOSITORY_TIMEOUT": "0", - "REPOSITORY_TRUSTED": "false", - "REPOSITORY_VISIBILITY": "", - "VELA": "true", - "VELA_ADDR": "TODO", - "VELA_BUILD_APPROVED_AT": "0", - "VELA_BUILD_APPROVED_BY": "", - "VELA_BUILD_AUTHOR": "", - "VELA_BUILD_AUTHOR_EMAIL": "", - "VELA_BUILD_BASE_REF": "", - "VELA_BUILD_BRANCH": "", - "VELA_BUILD_CHANNEL": "TODO", - "VELA_BUILD_CLONE": "", - "VELA_BUILD_COMMIT": "", - "VELA_BUILD_CREATED": "0", - "VELA_BUILD_DISTRIBUTION": "", - "VELA_BUILD_ENQUEUED": "0", - "VELA_BUILD_EVENT": "", - "VELA_BUILD_EVENT_ACTION": "", - "VELA_BUILD_HOST": "", - "VELA_BUILD_LINK": "", - "VELA_BUILD_MESSAGE": "", - "VELA_BUILD_NUMBER": "0", - "VELA_BUILD_PARENT": "0", - "VELA_BUILD_REF": "", - "VELA_BUILD_RUNTIME": "", - "VELA_BUILD_SENDER": "", - "VELA_BUILD_SOURCE": "", - "VELA_BUILD_STARTED": "0", - "VELA_BUILD_STATUS": "", - "VELA_BUILD_TITLE": "", - "VELA_BUILD_WORKSPACE": "/vela/src", - "VELA_CHANNEL": "TODO", - "VELA_DATABASE": "TODO", - "VELA_DISTRIBUTION": "TODO", - "VELA_HOST": "TODO", - "VELA_NETRC_MACHINE": "TODO", - "VELA_NETRC_PASSWORD": "", - "VELA_NETRC_USERNAME": "x-oauth-basic", - "VELA_QUEUE": "TODO", - "VELA_REPO_ACTIVE": "false", - "VELA_REPO_ALLOW_COMMENT": "false", - "VELA_REPO_ALLOW_DEPLOY": "false", - "VELA_REPO_ALLOW_PULL": "false", - "VELA_REPO_ALLOW_PUSH": "false", - "VELA_REPO_ALLOW_TAG": "false", - "VELA_REPO_ALLOW_EVENTS": "", - "VELA_REPO_APPROVE_BUILD": "", - "VELA_REPO_BRANCH": "", - "VELA_REPO_TOPICS": "", - "VELA_REPO_BUILD_LIMIT": "0", - "VELA_REPO_CLONE": "", - "VELA_REPO_FULL_NAME": "", - "VELA_REPO_LINK": "", - "VELA_REPO_NAME": "", - "VELA_REPO_ORG": "", - "VELA_REPO_PIPELINE_TYPE": "", - "VELA_REPO_PRIVATE": "false", - "VELA_REPO_TIMEOUT": "0", - "VELA_REPO_TRUSTED": "false", - "VELA_REPO_VISIBILITY": "", - "VELA_RUNTIME": "TODO", - "VELA_SOURCE": "TODO", - "VELA_USER_ACTIVE": "false", - "VELA_USER_ADMIN": "false", - "VELA_USER_FAVORITES": "[]", - "VELA_USER_NAME": "", - "VELA_VERSION": "TODO", - "VELA_WORKSPACE": "/vela/src", - "HELLO": "Hello, Global Message", + "BUILD_AUTHOR": "", + "BUILD_AUTHOR_EMAIL": "", + "BUILD_BASE_REF": "", + "BUILD_BRANCH": "", + "BUILD_CHANNEL": "TODO", + "BUILD_CLONE": "", + "BUILD_COMMIT": "", + "BUILD_CREATED": "0", + "BUILD_ENQUEUED": "0", + "BUILD_EVENT": "", + "BUILD_HOST": "", + "BUILD_LINK": "", + "BUILD_MESSAGE": "", + "BUILD_NUMBER": "0", + "BUILD_PARENT": "0", + "BUILD_REF": "", + "BUILD_SENDER": "", + "BUILD_SOURCE": "", + "BUILD_STARTED": "0", + "BUILD_STATUS": "", + "BUILD_TITLE": "", + "BUILD_WORKSPACE": "/vela/src", + "CI": "true", + "PARAMETER_FOO": "bar", + "REPOSITORY_ACTIVE": "false", + "REPOSITORY_ALLOW_EVENTS": "", + "REPOSITORY_BRANCH": "", + "REPOSITORY_CLONE": "", + "REPOSITORY_FULL_NAME": "", + "REPOSITORY_LINK": "", + "REPOSITORY_NAME": "", + "REPOSITORY_ORG": "", + "REPOSITORY_PRIVATE": "false", + "REPOSITORY_TIMEOUT": "0", + "REPOSITORY_TRUSTED": "false", + "REPOSITORY_VISIBILITY": "", + "VELA": "true", + "VELA_ADDR": "TODO", + "VELA_BUILD_APPROVED_AT": "0", + "VELA_BUILD_APPROVED_BY": "", + "VELA_BUILD_AUTHOR": "", + "VELA_BUILD_AUTHOR_EMAIL": "", + "VELA_BUILD_BASE_REF": "", + "VELA_BUILD_BRANCH": "", + "VELA_BUILD_CHANNEL": "TODO", + "VELA_BUILD_CLONE": "", + "VELA_BUILD_COMMIT": "", + "VELA_BUILD_CREATED": "0", + "VELA_BUILD_DISTRIBUTION": "", + "VELA_BUILD_ENQUEUED": "0", + "VELA_BUILD_EVENT": "", + "VELA_BUILD_EVENT_ACTION": "", + "VELA_BUILD_HOST": "", + "VELA_BUILD_LINK": "", + "VELA_BUILD_MESSAGE": "", + "VELA_BUILD_NUMBER": "0", + "VELA_BUILD_PARENT": "0", + "VELA_BUILD_REF": "", + "VELA_BUILD_RUNTIME": "", + "VELA_BUILD_SENDER": "", + "VELA_BUILD_SOURCE": "", + "VELA_BUILD_STARTED": "0", + "VELA_BUILD_STATUS": "", + "VELA_BUILD_TITLE": "", + "VELA_BUILD_WORKSPACE": "/vela/src", + "VELA_CHANNEL": "TODO", + "VELA_DATABASE": "TODO", + "VELA_DISTRIBUTION": "TODO", + "VELA_HOST": "TODO", + "VELA_NETRC_MACHINE": "TODO", + "VELA_NETRC_PASSWORD": "", + "VELA_NETRC_USERNAME": "x-oauth-basic", + "VELA_QUEUE": "TODO", + "VELA_REPO_ACTIVE": "false", + "VELA_REPO_ALLOW_EVENTS": "", + "VELA_REPO_APPROVE_BUILD": "", + "VELA_REPO_BRANCH": "", + "VELA_REPO_TOPICS": "", + "VELA_REPO_BUILD_LIMIT": "0", + "VELA_REPO_CLONE": "", + "VELA_REPO_FULL_NAME": "", + "VELA_REPO_LINK": "", + "VELA_REPO_NAME": "", + "VELA_REPO_ORG": "", + "VELA_REPO_PIPELINE_TYPE": "", + "VELA_REPO_PRIVATE": "false", + "VELA_REPO_TIMEOUT": "0", + "VELA_REPO_TRUSTED": "false", + "VELA_REPO_VISIBILITY": "", + "VELA_RUNTIME": "TODO", + "VELA_SOURCE": "TODO", + "VELA_USER_ACTIVE": "false", + "VELA_USER_ADMIN": "false", + "VELA_USER_FAVORITES": "[]", + "VELA_USER_NAME": "", + "VELA_VERSION": "TODO", + "VELA_WORKSPACE": "/vela/src", + "HELLO": "Hello, Global Message", }, }, }, @@ -576,7 +546,7 @@ func TestNative_EnvironmentSecrets(t *testing.T) { t.Errorf("EnvironmentSecrets returned err: %v", err) } - if diff := cmp.Diff(got, want); diff != "" { + if diff := cmp.Diff(want, got); diff != "" { t.Errorf("EnvironmentSecrets mismatch (-want +got):\n%s", diff) } } @@ -615,36 +585,36 @@ func TestNative_environment(t *testing.T) { w: workspace, b: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &push, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &str, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &str, BaseRef: &str}, m: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, u: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "push", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "foo", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "push", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "foo", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "push", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "foo", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "push", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "foo", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, // tag { w: workspace, b: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &tag, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &str, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &tagref, BaseRef: &str}, m: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, u: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "tag", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/tags/1", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TAG": "1", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "tag", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/tags/1", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TAG": "1", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "tag", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/tags/1", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TAG": "1", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "tag", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/tags/1", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TAG": "1", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, // pull_request { w: workspace, b: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &pull, EventAction: &pullact, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &str, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &pullref, BaseRef: &str}, m: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, u: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "pull_request", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_PULL_REQUEST_NUMBER": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "pull_request", "VELA_BUILD_EVENT_ACTION": "opened", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_PULL_REQUEST": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_PULL_REQUEST": "1", "VELA_PULL_REQUEST_SOURCE": "", "VELA_PULL_REQUEST_TARGET": "foo", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "pull_request", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_PULL_REQUEST_NUMBER": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "pull_request", "VELA_BUILD_EVENT_ACTION": "opened", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_PULL_REQUEST": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_PULL_REQUEST": "1", "VELA_PULL_REQUEST_SOURCE": "", "VELA_PULL_REQUEST_TARGET": "foo", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, // deployment { w: workspace, b: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &deploy, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &target, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &pullref, BaseRef: &str}, m: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + r: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, u: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "deployment", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TARGET": "production", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "deployment", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TARGET": "production", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DEPLOYMENT": "production", "VELA_DEPLOYMENT_NUMBER": "0", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + want: map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "deployment", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TARGET": "production", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "deployment", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TARGET": "production", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DEPLOYMENT": "production", "VELA_DEPLOYMENT_NUMBER": "0", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, } @@ -731,29 +701,29 @@ func Test_client_EnvironmentBuild(t *testing.T) { {"push", fields{ build: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &push, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &str, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &str, BaseRef: &str}, metadata: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, user: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "push", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "foo", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "push", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "foo", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}}, + }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "push", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "foo", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "push", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "foo", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}}, {"tag", fields{ build: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &tag, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &str, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &tagref, BaseRef: &str}, metadata: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, user: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "tag", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/tags/1", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TAG": "1", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "tag", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/tags/1", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TAG": "1", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "tag", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/tags/1", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TAG": "1", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "tag", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/tags/1", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TAG": "1", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, {"pull_request", fields{ build: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &pull, EventAction: &pullact, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &str, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &pullref, BaseRef: &str}, metadata: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, user: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "pull_request", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_PULL_REQUEST_NUMBER": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "pull_request", "VELA_BUILD_EVENT_ACTION": "opened", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_PULL_REQUEST": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_PULL_REQUEST": "1", "VELA_PULL_REQUEST_SOURCE": "", "VELA_PULL_REQUEST_TARGET": "foo", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "pull_request", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_PULL_REQUEST_NUMBER": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "pull_request", "VELA_BUILD_EVENT_ACTION": "opened", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_PULL_REQUEST": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_PULL_REQUEST": "1", "VELA_PULL_REQUEST_SOURCE": "", "VELA_PULL_REQUEST_TARGET": "foo", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, {"deployment", fields{ build: &library.Build{ID: &num64, RepoID: &num64, Number: &num, Parent: &num, Event: &deploy, Status: &str, Error: &str, Enqueued: &num64, Created: &num64, Started: &num64, Finished: &num64, Deploy: &target, Clone: &str, Source: &str, Title: &str, Message: &str, Commit: &str, Sender: &str, Author: &str, Branch: &str, Ref: &pullref, BaseRef: &str}, metadata: &types.Metadata{Database: &types.Database{Driver: str, Host: str}, Queue: &types.Queue{Channel: str, Driver: str, Host: str}, Source: &types.Source{Driver: str, Host: str}, Vela: &types.Vela{Address: str, WebAddress: str}}, - repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL, AllowPull: &booL, AllowPush: &booL, AllowDeploy: &booL, AllowTag: &booL, AllowComment: &booL}, + repo: &library.Repo{ID: &num64, UserID: &num64, Org: &str, Name: &str, FullName: &str, Link: &str, Clone: &str, Branch: &str, Topics: &topics, BuildLimit: &num64, Timeout: &num64, Visibility: &str, Private: &booL, Trusted: &booL, Active: &booL}, user: &library.User{ID: &num64, Name: &str, Token: &str, Active: &booL, Admin: &booL}, - }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "deployment", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TARGET": "production", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_COMMENT": "false", "REPOSITORY_ALLOW_DEPLOY": "false", "REPOSITORY_ALLOW_PULL": "false", "REPOSITORY_ALLOW_PUSH": "false", "REPOSITORY_ALLOW_TAG": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "deployment", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TARGET": "production", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DEPLOYMENT": "production", "VELA_DEPLOYMENT_NUMBER": "0", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_COMMENT": "false", "VELA_REPO_ALLOW_DEPLOY": "false", "VELA_REPO_ALLOW_PULL": "false", "VELA_REPO_ALLOW_PUSH": "false", "VELA_REPO_ALLOW_TAG": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, + }, map[string]string{"BUILD_AUTHOR": "foo", "BUILD_AUTHOR_EMAIL": "", "BUILD_BASE_REF": "foo", "BUILD_BRANCH": "foo", "BUILD_CHANNEL": "foo", "BUILD_CLONE": "foo", "BUILD_COMMIT": "foo", "BUILD_CREATED": "1", "BUILD_ENQUEUED": "1", "BUILD_EVENT": "deployment", "BUILD_HOST": "", "BUILD_LINK": "", "BUILD_MESSAGE": "foo", "BUILD_NUMBER": "1", "BUILD_PARENT": "1", "BUILD_REF": "refs/pull/1/head", "BUILD_SENDER": "foo", "BUILD_SOURCE": "foo", "BUILD_STARTED": "1", "BUILD_STATUS": "foo", "BUILD_TARGET": "production", "BUILD_TITLE": "foo", "BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "CI": "true", "REPOSITORY_ACTIVE": "false", "REPOSITORY_ALLOW_EVENTS": "", "REPOSITORY_BRANCH": "foo", "REPOSITORY_CLONE": "foo", "REPOSITORY_FULL_NAME": "foo", "REPOSITORY_LINK": "foo", "REPOSITORY_NAME": "foo", "REPOSITORY_ORG": "foo", "REPOSITORY_PRIVATE": "false", "REPOSITORY_TIMEOUT": "1", "REPOSITORY_TRUSTED": "false", "REPOSITORY_VISIBILITY": "foo", "VELA": "true", "VELA_ADDR": "foo", "VELA_BUILD_APPROVED_AT": "0", "VELA_BUILD_APPROVED_BY": "", "VELA_BUILD_AUTHOR": "foo", "VELA_BUILD_AUTHOR_EMAIL": "", "VELA_BUILD_BASE_REF": "foo", "VELA_BUILD_BRANCH": "foo", "VELA_BUILD_CHANNEL": "foo", "VELA_BUILD_CLONE": "foo", "VELA_BUILD_COMMIT": "foo", "VELA_BUILD_CREATED": "1", "VELA_BUILD_DISTRIBUTION": "", "VELA_BUILD_ENQUEUED": "1", "VELA_BUILD_EVENT": "deployment", "VELA_BUILD_EVENT_ACTION": "", "VELA_BUILD_HOST": "", "VELA_BUILD_LINK": "", "VELA_BUILD_MESSAGE": "foo", "VELA_BUILD_NUMBER": "1", "VELA_BUILD_PARENT": "1", "VELA_BUILD_REF": "refs/pull/1/head", "VELA_BUILD_RUNTIME": "", "VELA_BUILD_SENDER": "foo", "VELA_BUILD_SOURCE": "foo", "VELA_BUILD_STARTED": "1", "VELA_BUILD_STATUS": "foo", "VELA_BUILD_TARGET": "production", "VELA_BUILD_TITLE": "foo", "VELA_BUILD_WORKSPACE": "/vela/src/foo/foo/foo", "VELA_CHANNEL": "foo", "VELA_DATABASE": "foo", "VELA_DEPLOYMENT": "production", "VELA_DEPLOYMENT_NUMBER": "0", "VELA_DISTRIBUTION": "TODO", "VELA_HOST": "foo", "VELA_NETRC_MACHINE": "foo", "VELA_NETRC_PASSWORD": "foo", "VELA_NETRC_USERNAME": "x-oauth-basic", "VELA_QUEUE": "foo", "VELA_REPO_ACTIVE": "false", "VELA_REPO_ALLOW_EVENTS": "", "VELA_REPO_APPROVE_BUILD": "", "VELA_REPO_BRANCH": "foo", "VELA_REPO_BUILD_LIMIT": "1", "VELA_REPO_CLONE": "foo", "VELA_REPO_FULL_NAME": "foo", "VELA_REPO_LINK": "foo", "VELA_REPO_NAME": "foo", "VELA_REPO_ORG": "foo", "VELA_REPO_PIPELINE_TYPE": "", "VELA_REPO_PRIVATE": "false", "VELA_REPO_TIMEOUT": "1", "VELA_REPO_TOPICS": "cloud,security", "VELA_REPO_TRUSTED": "false", "VELA_REPO_VISIBILITY": "foo", "VELA_RUNTIME": "TODO", "VELA_SOURCE": "foo", "VELA_USER_ACTIVE": "false", "VELA_USER_ADMIN": "false", "VELA_USER_FAVORITES": "[]", "VELA_USER_NAME": "foo", "VELA_VERSION": "TODO", "VELA_WORKSPACE": "/vela/src/foo/foo/foo"}, }, } for _, tt := range tests { diff --git a/database/build/build_test.go b/database/build/build_test.go index 2478b2ded..16910e5ac 100644 --- a/database/build/build_test.go +++ b/database/build/build_test.go @@ -261,11 +261,6 @@ func testRepo() *library.Repo { Private: new(bool), Trusted: new(bool), Active: new(bool), - AllowPull: new(bool), - AllowPush: new(bool), - AllowDeploy: new(bool), - AllowTag: new(bool), - AllowComment: new(bool), } } diff --git a/database/deployment/deployment_test.go b/database/deployment/deployment_test.go index 4421f4f9d..0184fbcce 100644 --- a/database/deployment/deployment_test.go +++ b/database/deployment/deployment_test.go @@ -208,10 +208,5 @@ func testRepo() *library.Repo { Private: new(bool), Trusted: new(bool), Active: new(bool), - AllowPull: new(bool), - AllowPush: new(bool), - AllowDeploy: new(bool), - AllowTag: new(bool), - AllowComment: new(bool), } } diff --git a/database/hook/hook_test.go b/database/hook/hook_test.go index 4aaeb6a93..fd358715f 100644 --- a/database/hook/hook_test.go +++ b/database/hook/hook_test.go @@ -207,10 +207,5 @@ func testRepo() *library.Repo { Private: new(bool), Trusted: new(bool), Active: new(bool), - AllowPull: new(bool), - AllowPush: new(bool), - AllowDeploy: new(bool), - AllowTag: new(bool), - AllowComment: new(bool), } } diff --git a/database/integration_test.go b/database/integration_test.go index ce35d1ec8..0bde55005 100644 --- a/database/integration_test.go +++ b/database/integration_test.go @@ -2239,11 +2239,6 @@ func newResources() *Resources { repoOne.SetPrivate(false) repoOne.SetTrusted(false) repoOne.SetActive(true) - repoOne.SetAllowPull(false) - repoOne.SetAllowPush(true) - repoOne.SetAllowDeploy(false) - repoOne.SetAllowTag(false) - repoOne.SetAllowComment(false) repoOne.SetPipelineType("") repoOne.SetPreviousName("") repoOne.SetApproveBuild(constants.ApproveNever) @@ -2267,11 +2262,6 @@ func newResources() *Resources { repoTwo.SetPrivate(false) repoTwo.SetTrusted(false) repoTwo.SetActive(true) - repoTwo.SetAllowPull(false) - repoTwo.SetAllowPush(true) - repoTwo.SetAllowDeploy(false) - repoTwo.SetAllowTag(false) - repoTwo.SetAllowComment(false) repoTwo.SetPipelineType("") repoTwo.SetPreviousName("") repoTwo.SetApproveBuild(constants.ApproveForkAlways) @@ -2312,7 +2302,6 @@ func newResources() *Resources { secretOrg.SetValue("bar") secretOrg.SetType("org") secretOrg.SetImages([]string{"alpine"}) - secretOrg.SetEvents([]string{"push", "tag", "deployment"}) secretOrg.SetAllowEvents(library.NewEventsFromMask(1)) secretOrg.SetAllowCommand(true) secretOrg.SetAllowSubstitution(true) @@ -2330,7 +2319,6 @@ func newResources() *Resources { secretRepo.SetValue("bar") secretRepo.SetType("repo") secretRepo.SetImages([]string{"alpine"}) - secretRepo.SetEvents([]string{"push", "tag", "deployment"}) secretRepo.SetAllowEvents(library.NewEventsFromMask(1)) secretRepo.SetAllowCommand(true) secretRepo.SetAllowSubstitution(true) @@ -2348,7 +2336,6 @@ func newResources() *Resources { secretShared.SetValue("bar") secretShared.SetType("shared") secretShared.SetImages([]string{"alpine"}) - secretShared.SetEvents([]string{"push", "tag", "deployment"}) secretShared.SetAllowCommand(true) secretShared.SetAllowSubstitution(true) secretShared.SetAllowEvents(library.NewEventsFromMask(1)) diff --git a/database/repo/create_test.go b/database/repo/create_test.go index 189622744..1a523b563 100644 --- a/database/repo/create_test.go +++ b/database/repo/create_test.go @@ -32,9 +32,9 @@ func TestRepo_Engine_CreateRepo(t *testing.T) { // ensure the mock expects the query _mock.ExpectQuery(`INSERT INTO "repos" -("user_id","hash","org","name","full_name","link","clone","branch","topics","build_limit","timeout","counter","visibility","private","trusted","active","allow_pull","allow_push","allow_deploy","allow_tag","allow_comment","allow_events","pipeline_type","previous_name","approve_build","id") -VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26) RETURNING "id"`). - WithArgs(1, AnyArgument{}, "foo", "bar", "foo/bar", nil, nil, nil, AnyArgument{}, AnyArgument{}, AnyArgument{}, AnyArgument{}, "public", false, false, false, false, false, false, false, false, nil, "yaml", "oldName", nil, 1). +("user_id","hash","org","name","full_name","link","clone","branch","topics","build_limit","timeout","counter","visibility","private","trusted","active","allow_events","pipeline_type","previous_name","approve_build","id") +VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21) RETURNING "id"`). + WithArgs(1, AnyArgument{}, "foo", "bar", "foo/bar", nil, nil, nil, AnyArgument{}, AnyArgument{}, AnyArgument{}, AnyArgument{}, "public", false, false, false, nil, "yaml", "oldName", nil, 1). WillReturnRows(_rows) _sqlite := testSqlite(t) diff --git a/database/repo/get_org_test.go b/database/repo/get_org_test.go index 95e6d6a32..db5b36314 100644 --- a/database/repo/get_org_test.go +++ b/database/repo/get_org_test.go @@ -30,8 +30,8 @@ func TestRepo_Engine_GetRepoForOrg(t *testing.T) { // create expected result in mock _rows := sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "build_limit", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", "", "") + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "build_limit", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, 0, "public", false, false, false, 1, "yaml", "", "") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "repos" WHERE org = $1 AND name = $2 LIMIT $3`).WithArgs("foo", "bar", 1).WillReturnRows(_rows) diff --git a/database/repo/get_test.go b/database/repo/get_test.go index 7a4fcdba8..3957975d2 100644 --- a/database/repo/get_test.go +++ b/database/repo/get_test.go @@ -30,8 +30,8 @@ func TestRepo_Engine_GetRepo(t *testing.T) { // create expected result in mock _rows := sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "build_limit", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", "", "") + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "build_limit", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, 0, "public", false, false, false, 1, "yaml", "", "") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "repos" WHERE id = $1 LIMIT $2`).WithArgs(1, 1).WillReturnRows(_rows) diff --git a/database/repo/list_org_test.go b/database/repo/list_org_test.go index 5d6bfb99f..e59e29d49 100644 --- a/database/repo/list_org_test.go +++ b/database/repo/list_org_test.go @@ -63,9 +63,9 @@ func TestRepo_Engine_ListReposForOrg(t *testing.T) { // create expected name query result in mock _rows = sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil). - AddRow(2, 1, "bar", "foo", "baz", "foo/baz", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil) + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil). + AddRow(2, 1, "bar", "foo", "baz", "foo/baz", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil) // ensure the mock expects the name query _mock.ExpectQuery(`SELECT * FROM "repos" WHERE org = $1 ORDER BY name LIMIT $2`).WithArgs("foo", 10).WillReturnRows(_rows) @@ -78,9 +78,9 @@ func TestRepo_Engine_ListReposForOrg(t *testing.T) { // create expected latest query result in mock _rows = sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil). - AddRow(2, 1, "bar", "foo", "baz", "foo/baz", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil) + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil). + AddRow(2, 1, "bar", "foo", "baz", "foo/baz", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil) // ensure the mock expects the latest query _mock.ExpectQuery(`SELECT repos.* FROM "repos" LEFT JOIN (SELECT repos.id, MAX(builds.created) AS latest_build FROM "builds" INNER JOIN repos repos ON builds.repo_id = repos.id WHERE repos.org = $1 GROUP BY "repos"."id") t on repos.id = t.id ORDER BY latest_build DESC NULLS LAST LIMIT $2`).WithArgs("foo", 10).WillReturnRows(_rows) diff --git a/database/repo/list_test.go b/database/repo/list_test.go index 793123257..7b3a5ff5e 100644 --- a/database/repo/list_test.go +++ b/database/repo/list_test.go @@ -48,9 +48,9 @@ func TestRepo_Engine_ListRepos(t *testing.T) { // create expected result in mock _rows = sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil). - AddRow(2, 1, "baz", "bar", "foo", "bar/foo", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil) + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil). + AddRow(2, 1, "baz", "bar", "foo", "bar/foo", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil) // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "repos"`).WillReturnRows(_rows) diff --git a/database/repo/list_user_test.go b/database/repo/list_user_test.go index a387c4e5a..30f6bc3b1 100644 --- a/database/repo/list_user_test.go +++ b/database/repo/list_user_test.go @@ -68,9 +68,9 @@ func TestRepo_Engine_ListReposForUser(t *testing.T) { // create expected name query result in mock _rows = sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil). - AddRow(2, 1, "baz", "bar", "foo", "bar/foo", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil) + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil). + AddRow(2, 1, "baz", "bar", "foo", "bar/foo", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil) // ensure the mock expects the name query _mock.ExpectQuery(`SELECT * FROM "repos" WHERE user_id = $1 ORDER BY name LIMIT $2`).WithArgs(1, 10).WillReturnRows(_rows) @@ -83,9 +83,9 @@ func TestRepo_Engine_ListReposForUser(t *testing.T) { // create expected latest query result in mock _rows = sqlmock.NewRows( - []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_pull", "allow_push", "allow_deploy", "allow_tag", "allow_comment", "allow_events", "pipeline_type", "previous_name", "approve_build"}). - AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil). - AddRow(2, 1, "baz", "bar", "foo", "bar/foo", "", "", "", "{}", 0, 0, "public", false, false, false, false, false, false, false, false, 1, "yaml", nil, nil) + []string{"id", "user_id", "hash", "org", "name", "full_name", "link", "clone", "branch", "topics", "timeout", "counter", "visibility", "private", "trusted", "active", "allow_events", "pipeline_type", "previous_name", "approve_build"}). + AddRow(1, 1, "baz", "foo", "bar", "foo/bar", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil). + AddRow(2, 1, "baz", "bar", "foo", "bar/foo", "", "", "", "{}", 0, 0, "public", false, false, false, 1, "yaml", nil, nil) // ensure the mock expects the latest query _mock.ExpectQuery(`SELECT repos.* FROM "repos" LEFT JOIN (SELECT repos.id, MAX(builds.created) AS latest_build FROM "builds" INNER JOIN repos repos ON builds.repo_id = repos.id WHERE repos.user_id = $1 GROUP BY "repos"."id") t on repos.id = t.id ORDER BY latest_build DESC NULLS LAST LIMIT $2`).WithArgs(1, 10).WillReturnRows(_rows) diff --git a/database/repo/repo_test.go b/database/repo/repo_test.go index 597ef1623..325732a56 100644 --- a/database/repo/repo_test.go +++ b/database/repo/repo_test.go @@ -194,11 +194,6 @@ func testRepo() *library.Repo { Private: new(bool), Trusted: new(bool), Active: new(bool), - AllowPull: new(bool), - AllowPush: new(bool), - AllowDeploy: new(bool), - AllowTag: new(bool), - AllowComment: new(bool), AllowEvents: testEvents(), } } diff --git a/database/repo/table.go b/database/repo/table.go index e0f26a6c3..a7877d280 100644 --- a/database/repo/table.go +++ b/database/repo/table.go @@ -31,11 +31,6 @@ repos ( private BOOLEAN, trusted BOOLEAN, active BOOLEAN, - allow_pull BOOLEAN, - allow_push BOOLEAN, - allow_deploy BOOLEAN, - allow_tag BOOLEAN, - allow_comment BOOLEAN, allow_events INTEGER, pipeline_type TEXT, previous_name VARCHAR(100), @@ -66,11 +61,6 @@ repos ( private BOOLEAN, trusted BOOLEAN, active BOOLEAN, - allow_pull BOOLEAN, - allow_push BOOLEAN, - allow_deploy BOOLEAN, - allow_tag BOOLEAN, - allow_comment BOOLEAN, allow_events INTEGER, pipeline_type TEXT, previous_name TEXT, diff --git a/database/repo/update_test.go b/database/repo/update_test.go index bf791a30d..c7bca1d15 100644 --- a/database/repo/update_test.go +++ b/database/repo/update_test.go @@ -33,9 +33,9 @@ func TestRepo_Engine_UpdateRepo(t *testing.T) { // ensure the mock expects the query _mock.ExpectExec(`UPDATE "repos" -SET "user_id"=$1,"hash"=$2,"org"=$3,"name"=$4,"full_name"=$5,"link"=$6,"clone"=$7,"branch"=$8,"topics"=$9,"build_limit"=$10,"timeout"=$11,"counter"=$12,"visibility"=$13,"private"=$14,"trusted"=$15,"active"=$16,"allow_pull"=$17,"allow_push"=$18,"allow_deploy"=$19,"allow_tag"=$20,"allow_comment"=$21,"allow_events"=$22,"pipeline_type"=$23,"previous_name"=$24,"approve_build"=$25 -WHERE "id" = $26`). - WithArgs(1, AnyArgument{}, "foo", "bar", "foo/bar", nil, nil, nil, AnyArgument{}, AnyArgument{}, AnyArgument{}, AnyArgument{}, "public", false, false, false, false, false, false, false, false, 1, "yaml", "oldName", constants.ApproveForkAlways, 1). +SET "user_id"=$1,"hash"=$2,"org"=$3,"name"=$4,"full_name"=$5,"link"=$6,"clone"=$7,"branch"=$8,"topics"=$9,"build_limit"=$10,"timeout"=$11,"counter"=$12,"visibility"=$13,"private"=$14,"trusted"=$15,"active"=$16,"allow_events"=$17,"pipeline_type"=$18,"previous_name"=$19,"approve_build"=$20 +WHERE "id" = $21`). + WithArgs(1, AnyArgument{}, "foo", "bar", "foo/bar", nil, nil, nil, AnyArgument{}, AnyArgument{}, AnyArgument{}, AnyArgument{}, "public", false, false, false, 1, "yaml", "oldName", constants.ApproveForkAlways, 1). WillReturnResult(sqlmock.NewResult(1, 1)) _sqlite := testSqlite(t) diff --git a/database/schedule/schedule_test.go b/database/schedule/schedule_test.go index d676223a1..723c40aaa 100644 --- a/database/schedule/schedule_test.go +++ b/database/schedule/schedule_test.go @@ -210,11 +210,6 @@ func testRepo() *library.Repo { Private: new(bool), Trusted: new(bool), Active: new(bool), - AllowPull: new(bool), - AllowPush: new(bool), - AllowDeploy: new(bool), - AllowTag: new(bool), - AllowComment: new(bool), } } diff --git a/database/secret/create_test.go b/database/secret/create_test.go index eeec4c363..210a57b99 100644 --- a/database/secret/create_test.go +++ b/database/secret/create_test.go @@ -60,23 +60,23 @@ func TestSecret_Engine_CreateSecret(t *testing.T) { // ensure the mock expects the repo secrets query _mock.ExpectQuery(`INSERT INTO "secrets" -("org","repo","team","name","value","type","images","events","allow_events","allow_command","allow_substitution","created_at","created_by","updated_at","updated_by","id") -VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16) RETURNING "id"`). - WithArgs("foo", "bar", nil, "baz", AnyArgument{}, "repo", nil, nil, 1, false, false, 1, "user", 1, "user2", 1). +("org","repo","team","name","value","type","images","allow_events","allow_command","allow_substitution","created_at","created_by","updated_at","updated_by","id") +VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15) RETURNING "id"`). + WithArgs("foo", "bar", nil, "baz", AnyArgument{}, "repo", nil, 1, false, false, 1, "user", 1, "user2", 1). WillReturnRows(_rows) // ensure the mock expects the org secrets query _mock.ExpectQuery(`INSERT INTO "secrets" -("org","repo","team","name","value","type","images","events","allow_events","allow_command","allow_substitution","created_at","created_by","updated_at","updated_by","id") -VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16) RETURNING "id"`). - WithArgs("foo", "*", nil, "bar", AnyArgument{}, "org", nil, nil, 3, false, false, 1, "user", 1, "user2", 2). +("org","repo","team","name","value","type","images","allow_events","allow_command","allow_substitution","created_at","created_by","updated_at","updated_by","id") +VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15) RETURNING "id"`). + WithArgs("foo", "*", nil, "bar", AnyArgument{}, "org", nil, 3, false, false, 1, "user", 1, "user2", 2). WillReturnRows(_rows) // ensure the mock expects the shared secrets query _mock.ExpectQuery(`INSERT INTO "secrets" -("org","repo","team","name","value","type","images","events","allow_events","allow_command","allow_substitution","created_at","created_by","updated_at","updated_by","id") -VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16) RETURNING "id"`). - WithArgs("foo", nil, "bar", "baz", AnyArgument{}, "shared", nil, nil, 1, false, false, 1, "user", 1, "user2", 3). +("org","repo","team","name","value","type","images","allow_events","allow_command","allow_substitution","created_at","created_by","updated_at","updated_by","id") +VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15) RETURNING "id"`). + WithArgs("foo", nil, "bar", "baz", AnyArgument{}, "shared", nil, 1, false, false, 1, "user", 1, "user2", 3). WillReturnRows(_rows) _sqlite := testSqlite(t) diff --git a/database/secret/get_org_test.go b/database/secret/get_org_test.go index 840fa2f91..51ca298d2 100644 --- a/database/secret/get_org_test.go +++ b/database/secret/get_org_test.go @@ -32,8 +32,8 @@ func TestSecret_Engine_GetSecretForOrg(t *testing.T) { // create expected result in mock _rows := sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(1, "org", "foo", "*", "", "baz", "bar", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(1, "org", "foo", "*", "", "baz", "bar", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 AND name = $3 LIMIT $4`). diff --git a/database/secret/get_repo_test.go b/database/secret/get_repo_test.go index c4ed2c472..d32f81cc0 100644 --- a/database/secret/get_repo_test.go +++ b/database/secret/get_repo_test.go @@ -42,8 +42,8 @@ func TestSecret_Engine_GetSecretForRepo(t *testing.T) { // create expected result in mock _rows := sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 AND repo = $3 AND name = $4 LIMIT $5`). diff --git a/database/secret/get_team_test.go b/database/secret/get_team_test.go index a39012c26..f34e6f2b6 100644 --- a/database/secret/get_team_test.go +++ b/database/secret/get_team_test.go @@ -32,8 +32,8 @@ func TestSecret_Engine_GetSecretForTeam(t *testing.T) { // create expected result in mock _rows := sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(1, "shared", "foo", "", "bar", "baz", "foob", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(1, "shared", "foo", "", "bar", "baz", "foob", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 AND team = $3 AND name = $4 LIMIT $5`). diff --git a/database/secret/get_test.go b/database/secret/get_test.go index 8b8d4d9c5..16e456c12 100644 --- a/database/secret/get_test.go +++ b/database/secret/get_test.go @@ -31,8 +31,8 @@ func TestSecret_Engine_GetSecret(t *testing.T) { // create expected result in mock _rows := sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE id = $1 LIMIT $2`).WithArgs(1, 1).WillReturnRows(_rows) diff --git a/database/secret/list_org_test.go b/database/secret/list_org_test.go index 024d7a05a..14493ef38 100644 --- a/database/secret/list_org_test.go +++ b/database/secret/list_org_test.go @@ -52,9 +52,9 @@ func TestSecret_Engine_ListSecretsForOrg(t *testing.T) { // create expected name query result in mock _rows = sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(2, "org", "foo", "*", "", "bar", "baz", nil, nil, 1, false, false, 1, "user", 1, "user2"). - AddRow(1, "org", "foo", "*", "", "baz", "bar", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(2, "org", "foo", "*", "", "bar", "baz", nil, 1, false, false, 1, "user", 1, "user2"). + AddRow(1, "org", "foo", "*", "", "baz", "bar", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the name query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 ORDER BY id DESC LIMIT $3`). diff --git a/database/secret/list_repo_test.go b/database/secret/list_repo_test.go index eb97e4c52..9fc76e7bf 100644 --- a/database/secret/list_repo_test.go +++ b/database/secret/list_repo_test.go @@ -63,9 +63,9 @@ func TestSecret_Engine_ListSecretsForRepo(t *testing.T) { // create expected name query result in mock _rows = sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(2, "repo", "foo", "bar", "", "foob", "baz", nil, nil, 1, false, false, 1, "user", 1, "user2"). - AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(2, "repo", "foo", "bar", "", "foob", "baz", nil, 1, false, false, 1, "user", 1, "user2"). + AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the name query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 AND repo = $3 ORDER BY id DESC LIMIT $4`). diff --git a/database/secret/list_team_test.go b/database/secret/list_team_test.go index fd925935e..89b40b237 100644 --- a/database/secret/list_team_test.go +++ b/database/secret/list_team_test.go @@ -53,9 +53,9 @@ func TestSecret_Engine_ListSecretsForTeam(t *testing.T) { // create expected name query result in mock _rows = sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(2, "shared", "foo", "", "bar", "foob", "baz", nil, nil, 1, false, false, 1, "user", 1, "user2"). - AddRow(1, "shared", "foo", "", "bar", "baz", "foob", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(2, "shared", "foo", "", "bar", "foob", "baz", nil, 1, false, false, 1, "user", 1, "user2"). + AddRow(1, "shared", "foo", "", "bar", "baz", "foob", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the name query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 AND team = $3 ORDER BY id DESC LIMIT $4`). @@ -134,6 +134,7 @@ func TestSecret_Engine_ListSecretsForTeams(t *testing.T) { _secretOne.SetCreatedBy("user") _secretOne.SetUpdatedAt(1) _secretOne.SetUpdatedBy("user2") + _secretOne.SetAllowEvents(library.NewEventsFromMask(1)) _secretTwo := testSecret() _secretTwo.SetID(2) @@ -146,6 +147,7 @@ func TestSecret_Engine_ListSecretsForTeams(t *testing.T) { _secretTwo.SetCreatedBy("user") _secretTwo.SetUpdatedAt(1) _secretTwo.SetUpdatedBy("user2") + _secretTwo.SetAllowEvents(library.NewEventsFromMask(1)) _postgres, _mock := testPostgres(t) defer func() { _sql, _ := _postgres.client.DB(); _sql.Close() }() @@ -159,9 +161,9 @@ func TestSecret_Engine_ListSecretsForTeams(t *testing.T) { // create expected name query result in mock _rows = sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_command", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(2, "shared", "foo", "", "bar", "foob", "baz", nil, nil, false, 1, "user", 1, "user2"). - AddRow(1, "shared", "foo", "", "bar", "baz", "foob", nil, nil, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(2, "shared", "foo", "", "bar", "foob", "baz", nil, 1, false, 1, "user", 1, "user2"). + AddRow(1, "shared", "foo", "", "bar", "baz", "foob", nil, 1, false, 1, "user", 1, "user2") // ensure the mock expects the name query _mock.ExpectQuery(`SELECT * FROM "secrets" WHERE type = $1 AND org = $2 AND LOWER(team) IN ($3,$4) ORDER BY id DESC LIMIT $5`). diff --git a/database/secret/list_test.go b/database/secret/list_test.go index a1a0e9e38..c050d452d 100644 --- a/database/secret/list_test.go +++ b/database/secret/list_test.go @@ -50,9 +50,9 @@ func TestSecret_Engine_ListSecrets(t *testing.T) { // create expected result in mock _rows = sqlmock.NewRows( - []string{"id", "type", "org", "repo", "team", "name", "value", "images", "events", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). - AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, nil, 1, false, false, 1, "user", 1, "user2"). - AddRow(2, "repo", "foo", "bar", "", "foob", "baz", nil, nil, 1, false, false, 1, "user", 1, "user2") + []string{"id", "type", "org", "repo", "team", "name", "value", "images", "allow_events", "allow_command", "allow_substitution", "created_at", "created_by", "updated_at", "updated_by"}). + AddRow(1, "repo", "foo", "bar", "", "baz", "foob", nil, 1, false, false, 1, "user", 1, "user2"). + AddRow(2, "repo", "foo", "bar", "", "foob", "baz", nil, 1, false, false, 1, "user", 1, "user2") // ensure the mock expects the query _mock.ExpectQuery(`SELECT * FROM "secrets"`).WillReturnRows(_rows) diff --git a/database/secret/secret_test.go b/database/secret/secret_test.go index e4b74ec9a..160f208cb 100644 --- a/database/secret/secret_test.go +++ b/database/secret/secret_test.go @@ -198,11 +198,6 @@ func testRepo() *library.Repo { Private: new(bool), Trusted: new(bool), Active: new(bool), - AllowPull: new(bool), - AllowPush: new(bool), - AllowDeploy: new(bool), - AllowTag: new(bool), - AllowComment: new(bool), } } @@ -218,7 +213,6 @@ func testSecret() *library.Secret { Value: new(string), Type: new(string), Images: new([]string), - Events: new([]string), AllowEvents: testEvents(), AllowCommand: new(bool), AllowSubstitution: new(bool), diff --git a/database/secret/table.go b/database/secret/table.go index 67fd6b8b9..07b84fee8 100644 --- a/database/secret/table.go +++ b/database/secret/table.go @@ -22,7 +22,6 @@ secrets ( name VARCHAR(250), value BYTEA, images VARCHAR(1000), - events VARCHAR(1000), allow_events INTEGER, allow_command BOOLEAN, allow_substitution BOOLEAN, @@ -48,7 +47,6 @@ secrets ( name TEXT, value TEXT, images TEXT, - events TEXT, allow_events INTEGER, allow_command BOOLEAN, allow_substitution BOOLEAN, diff --git a/database/secret/update_test.go b/database/secret/update_test.go index 5797471f2..0502de911 100644 --- a/database/secret/update_test.go +++ b/database/secret/update_test.go @@ -57,23 +57,23 @@ func TestSecret_Engine_UpdateSecret(t *testing.T) { // ensure the mock expects the repo query _mock.ExpectExec(`UPDATE "secrets" -SET "org"=$1,"repo"=$2,"team"=$3,"name"=$4,"value"=$5,"type"=$6,"images"=$7,"events"=$8,"allow_events"=$9,"allow_command"=$10,"allow_substitution"=$11,"created_at"=$12,"created_by"=$13,"updated_at"=$14,"updated_by"=$15 -WHERE "id" = $16`). - WithArgs("foo", "bar", nil, "baz", AnyArgument{}, "repo", nil, nil, 1, false, false, 1, "user", AnyArgument{}, "user2", 1). +SET "org"=$1,"repo"=$2,"team"=$3,"name"=$4,"value"=$5,"type"=$6,"images"=$7,"allow_events"=$8,"allow_command"=$9,"allow_substitution"=$10,"created_at"=$11,"created_by"=$12,"updated_at"=$13,"updated_by"=$14 +WHERE "id" = $15`). + WithArgs("foo", "bar", nil, "baz", AnyArgument{}, "repo", nil, 1, false, false, 1, "user", AnyArgument{}, "user2", 1). WillReturnResult(sqlmock.NewResult(1, 1)) // ensure the mock expects the org query _mock.ExpectExec(`UPDATE "secrets" -SET "org"=$1,"repo"=$2,"team"=$3,"name"=$4,"value"=$5,"type"=$6,"images"=$7,"events"=$8,"allow_events"=$9,"allow_command"=$10,"allow_substitution"=$11,"created_at"=$12,"created_by"=$13,"updated_at"=$14,"updated_by"=$15 -WHERE "id" = $16`). - WithArgs("foo", "*", nil, "bar", AnyArgument{}, "org", nil, nil, 1, false, false, 1, "user", AnyArgument{}, "user2", 2). +SET "org"=$1,"repo"=$2,"team"=$3,"name"=$4,"value"=$5,"type"=$6,"images"=$7,"allow_events"=$8,"allow_command"=$9,"allow_substitution"=$10,"created_at"=$11,"created_by"=$12,"updated_at"=$13,"updated_by"=$14 +WHERE "id" = $15`). + WithArgs("foo", "*", nil, "bar", AnyArgument{}, "org", nil, 1, false, false, 1, "user", AnyArgument{}, "user2", 2). WillReturnResult(sqlmock.NewResult(1, 1)) // ensure the mock expects the shared query _mock.ExpectExec(`UPDATE "secrets" -SET "org"=$1,"repo"=$2,"team"=$3,"name"=$4,"value"=$5,"type"=$6,"images"=$7,"events"=$8,"allow_events"=$9,"allow_command"=$10,"allow_substitution"=$11,"created_at"=$12,"created_by"=$13,"updated_at"=$14,"updated_by"=$15 -WHERE "id" = $16`). - WithArgs("foo", nil, "bar", "baz", AnyArgument{}, "shared", nil, nil, 1, false, false, 1, "user", NowTimestamp{}, "user2", 3). +SET "org"=$1,"repo"=$2,"team"=$3,"name"=$4,"value"=$5,"type"=$6,"images"=$7,"allow_events"=$8,"allow_command"=$9,"allow_substitution"=$10,"created_at"=$11,"created_by"=$12,"updated_at"=$13,"updated_by"=$14 +WHERE "id" = $15`). + WithArgs("foo", nil, "bar", "baz", AnyArgument{}, "shared", nil, 1, false, false, 1, "user", NowTimestamp{}, "user2", 3). WillReturnResult(sqlmock.NewResult(1, 1)) _sqlite := testSqlite(t) diff --git a/go.mod b/go.mod index eb4191a8d..681104cdc 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/drone/envsubst v1.0.3 github.com/gin-gonic/gin v1.9.1 github.com/go-playground/assert/v2 v2.2.0 - github.com/go-vela/types v0.23.4-0.20240326211542-476edfa844f0 + github.com/go-vela/types v0.23.4-0.20240401132228-9b43c701ab32 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v59 v59.0.0 diff --git a/go.sum b/go.sum index 7e6377fa8..a956a83fd 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-vela/types v0.23.4-0.20240326211542-476edfa844f0 h1:CR/lM4nzDoQ1wKDa9aJGnlZHkx94m170t9NKyCjV9NA= -github.com/go-vela/types v0.23.4-0.20240326211542-476edfa844f0/go.mod h1:mEF9dLkk00rUXf/t39n2WvXZgJbxnPEEWy+DHqIlRUo= +github.com/go-vela/types v0.23.4-0.20240401132228-9b43c701ab32 h1:fqmNnM1LdH3Zg1zCADfgR7a51EOSZvLFAB2Em4CG+Pg= +github.com/go-vela/types v0.23.4-0.20240401132228-9b43c701ab32/go.mod h1:mEF9dLkk00rUXf/t39n2WvXZgJbxnPEEWy+DHqIlRUo= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= diff --git a/mock/server/repo.go b/mock/server/repo.go index cc480b289..88b4d4715 100644 --- a/mock/server/repo.go +++ b/mock/server/repo.go @@ -33,11 +33,6 @@ const ( "pipeline_type": "yaml", "topics": [], "active": true, - "allow_pull": false, - "allow_push": true, - "allow_deploy": false, - "allow_tag": false, - "allow_comment": false, "allow_events": { "push": { "branch": true, @@ -77,11 +72,7 @@ const ( "visibility": "public", "private": false, "trusted": true, - "active": true, - "allow_pr": false, - "allow_push": true, - "allow_deploy": false, - "allow_tag": false + "active": true }, { "id": 2, @@ -97,11 +88,7 @@ const ( "visibility": "public", "private": false, "trusted": true, - "active": true, - "allow_pr": false, - "allow_push": true, - "allow_deploy": false, - "allow_tag": false + "active": true } ]` ) diff --git a/mock/server/secret.go b/mock/server/secret.go index 34fcd4b76..5030ce3cd 100644 --- a/mock/server/secret.go +++ b/mock/server/secret.go @@ -28,7 +28,6 @@ const ( "images": [ "alpine" ], - "events": [], "allow_events": { "push": { "branch": true, @@ -68,9 +67,6 @@ const ( "type": "repo", "images": [ "alpine" - ], - "events": [ - "push" ] }, { @@ -83,9 +79,6 @@ const ( "type": "org", "images": [ "alpine" - ], - "events": [ - "push" ] }, { @@ -98,9 +91,6 @@ const ( "type": "shared", "images": [ "alpine" - ], - "events": [ - "push" ] } ]` diff --git a/queue/redis/redis_test.go b/queue/redis/redis_test.go index 919892976..3f632b129 100644 --- a/queue/redis/redis_test.go +++ b/queue/redis/redis_test.go @@ -74,22 +74,18 @@ var ( } _repo = &library.Repo{ - ID: Int64(1), - Org: String("github"), - Name: String("octocat"), - FullName: String("github/octocat"), - Link: String("https://github.com/github/octocat"), - Clone: String("https://github.com/github/octocat.git"), - Branch: String("main"), - Timeout: Int64(60), - Visibility: String("public"), - Private: Bool(false), - Trusted: Bool(false), - Active: Bool(true), - AllowPull: Bool(false), - AllowPush: Bool(true), - AllowDeploy: Bool(false), - AllowTag: Bool(false), + ID: Int64(1), + Org: String("github"), + Name: String("octocat"), + FullName: String("github/octocat"), + Link: String("https://github.com/github/octocat"), + Clone: String("https://github.com/github/octocat.git"), + Branch: String("main"), + Timeout: Int64(60), + Visibility: String("public"), + Private: Bool(false), + Trusted: Bool(false), + Active: Bool(true), } _steps = &pipeline.Build{ diff --git a/router/middleware/org/org_test.go b/router/middleware/org/org_test.go index 27021222f..8b217f5f8 100644 --- a/router/middleware/org/org_test.go +++ b/router/middleware/org/org_test.go @@ -48,11 +48,6 @@ func TestOrg_Establish(t *testing.T) { r.SetPrivate(false) r.SetTrusted(false) r.SetActive(false) - r.SetAllowPull(false) - r.SetAllowPush(false) - r.SetAllowDeploy(false) - r.SetAllowTag(false) - r.SetAllowComment(false) want := "foo" got := "" diff --git a/router/middleware/repo/repo_test.go b/router/middleware/repo/repo_test.go index 9ae835eae..488bcac8d 100644 --- a/router/middleware/repo/repo_test.go +++ b/router/middleware/repo/repo_test.go @@ -54,11 +54,6 @@ func TestRepo_Establish(t *testing.T) { want.SetPrivate(false) want.SetTrusted(false) want.SetActive(false) - want.SetAllowPull(false) - want.SetAllowPush(false) - want.SetAllowDeploy(false) - want.SetAllowTag(false) - want.SetAllowComment(false) want.SetAllowEvents(library.NewEventsFromMask(1)) want.SetPipelineType("yaml") want.SetPreviousName("") diff --git a/scm/github/repo_test.go b/scm/github/repo_test.go index 6918c8a0d..b34e704ac 100644 --- a/scm/github/repo_test.go +++ b/scm/github/repo_test.go @@ -690,9 +690,6 @@ func TestGithub_Enable(t *testing.T) { r.SetName("bar") r.SetOrg("foo") r.SetHash("secret") - r.SetAllowPush(true) - r.SetAllowPull(true) - r.SetAllowDeploy(true) client, _ := NewTest(s.URL) @@ -739,9 +736,6 @@ func TestGithub_Update(t *testing.T) { r.SetName("bar") r.SetOrg("foo") r.SetHash("secret") - r.SetAllowPush(true) - r.SetAllowPull(true) - r.SetAllowDeploy(true) hookID := int64(1) diff --git a/secret/native/count_test.go b/secret/native/count_test.go index 33ab448be..e080ec03a 100644 --- a/secret/native/count_test.go +++ b/secret/native/count_test.go @@ -20,7 +20,6 @@ func TestNative_Count(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetCreatedAt(1) sec.SetUpdatedAt(1) diff --git a/secret/native/create_test.go b/secret/native/create_test.go index 02a114976..c7c44c22d 100644 --- a/secret/native/create_test.go +++ b/secret/native/create_test.go @@ -22,7 +22,6 @@ func TestNative_Create_Org(t *testing.T) { want.SetValue("baz") want.SetType("org") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowEvents(library.NewEventsFromMask(1)) want.SetAllowCommand(false) want.SetAllowSubstitution(false) @@ -71,7 +70,6 @@ func TestNative_Create_Repo(t *testing.T) { want.SetValue("foob") want.SetType("repo") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowEvents(library.NewEventsFromMask(1)) want.SetAllowCommand(false) want.SetAllowSubstitution(false) @@ -120,7 +118,6 @@ func TestNative_Create_Shared(t *testing.T) { want.SetValue("foob") want.SetType("shared") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowEvents(library.NewEventsFromMask(1)) want.SetAllowCommand(false) want.SetAllowSubstitution(false) @@ -169,7 +166,6 @@ func TestNative_Create_Invalid(t *testing.T) { sec.SetValue("foob") sec.SetType("invalid") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowEvents(library.NewEventsFromMask(1)) sec.SetAllowCommand(false) sec.SetAllowSubstitution(false) diff --git a/secret/native/delete_test.go b/secret/native/delete_test.go index 96838d575..ad486b2a1 100644 --- a/secret/native/delete_test.go +++ b/secret/native/delete_test.go @@ -21,7 +21,6 @@ func TestNative_Delete(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) sec.SetCreatedAt(1) sec.SetUpdatedAt(1) diff --git a/secret/native/get_test.go b/secret/native/get_test.go index b9b56e51e..f20dcdf5b 100644 --- a/secret/native/get_test.go +++ b/secret/native/get_test.go @@ -22,7 +22,6 @@ func TestNative_Get(t *testing.T) { want.SetValue("foob") want.SetType("repo") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowEvents(library.NewEventsFromMask(1)) want.SetAllowCommand(false) want.SetAllowSubstitution(false) diff --git a/secret/native/list_test.go b/secret/native/list_test.go index b01e3a546..b201eda73 100644 --- a/secret/native/list_test.go +++ b/secret/native/list_test.go @@ -22,7 +22,6 @@ func TestNative_List(t *testing.T) { sOne.SetValue("foob") sOne.SetType("repo") sOne.SetImages([]string{"foo", "bar"}) - sOne.SetEvents([]string{"foo", "bar"}) sOne.SetAllowEvents(library.NewEventsFromMask(1)) sOne.SetAllowCommand(false) sOne.SetAllowSubstitution(false) @@ -40,7 +39,6 @@ func TestNative_List(t *testing.T) { sTwo.SetValue("baz") sTwo.SetType("repo") sTwo.SetImages([]string{"foo", "bar"}) - sTwo.SetEvents([]string{"foo", "bar"}) sTwo.SetAllowEvents(library.NewEventsFromMask(1)) sTwo.SetAllowCommand(false) sTwo.SetAllowSubstitution(false) diff --git a/secret/native/update.go b/secret/native/update.go index 7e2c92d0c..bce00e936 100644 --- a/secret/native/update.go +++ b/secret/native/update.go @@ -19,11 +19,6 @@ func (c *client) Update(ctx context.Context, sType, org, name string, s *library return nil, err } - // update the events if set - if len(s.GetEvents()) > 0 { - secret.SetEvents(s.GetEvents()) - } - // update allow events if set if s.GetAllowEvents().ToDatabase() > 0 { secret.SetAllowEvents(s.GetAllowEvents()) diff --git a/secret/native/update_test.go b/secret/native/update_test.go index 38d7a3b5b..1ec2d597a 100644 --- a/secret/native/update_test.go +++ b/secret/native/update_test.go @@ -23,7 +23,6 @@ func TestNative_Update(t *testing.T) { original.SetValue("secretValue") original.SetType("repo") original.SetImages([]string{"foo", "baz"}) - original.SetEvents([]string{"foob", "bar"}) original.SetAllowEvents(library.NewEventsFromMask(1)) original.SetAllowCommand(true) original.SetAllowSubstitution(true) @@ -41,7 +40,6 @@ func TestNative_Update(t *testing.T) { want.SetValue("foob") want.SetType("repo") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowEvents(library.NewEventsFromMask(3)) want.SetAllowCommand(false) want.SetAllowSubstitution(false) diff --git a/secret/vault/create_test.go b/secret/vault/create_test.go index 129b0e487..dc0d5226f 100644 --- a/secret/vault/create_test.go +++ b/secret/vault/create_test.go @@ -51,7 +51,6 @@ func TestVault_Create_Org(t *testing.T) { sec.SetValue("baz") sec.SetType("org") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(true) sec.SetAllowSubstitution(true) sec.SetAllowEvents(library.NewEventsFromMask(1)) @@ -142,7 +141,6 @@ func TestVault_Create_Repo(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(true) sec.SetAllowSubstitution(true) sec.SetAllowEvents(library.NewEventsFromMask(3)) @@ -234,7 +232,6 @@ func TestVault_Create_Shared(t *testing.T) { sec.SetValue("foob") sec.SetType("shared") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) sec.SetAllowSubstitution(false) sec.SetAllowEvents(library.NewEventsFromMask(1)) @@ -321,7 +318,6 @@ func TestVault_Create_InvalidSecret(t *testing.T) { sec.SetValue("") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) type args struct { @@ -376,7 +372,6 @@ func TestVault_Create_InvalidType(t *testing.T) { sec.SetValue("foob") sec.SetType("invalid") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) // setup mock server @@ -430,7 +425,6 @@ func TestVault_Create_ClosedServer(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) // setup mock server diff --git a/secret/vault/get_test.go b/secret/vault/get_test.go index 2c811e9fd..5af08f22a 100644 --- a/secret/vault/get_test.go +++ b/secret/vault/get_test.go @@ -51,7 +51,6 @@ func TestVault_Get_Org(t *testing.T) { want.SetValue("baz") want.SetType("org") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowCommand(true) want.SetAllowSubstitution(true) want.SetAllowEvents(library.NewEventsFromMask(1)) @@ -142,7 +141,6 @@ func TestVault_Get_Repo(t *testing.T) { want.SetValue("foob") want.SetType("repo") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowCommand(true) want.SetAllowSubstitution(true) want.SetAllowEvents(library.NewEventsFromMask(3)) @@ -233,7 +231,6 @@ func TestVault_Get_Shared(t *testing.T) { want.SetValue("foob") want.SetType("shared") want.SetImages([]string{"foo", "bar"}) - want.SetEvents([]string{"foo", "bar"}) want.SetAllowCommand(false) want.SetAllowSubstitution(false) want.SetAllowEvents(library.NewEventsFromMask(1)) diff --git a/secret/vault/list_test.go b/secret/vault/list_test.go index 3a6c2ab60..9a6eb352e 100644 --- a/secret/vault/list_test.go +++ b/secret/vault/list_test.go @@ -66,7 +66,6 @@ func TestVault_List_Org(t *testing.T) { sec.SetValue("baz") sec.SetType("org") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(true) sec.SetAllowSubstitution(true) sec.SetAllowEvents(library.NewEventsFromMask(1)) @@ -204,7 +203,6 @@ func TestVault_List_Repo(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(true) sec.SetAllowSubstitution(true) sec.SetAllowEvents(library.NewEventsFromMask(3)) @@ -327,7 +325,6 @@ func TestVault_List_Shared(t *testing.T) { sec.SetValue("foob") sec.SetType("shared") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) sec.SetAllowSubstitution(false) sec.SetAllowEvents(library.NewEventsFromMask(1)) diff --git a/secret/vault/update.go b/secret/vault/update.go index 5655dcb9d..a269bd8f3 100644 --- a/secret/vault/update.go +++ b/secret/vault/update.go @@ -45,9 +45,6 @@ func (c *client) Update(ctx context.Context, sType, org, name string, s *library // convert the Vault secret our secret vault := vaultFromSecret(sec) - if len(s.GetEvents()) > 0 { - vault.Data["events"] = s.GetEvents() - } if s.GetAllowEvents().ToDatabase() != 0 { vault.Data["allow_events"] = s.GetAllowEvents().ToDatabase() diff --git a/secret/vault/update_test.go b/secret/vault/update_test.go index 94f247c7e..4a525c1ab 100644 --- a/secret/vault/update_test.go +++ b/secret/vault/update_test.go @@ -66,7 +66,6 @@ func TestVault_Update_Org(t *testing.T) { sec.SetValue("baz") sec.SetType("org") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(true) sec.SetAllowSubstitution(true) sec.SetAllowEvents(library.NewEventsFromMask(1)) @@ -173,7 +172,6 @@ func TestVault_Update_Repo(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(true) sec.SetAllowSubstitution(true) sec.SetAllowEvents(library.NewEventsFromMask(3)) @@ -280,7 +278,6 @@ func TestVault_Update_Shared(t *testing.T) { sec.SetValue("foob") sec.SetType("shared") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) sec.SetAllowSubstitution(false) sec.SetAllowEvents(library.NewEventsFromMask(1)) @@ -372,7 +369,6 @@ func TestVault_Update_InvalidSecret(t *testing.T) { sec.SetValue("") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) sec.SetAllowCommand(false) type args struct { @@ -426,7 +422,6 @@ func TestVault_Update_InvalidType(t *testing.T) { sec.SetValue("foob") sec.SetType("invalid") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) // setup mock server fake := httptest.NewServer(http.NotFoundHandler()) @@ -478,7 +473,6 @@ func TestVault_Update_ClosedServer(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) // setup mock server fake := httptest.NewServer(http.NotFoundHandler()) @@ -552,7 +546,6 @@ func TestVault_Update_NoWrite(t *testing.T) { sec.SetValue("foob") sec.SetType("repo") sec.SetImages([]string{"foo", "bar"}) - sec.SetEvents([]string{"foo", "bar"}) type args struct { version string diff --git a/secret/vault/vault.go b/secret/vault/vault.go index d9f3d79b5..2cbf34b34 100644 --- a/secret/vault/vault.go +++ b/secret/vault/vault.go @@ -144,22 +144,8 @@ func secretFromVault(vault *api.Secret) *library.Secret { data = vault.Data } - // set events if found in Vault secret - v, ok := data["events"] - if ok { - events, ok := v.([]interface{}) - if ok { - for _, element := range events { - event, ok := element.(string) - if ok { - s.SetEvents(append(s.GetEvents(), event)) - } - } - } - } - // set allow_events if found in Vault secret - v, ok = data["allow_events"] + v, ok := data["allow_events"] if ok { maskJSON, ok := v.(json.Number) if ok { @@ -345,11 +331,6 @@ func vaultFromSecret(s *library.Secret) *api.Secret { vault := new(api.Secret) vault.Data = data - // set events if found in Vela secret - if len(s.GetEvents()) > 0 { - vault.Data["events"] = s.GetEvents() - } - // set allow events to mask if s.GetAllowEvents().ToDatabase() != 0 { vault.Data["allow_events"] = s.GetAllowEvents().ToDatabase() diff --git a/secret/vault/vault_test.go b/secret/vault/vault_test.go index cec5d02c8..2bbb666bb 100644 --- a/secret/vault/vault_test.go +++ b/secret/vault/vault_test.go @@ -133,7 +133,6 @@ func TestVault_secretFromVault(t *testing.T) { want.SetName("bar") want.SetValue("baz") want.SetType("org") - want.SetEvents([]string{"push", "tag", "deployment"}) want.SetAllowEvents(library.NewEventsFromMask(8195)) want.SetImages([]string{"foo", "bar"}) want.SetAllowCommand(true) @@ -176,7 +175,6 @@ func TestVault_vaultFromSecret(t *testing.T) { s.SetName("bar") s.SetValue("baz") s.SetType("org") - s.SetEvents([]string{"foo", "bar"}) s.SetAllowEvents(library.NewEventsFromMask(1)) s.SetImages([]string{"foo", "bar"}) s.SetAllowCommand(true) @@ -188,7 +186,6 @@ func TestVault_vaultFromSecret(t *testing.T) { want := &api.Secret{ Data: map[string]interface{}{ - "events": []string{"foo", "bar"}, "allow_events": int64(1), "images": []string{"foo", "bar"}, "name": "bar", @@ -243,7 +240,6 @@ func TestVault_AccurateSecretFields(t *testing.T) { // helper function to return a test Vault secret data. func testVaultSecretData() map[string]interface{} { return map[string]interface{}{ - "events": []interface{}{"push", "tag", "deployment"}, "allow_events": json.Number("8195"), "images": []interface{}{"foo", "bar"}, "name": "bar", From 52df52777068b26a1cd46757d4e482164e09b060 Mon Sep 17 00:00:00 2001 From: wsan3 Date: Mon, 1 Apr 2024 17:06:25 -0500 Subject: [PATCH 06/10] Extend label rule to include other PR events --- api/build/compile_publish.go | 2 ++ api/webhook/post.go | 5 +++++ compiler/engine.go | 4 ++-- compiler/native/compile.go | 2 +- compiler/native/expand_test.go | 2 ++ compiler/native/native.go | 10 +++++----- scm/github/webhook.go | 13 ++++++++++++- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/api/build/compile_publish.go b/api/build/compile_publish.go index ea908862f..f60dcaa56 100644 --- a/api/build/compile_publish.go +++ b/api/build/compile_publish.go @@ -31,6 +31,7 @@ type CompileAndPublishConfig struct { BaseErr string Source string Comment string + Labels []string Retries int } @@ -287,6 +288,7 @@ func CompileAndPublish( WithMetadata(cfg.Metadata). WithRepo(repo). WithUser(u). + WithLabels(cfg.Labels). Compile(pipelineFile) if err != nil { // format the error message with extra information diff --git a/api/webhook/post.go b/api/webhook/post.go index 8ebf0bf7f..1ddcb0d2b 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -273,9 +273,13 @@ func PostWebhook(c *gin.Context) { } var prComment string + var prLabels []string if strings.EqualFold(b.GetEvent(), constants.EventComment) { prComment = webhook.PullRequest.Comment } + if strings.EqualFold(b.GetEvent(), constants.EventPull) { + prLabels = webhook.PullRequest.Labels + } // construct CompileAndPublishConfig config := build.CompileAndPublishConfig{ @@ -285,6 +289,7 @@ func PostWebhook(c *gin.Context) { BaseErr: baseErr, Source: "webhook", Comment: prComment, + Labels: prLabels, Retries: 3, } diff --git a/compiler/engine.go b/compiler/engine.go index f1f416cce..1778c08a0 100644 --- a/compiler/engine.go +++ b/compiler/engine.go @@ -141,8 +141,8 @@ type Engine interface { // the library user type in the Engine. WithUser(*library.User) Engine // WithLabel defines a function that sets - // the label in the Engine. - WithLabel(string) Engine + // the label(s) in the Engine. + WithLabels([]string) Engine // WithUser defines a function that sets // the private github client in the Engine. WithPrivateGitHub(string, string) Engine diff --git a/compiler/native/compile.go b/compiler/native/compile.go index 70aba717c..e2e1f0718 100644 --- a/compiler/native/compile.go +++ b/compiler/native/compile.go @@ -70,7 +70,7 @@ func (c *client) Compile(v interface{}) (*pipeline.Build, *library.Pipeline, err Repo: c.repo.GetFullName(), Tag: strings.TrimPrefix(c.build.GetRef(), "refs/tags/"), Target: c.build.GetDeploy(), - Label: c.label, + Label: c.labels, } switch { diff --git a/compiler/native/expand_test.go b/compiler/native/expand_test.go index df04741e3..6d9479a53 100644 --- a/compiler/native/expand_test.go +++ b/compiler/native/expand_test.go @@ -450,6 +450,7 @@ func TestNative_ExpandStepsMulti(t *testing.T) { If: yaml.Rules{ Branch: []string{"main"}, }, + Operator: "and", }, }, &yaml.Step{ @@ -466,6 +467,7 @@ func TestNative_ExpandStepsMulti(t *testing.T) { If: yaml.Rules{ Branch: []string{"dev"}, }, + Operator: "and", }, }, } diff --git a/compiler/native/native.go b/compiler/native/native.go index c5acf0a2d..048f22307 100644 --- a/compiler/native/native.go +++ b/compiler/native/native.go @@ -42,7 +42,7 @@ type client struct { metadata *types.Metadata repo *library.Repo user *library.User - label string + labels []string } // New returns a Pipeline implementation that integrates with the supported registries. @@ -212,10 +212,10 @@ func (c *client) WithUser(u *library.User) compiler.Engine { return c } -// WithComment sets the comment in the Engine. -func (c *client) WithLabel(label string) compiler.Engine { - if label != "" { - c.label = label +// WithLabels sets the label(s) in the Engine. +func (c *client) WithLabels(labels []string) compiler.Engine { + if len(labels) != 0 { + c.labels = labels } return c diff --git a/scm/github/webhook.go b/scm/github/webhook.go index d53b988aa..08ce41464 100644 --- a/scm/github/webhook.go +++ b/scm/github/webhook.go @@ -311,6 +311,17 @@ func (c *client) processPREvent(h *library.Hook, payload *github.PullRequestEven b.SetEmail(payload.GetPullRequest().GetHead().GetUser().GetEmail()) } + var prLabels []string + if strings.EqualFold(payload.GetAction(), "labeled") || + strings.EqualFold(payload.GetAction(), "unlabeled") { + prLabels = append(prLabels, payload.GetLabel().GetName()) + } else { + labels := payload.GetPullRequest().Labels + for _, label := range labels { + prLabels = append(prLabels, label.GetName()) + } + } + // determine if pull request head is a fork and does not match the repo name of base fromFork := payload.GetPullRequest().GetHead().GetRepo().GetFork() && !strings.EqualFold(payload.GetPullRequest().GetBase().GetRepo().GetFullName(), payload.GetPullRequest().GetHead().GetRepo().GetFullName()) @@ -319,7 +330,7 @@ func (c *client) processPREvent(h *library.Hook, payload *github.PullRequestEven PullRequest: types.PullRequest{ Number: payload.GetNumber(), IsFromFork: fromFork, - Label: payload.GetLabel().GetName(), + Labels: prLabels, }, Hook: h, Repo: r, From 5e7e402e46059f02705ce73dcf3cefa462d3fc2e Mon Sep 17 00:00:00 2001 From: wsan3 Date: Tue, 2 Apr 2024 14:16:49 -0500 Subject: [PATCH 07/10] Update go.mod --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 681104cdc..5a52e83a0 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/drone/envsubst v1.0.3 github.com/gin-gonic/gin v1.9.1 github.com/go-playground/assert/v2 v2.2.0 - github.com/go-vela/types v0.23.4-0.20240401132228-9b43c701ab32 + github.com/go-vela/types v0.23.4-0.20240402153726-f16c3e4cb5fb github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v59 v59.0.0 diff --git a/go.sum b/go.sum index a956a83fd..9c4e1259a 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw= github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-vela/types v0.23.4-0.20240401132228-9b43c701ab32 h1:fqmNnM1LdH3Zg1zCADfgR7a51EOSZvLFAB2Em4CG+Pg= -github.com/go-vela/types v0.23.4-0.20240401132228-9b43c701ab32/go.mod h1:mEF9dLkk00rUXf/t39n2WvXZgJbxnPEEWy+DHqIlRUo= +github.com/go-vela/types v0.23.4-0.20240402153726-f16c3e4cb5fb h1:jHao/NNRswInMLEb0m1OJ84d1m/LGWMCmaeRqSDnWQY= +github.com/go-vela/types v0.23.4-0.20240402153726-f16c3e4cb5fb/go.mod h1:mEF9dLkk00rUXf/t39n2WvXZgJbxnPEEWy+DHqIlRUo= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= From 93819209fa4f5acb57a869a71154c806afd2560a Mon Sep 17 00:00:00 2001 From: wsan3 Date: Tue, 2 Apr 2024 15:21:40 -0500 Subject: [PATCH 08/10] Fix linter warnings --- api/webhook/post.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/webhook/post.go b/api/webhook/post.go index 1ddcb0d2b..d33a201e9 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -272,11 +272,15 @@ func PostWebhook(c *gin.Context) { return } - var prComment string - var prLabels []string + var ( + prComment string + prLabels []string + ) + if strings.EqualFold(b.GetEvent(), constants.EventComment) { prComment = webhook.PullRequest.Comment } + if strings.EqualFold(b.GetEvent(), constants.EventPull) { prLabels = webhook.PullRequest.Labels } From cbe9a6744f0b25edd072a25876dc9ac224899a29 Mon Sep 17 00:00:00 2001 From: wsan3 Date: Wed, 3 Apr 2024 12:25:39 -0500 Subject: [PATCH 09/10] Add tests for webhook and native compiler --- compiler/native/native_test.go | 20 + .../pull_request_edited_while_labeled.json | 457 ++++++++++++++++++ .../testdata/hooks/pull_request_labeled.json | 451 +++++++++++++++++ .../hooks/pull_request_unlabeled.json | 451 +++++++++++++++++ scm/github/webhook_test.go | 90 ++++ 5 files changed, 1469 insertions(+) create mode 100644 scm/github/testdata/hooks/pull_request_edited_while_labeled.json create mode 100644 scm/github/testdata/hooks/pull_request_labeled.json create mode 100644 scm/github/testdata/hooks/pull_request_unlabeled.json diff --git a/compiler/native/native_test.go b/compiler/native/native_test.go index 36be98195..489288ee7 100644 --- a/compiler/native/native_test.go +++ b/compiler/native/native_test.go @@ -328,3 +328,23 @@ func TestNative_WithUser(t *testing.T) { t.Errorf("WithUser is %v, want %v", got, want) } } + +func TestNative_WithLabels(t *testing.T) { + // setup types + set := flag.NewFlagSet("test", 0) + c := cli.NewContext(nil, set, nil) + + labels := []string{"documentation", "enhancement"} + want, _ := New(c) + want.labels = []string{"documentation", "enhancement"} + + // run test + got, err := New(c) + if err != nil { + t.Errorf("Unable to create new compiler: %v", err) + } + + if !reflect.DeepEqual(got.WithLabels(labels), want) { + t.Errorf("WithLocalTemplates is %v, want %v", got, want) + } +} diff --git a/scm/github/testdata/hooks/pull_request_edited_while_labeled.json b/scm/github/testdata/hooks/pull_request_edited_while_labeled.json new file mode 100644 index 000000000..aa5f13edd --- /dev/null +++ b/scm/github/testdata/hooks/pull_request_edited_while_labeled.json @@ -0,0 +1,457 @@ +{ + "action": "edited", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1", + "id": 191568743, + "node_id": "MDExOlB1bGxSZXF1ZXN0MTkxNTY4NzQz", + "html_url": "https://github.com/Codertocat/Hello-World/pull/1", + "diff_url": "https://github.com/Codertocat/Hello-World/pull/1.diff", + "patch_url": "https://github.com/Codertocat/Hello-World/pull/1.patch", + "issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into main.", + "created_at": "2018-05-30T20:18:30Z", + "updated_at": "2018-05-30T20:18:50Z", + "closed_at": "2018-05-30T20:18:50Z", + "merged_at": null, + "merge_commit_sha": "414cb0069601a32b00bd122a2380cd283626a8e5", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [ + { + "id": 3768735, + "node_id": "MDU6TGFiZWwzNzY4NzM1", + "url": "https://git.target.com/api/v3/repos/WinSan/vela-sandbox/labels/documentation", + "name": "documentation", + "color": "0075ca", + "default": true, + "description": "Improvements or additions to documentation" + } + ], + "milestone": null, + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a", + "head": { + "label": "Codertocat:changes", + "ref": "changes", + "sha": "34c5c7793cb3b279e22454cb6750c80560547b3a", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + } + }, + "base": { + "label": "Codertocat:main", + "ref": "main", + "sha": "a10867b14bb761a232cd80139fbd4c0d33264240", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1" + }, + "html": { + "href": "https://github.com/Codertocat/Hello-World/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a" + } + }, + "author_association": "OWNER", + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "clean", + "merged_by": null, + "comments": 0, + "review_comments": 1, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "changes": { + "title": { + "from": "Update README.md." + } + }, + "repository": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/scm/github/testdata/hooks/pull_request_labeled.json b/scm/github/testdata/hooks/pull_request_labeled.json new file mode 100644 index 000000000..5d2cbd6eb --- /dev/null +++ b/scm/github/testdata/hooks/pull_request_labeled.json @@ -0,0 +1,451 @@ +{ + "action": "labeled", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1", + "id": 191568743, + "node_id": "MDExOlB1bGxSZXF1ZXN0MTkxNTY4NzQz", + "html_url": "https://github.com/Codertocat/Hello-World/pull/1", + "diff_url": "https://github.com/Codertocat/Hello-World/pull/1.diff", + "patch_url": "https://github.com/Codertocat/Hello-World/pull/1.patch", + "issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into main.", + "created_at": "2018-05-30T20:18:30Z", + "updated_at": "2018-05-30T20:18:50Z", + "closed_at": "2018-05-30T20:18:50Z", + "merged_at": null, + "merge_commit_sha": "414cb0069601a32b00bd122a2380cd283626a8e5", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a", + "head": { + "label": "Codertocat:changes", + "ref": "changes", + "sha": "34c5c7793cb3b279e22454cb6750c80560547b3a", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + } + }, + "base": { + "label": "Codertocat:main", + "ref": "main", + "sha": "a10867b14bb761a232cd80139fbd4c0d33264240", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1" + }, + "html": { + "href": "https://github.com/Codertocat/Hello-World/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a" + } + }, + "author_association": "OWNER", + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "clean", + "merged_by": null, + "comments": 0, + "review_comments": 1, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "label": { + "id": 3768735, + "node_id": "MDU6TGFiZWwzNzY4NzM1", + "url": "https://github.com/Codertocat/Hello-World/labels/documentation", + "name": "documentation", + "color": "0075ca", + "default": true, + "description": "Improvements or additions to documentation" + }, + "repository": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/scm/github/testdata/hooks/pull_request_unlabeled.json b/scm/github/testdata/hooks/pull_request_unlabeled.json new file mode 100644 index 000000000..adf48f380 --- /dev/null +++ b/scm/github/testdata/hooks/pull_request_unlabeled.json @@ -0,0 +1,451 @@ +{ + "action": "unlabeled", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1", + "id": 191568743, + "node_id": "MDExOlB1bGxSZXF1ZXN0MTkxNTY4NzQz", + "html_url": "https://github.com/Codertocat/Hello-World/pull/1", + "diff_url": "https://github.com/Codertocat/Hello-World/pull/1.diff", + "patch_url": "https://github.com/Codertocat/Hello-World/pull/1.patch", + "issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into main.", + "created_at": "2018-05-30T20:18:30Z", + "updated_at": "2018-05-30T20:18:50Z", + "closed_at": "2018-05-30T20:18:50Z", + "merged_at": null, + "merge_commit_sha": "414cb0069601a32b00bd122a2380cd283626a8e5", + "assignee": null, + "assignees": [], + "requested_reviewers": [], + "requested_teams": [], + "labels": [], + "milestone": null, + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a", + "head": { + "label": "Codertocat:changes", + "ref": "changes", + "sha": "34c5c7793cb3b279e22454cb6750c80560547b3a", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + } + }, + "base": { + "label": "Codertocat:main", + "ref": "main", + "sha": "a10867b14bb761a232cd80139fbd4c0d33264240", + "user": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1" + }, + "html": { + "href": "https://github.com/Codertocat/Hello-World/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a" + } + }, + "author_association": "OWNER", + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "clean", + "merged_by": null, + "comments": 0, + "review_comments": 1, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "label": { + "id": 3768735, + "node_id": "MDU6TGFiZWwzNzY4NzM1", + "url": "https://github.com/Codertocat/Hello-World/labels/documentation", + "name": "documentation", + "color": "0075ca", + "default": true, + "description": "Improvements or additions to documentation" + }, + "repository": { + "id": 135493233, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/Codertocat/Hello-World", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/Codertocat/Hello-World", + "forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks", + "keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams", + "hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks", + "issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}", + "events_url": "https://api.github.com/repos/Codertocat/Hello-World/events", + "assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}", + "branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}", + "tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags", + "blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages", + "stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers", + "contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors", + "subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers", + "subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription", + "commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}", + "compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges", + "archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads", + "issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}", + "pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}", + "releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}", + "deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments", + "created_at": "2018-05-30T20:18:04Z", + "updated_at": "2018-05-30T20:18:50Z", + "pushed_at": "2018-05-30T20:18:48Z", + "git_url": "git://github.com/Codertocat/Hello-World.git", + "ssh_url": "git@github.com:Codertocat/Hello-World.git", + "clone_url": "https://github.com/Codertocat/Hello-World.git", + "svn_url": "https://github.com/Codertocat/Hello-World", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "main" + }, + "sender": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Codertocat", + "html_url": "https://github.com/Codertocat", + "followers_url": "https://api.github.com/users/Codertocat/followers", + "following_url": "https://api.github.com/users/Codertocat/following{/other_user}", + "gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions", + "organizations_url": "https://api.github.com/users/Codertocat/orgs", + "repos_url": "https://api.github.com/users/Codertocat/repos", + "events_url": "https://api.github.com/users/Codertocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/Codertocat/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/scm/github/webhook_test.go b/scm/github/webhook_test.go index eab3cbc54..64a33d28e 100644 --- a/scm/github/webhook_test.go +++ b/scm/github/webhook_test.go @@ -372,6 +372,54 @@ func TestGithub_ProcessWebhook_PullRequest(t *testing.T) { wantBuild.SetBaseRef("main") wantBuild.SetHeadRef("changes") + wantBuild2 := new(library.Build) + wantBuild2.SetEvent("pull_request") + wantBuild2.SetEventAction("labeled") + wantBuild2.SetClone("https://github.com/Codertocat/Hello-World.git") + wantBuild2.SetSource("https://github.com/Codertocat/Hello-World/pull/1") + wantBuild2.SetTitle("pull_request received from https://github.com/Codertocat/Hello-World") + wantBuild2.SetMessage("Update the README with new information") + wantBuild2.SetCommit("34c5c7793cb3b279e22454cb6750c80560547b3a") + wantBuild2.SetSender("Codertocat") + wantBuild2.SetAuthor("Codertocat") + wantBuild2.SetEmail("") + wantBuild2.SetBranch("main") + wantBuild2.SetRef("refs/pull/1/head") + wantBuild2.SetBaseRef("main") + wantBuild2.SetHeadRef("changes") + + wantBuild3 := new(library.Build) + wantBuild3.SetEvent("pull_request") + wantBuild3.SetEventAction("unlabeled") + wantBuild3.SetClone("https://github.com/Codertocat/Hello-World.git") + wantBuild3.SetSource("https://github.com/Codertocat/Hello-World/pull/1") + wantBuild3.SetTitle("pull_request received from https://github.com/Codertocat/Hello-World") + wantBuild3.SetMessage("Update the README with new information") + wantBuild3.SetCommit("34c5c7793cb3b279e22454cb6750c80560547b3a") + wantBuild3.SetSender("Codertocat") + wantBuild3.SetAuthor("Codertocat") + wantBuild3.SetEmail("") + wantBuild3.SetBranch("main") + wantBuild3.SetRef("refs/pull/1/head") + wantBuild3.SetBaseRef("main") + wantBuild3.SetHeadRef("changes") + + wantBuild4 := new(library.Build) + wantBuild4.SetEvent("pull_request") + wantBuild4.SetEventAction("edited") + wantBuild4.SetClone("https://github.com/Codertocat/Hello-World.git") + wantBuild4.SetSource("https://github.com/Codertocat/Hello-World/pull/1") + wantBuild4.SetTitle("pull_request received from https://github.com/Codertocat/Hello-World") + wantBuild4.SetMessage("Update the README with new information") + wantBuild4.SetCommit("34c5c7793cb3b279e22454cb6750c80560547b3a") + wantBuild4.SetSender("Codertocat") + wantBuild4.SetAuthor("Codertocat") + wantBuild4.SetEmail("") + wantBuild4.SetBranch("main") + wantBuild4.SetRef("refs/pull/1/head") + wantBuild4.SetBaseRef("main") + wantBuild4.SetHeadRef("changes") + tests := []struct { name string testData string @@ -435,6 +483,48 @@ func TestGithub_ProcessWebhook_PullRequest(t *testing.T) { Build: nil, }, }, + { + name: "labeled documentation", + testData: "testdata/hooks/pull_request_labeled.json", + want: &types.Webhook{ + PullRequest: types.PullRequest{ + Number: wantHook.GetNumber(), + IsFromFork: false, + Labels: []string{"documentation"}, + }, + Hook: wantHook, + Repo: wantRepo, + Build: wantBuild2, + }, + }, + { + name: "unlabeled documentation", + testData: "testdata/hooks/pull_request_unlabeled.json", + want: &types.Webhook{ + PullRequest: types.PullRequest{ + Number: wantHook.GetNumber(), + IsFromFork: false, + Labels: []string{"documentation"}, + }, + Hook: wantHook, + Repo: wantRepo, + Build: wantBuild3, + }, + }, + { + name: "edited while labeled documentation", + testData: "testdata/hooks/pull_request_edited_while_labeled.json", + want: &types.Webhook{ + PullRequest: types.PullRequest{ + Number: wantHook.GetNumber(), + IsFromFork: false, + Labels: []string{"documentation"}, + }, + Hook: wantHook, + Repo: wantRepo, + Build: wantBuild4, + }, + }, } for _, tt := range tests { From 17c534f4562ca3717e3ed4197b7a99c26ea49d21 Mon Sep 17 00:00:00 2001 From: wsan3 Date: Wed, 3 Apr 2024 13:53:55 -0500 Subject: [PATCH 10/10] Update test for webhook --- .../hooks/pull_request_edited_while_labeled.json | 9 +++++++++ scm/github/webhook_test.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scm/github/testdata/hooks/pull_request_edited_while_labeled.json b/scm/github/testdata/hooks/pull_request_edited_while_labeled.json index aa5f13edd..55471932e 100644 --- a/scm/github/testdata/hooks/pull_request_edited_while_labeled.json +++ b/scm/github/testdata/hooks/pull_request_edited_while_labeled.json @@ -52,6 +52,15 @@ "color": "0075ca", "default": true, "description": "Improvements or additions to documentation" + }, + { + "id": 3768737, + "node_id": "MDU6TGFiZWwzNzY4NzM3", + "url": "https://git.target.com/api/v3/repos/WinSan/vela-sandbox/labels/enhancement", + "name": "enhancement", + "color": "a2eeef", + "default": true, + "description": "New feature or request" } ], "milestone": null, diff --git a/scm/github/webhook_test.go b/scm/github/webhook_test.go index 64a33d28e..3bf0415f9 100644 --- a/scm/github/webhook_test.go +++ b/scm/github/webhook_test.go @@ -518,7 +518,7 @@ func TestGithub_ProcessWebhook_PullRequest(t *testing.T) { PullRequest: types.PullRequest{ Number: wantHook.GetNumber(), IsFromFork: false, - Labels: []string{"documentation"}, + Labels: []string{"documentation", "enhancement"}, }, Hook: wantHook, Repo: wantRepo,