From 6e670078443de9329ba1f1fe1e9baca45b4583e3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sun, 30 May 2021 12:47:16 +0200 Subject: [PATCH 01/10] Bump github.com/google/go-jsonnet to v0.17.0 ... to allow std.objectValues(). --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6598af1fe..1967a631a 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/go-sql-driver/mysql v1.4.0 github.com/golang/mock v1.3.1 github.com/google/go-cmp v0.4.0 - github.com/google/go-jsonnet v0.16.0 + github.com/google/go-jsonnet v0.17.0 github.com/google/wire v0.2.1 github.com/gorhill/cronexpr v0.0.0-20140423231348-a557574d6c02 // indirect github.com/gosimple/slug v1.3.0 diff --git a/go.sum b/go.sum index 8c89fe748..7a16225f8 100644 --- a/go.sum +++ b/go.sum @@ -184,6 +184,8 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-jsonnet v0.16.0 h1:Nb4EEOp+rdeGGyB1rQ5eisgSAqrTnhf9ip+X6lzZbY0= github.com/google/go-jsonnet v0.16.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw= +github.com/google/go-jsonnet v0.17.0 h1:/9NIEfhK1NQRKl3sP2536b2+x5HnZMdql7x3yK/l8JY= +github.com/google/go-jsonnet v0.17.0/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/wire v0.2.1 h1:TYj4Z2qjqxa2ufb34UJqVeO9aznL+i0fLO6TqThKZ7Y= From c7e03b62518b90c4c4b8643c94af280255a83943 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 7 Jun 2021 16:05:55 +0545 Subject: [PATCH 02/10] Fix various typos --- CHANGELOG.md | 4 ++-- core/build.go | 2 +- core/transfer.go | 2 +- core/user.go | 2 +- handler/api/user/repos_test.go | 4 ++-- handler/api/user/sync.go | 4 ++-- handler/api/users/create.go | 2 +- handler/api/users/create_test.go | 2 +- handler/api/users/find.go | 2 +- handler/web/login.go | 4 ++-- operator/manager/manager.go | 8 ++++---- operator/manager/rpc/server_oss.go | 4 ++-- operator/manager/rpc2/handler.go | 4 ++-- operator/manager/rpc2/types.go | 4 ++-- operator/runner/machine/config.go | 2 +- operator/runner/machine/machine.go | 2 +- plugin/config/global_test.go | 2 +- plugin/converter/jsonnet/jsonnet.go | 10 +++++----- plugin/registry/encrypted.go | 2 +- plugin/registry/endpoint_test.go | 2 +- scheduler/queue/queue.go | 4 ++-- scheduler/queue/queue_test.go | 10 +++++----- service/content/content.go | 2 +- service/hook/parser/testdata/gitea_push.json | 2 +- service/hook/parser/testdata/gitea_tag.json | 2 +- service/hook/parser/testdata/gogs_pull_create.json | 2 +- service/hook/parser/testdata/gogs_push.json | 2 +- service/hook/parser/testdata/gogs_tag.json | 2 +- service/syncer/util.go | 2 +- session/session_test.go | 2 +- store/repos/repos.go | 10 +++++----- store/shared/db/conn.go | 2 +- store/shared/encrypt/aesgcm.go | 8 ++++---- trigger/dag/dag_test.go | 2 +- trigger/skip.go | 2 +- 35 files changed, 61 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 799e6a64e..5f58c5ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,13 +94,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - page to view the latest build per branch. ### Fixed -- sync routine not executing asyncronously, being cancelled by http context. +- sync routine not executing asynchronously, being cancelled by http context. - sync routine should ignore gitlab subrepositories - convert deploy events in 0.8 yaml to promote events. - do not execute cron job for disabled repositories. [#2931](https://github.com/drone/drone/issues/2931). - remove trailing slash from gitea url to prevent oauth2 token refresh errors, by [@cmj0121](https://github.com/cmj0121). [#2920](https://github.com/drone/drone/issues/2920). - disable font ligatures in build log output. [drone/drone-ui#322](https://github.com/drone/drone-ui/pull/322). -- missing am/pm in timstamps +- missing am/pm in timestamps ## [1.6.5] - 2020-01-29 ### Changed diff --git a/core/build.go b/core/build.go index c164535ce..f70761869 100644 --- a/core/build.go +++ b/core/build.go @@ -77,7 +77,7 @@ type BuildStore interface { LatestBranches(context.Context, int64) ([]*Build, error) // LatestPulls returns the latest builds from the - // datastore by pull requeset. + // datastore by pull request. LatestPulls(context.Context, int64) ([]*Build, error) // LatestDeploys returns the latest builds from the diff --git a/core/transfer.go b/core/transfer.go index 48ece4182..3e6535179 100644 --- a/core/transfer.go +++ b/core/transfer.go @@ -16,7 +16,7 @@ package core import "context" -// Transferer handles transfering repository ownership from one +// Transferer handles transferring repository ownership from one // user to another user account. type Transferer interface { Transfer(ctx context.Context, user *User) error diff --git a/core/user.go b/core/user.go index c4d62ae7b..e9fcaa9d7 100644 --- a/core/user.go +++ b/core/user.go @@ -101,7 +101,7 @@ type ( } ) -// Validate valides the user and returns an error if the +// Validate validates the user and returns an error if the // validation fails. func (u *User) Validate() error { switch { diff --git a/handler/api/user/repos_test.go b/handler/api/user/repos_test.go index cc99883e1..3ab2ebace 100644 --- a/handler/api/user/repos_test.go +++ b/handler/api/user/repos_test.go @@ -25,7 +25,7 @@ func init() { logrus.SetOutput(ioutil.Discard) } -func TestResitoryList(t *testing.T) { +func TestRepositoryList(t *testing.T) { controller := gomock.NewController(t) defer controller.Finish() @@ -63,7 +63,7 @@ func TestResitoryList(t *testing.T) { } } -func TestResitoryListErr(t *testing.T) { +func TestRepositoryListErr(t *testing.T) { controller := gomock.NewController(t) defer controller.Finish() diff --git a/handler/api/user/sync.go b/handler/api/user/sync.go index c2f0555ad..42512d737 100644 --- a/handler/api/user/sync.go +++ b/handler/api/user/sync.go @@ -30,7 +30,7 @@ func HandleSync(syncer core.Syncer, repos core.RepositoryStore) http.HandlerFunc return func(w http.ResponseWriter, r *http.Request) { viewer, _ := request.UserFrom(r.Context()) - // performs asyncrhonous account synchronization. + // performs asynchronous account synchronization. // this requires long polling to determine when the // sync is complete. if r.FormValue("async") == "true" { @@ -57,7 +57,7 @@ func HandleSync(syncer core.Syncer, repos core.RepositoryStore) http.HandlerFunc if err != nil { render.InternalError(w, err) logger.FromRequest(r).WithError(err). - Warnln("api: cannot synchrnoize account") + Warnln("api: cannot synchronize account") } else { render.JSON(w, list, 200) } diff --git a/handler/api/users/create.go b/handler/api/users/create.go index d12c1d045..575680678 100644 --- a/handler/api/users/create.go +++ b/handler/api/users/create.go @@ -77,7 +77,7 @@ func HandleCreate(users core.UserStore, service core.UserService, sender core.We if err != nil { render.ErrorCode(w, err, 400) logger.FromRequest(r).WithError(err). - Errorln("api: invlid username") + Errorln("api: invalid username") return } diff --git a/handler/api/users/create_test.go b/handler/api/users/create_test.go index f57798362..77253edb6 100644 --- a/handler/api/users/create_test.go +++ b/handler/api/users/create_test.go @@ -30,7 +30,7 @@ func TestCreate(t *testing.T) { t.Errorf("Want user login %s, got %s", want, got) } if in.Hash == "" { - t.Errorf("Expect user secert generated") + t.Errorf("Expect user secret generated") } return nil }) diff --git a/handler/api/users/find.go b/handler/api/users/find.go index efdddd056..491bda8ee 100644 --- a/handler/api/users/find.go +++ b/handler/api/users/find.go @@ -35,7 +35,7 @@ func HandleFind(users core.UserStore) http.HandlerFunc { if err != nil { // the client can make a user request by providing // the user id as opposed to the username. If a - // numberic user id is provided as input, attempt + // numeric user id is provided as input, attempt // to lookup the user by id. if id, _ := strconv.ParseInt(login, 10, 64); id != 0 { user, err = users.Find(r.Context(), id) diff --git a/handler/web/login.go b/handler/web/login.go index d7ca7128a..08ee23e68 100644 --- a/handler/web/login.go +++ b/handler/web/login.go @@ -150,7 +150,7 @@ func HandleLogin( } // If the user account has never been synchronized we - // execute the synchonrization logic. + // execute the synchronization logic. if time.Unix(user.Synced, 0).Add(syncPeriod).Before(time.Now()) { user.Syncing = true } @@ -163,7 +163,7 @@ func HandleLogin( logger.Errorf("cannot update user: %s", err) } - // launch the synchrnoization process in a go-routine, + // launch the synchronization process in a go-routine, // since it is a long-running process and can take up // to a few minutes. if user.Syncing { diff --git a/operator/manager/manager.go b/operator/manager/manager.go index d8ed98496..af725702a 100644 --- a/operator/manager/manager.go +++ b/operator/manager/manager.go @@ -44,7 +44,7 @@ type ( System *core.System `json:"system"` } - // BuildManager encapsulets complex build operations and provides + // BuildManager encapsulates complex build operations and provides // a simplified interface for build runners. BuildManager interface { // Request requests the next available build stage for execution. @@ -60,13 +60,13 @@ type ( Details(ctx context.Context, stage int64) (*Context, error) // Before signals the build step is about to start. - Before(ctxt context.Context, step *core.Step) error + Before(ctx context.Context, step *core.Step) error // After signals the build step is complete. After(ctx context.Context, step *core.Step) error // Before signals the build stage is about to start. - BeforeAll(ctxt context.Context, stage *core.Stage) error + BeforeAll(ctx context.Context, stage *core.Stage) error // After signals the build stage is complete. AfterAll(ctx context.Context, stage *core.Stage) error @@ -84,7 +84,7 @@ type ( UploadBytes(ctx context.Context, step int64, b []byte) error } - // Request provildes filters when requesting a pending + // Request provides filters when requesting a pending // build from the queue. This allows an agent, for example, // to request a build that matches its architecture and kernel. Request struct { diff --git a/operator/manager/rpc/server_oss.go b/operator/manager/rpc/server_oss.go index c056b4c7c..6d068b6f4 100644 --- a/operator/manager/rpc/server_oss.go +++ b/operator/manager/rpc/server_oss.go @@ -58,7 +58,7 @@ func (Server) Details(ctx context.Context, stage int64) (*manager.Context, error } // Before signals the build step is about to start. -func (Server) Before(ctxt context.Context, step *core.Step) error { +func (Server) Before(ctx context.Context, step *core.Step) error { return errors.New("not implemented") } @@ -68,7 +68,7 @@ func (Server) After(ctx context.Context, step *core.Step) error { } // Before signals the build stage is about to start. -func (Server) BeforeAll(ctxt context.Context, stage *core.Stage) error { +func (Server) BeforeAll(ctx context.Context, stage *core.Stage) error { return errors.New("not implemented") } diff --git a/operator/manager/rpc2/handler.go b/operator/manager/rpc2/handler.go index 311299fbc..f901af222 100644 --- a/operator/manager/rpc2/handler.go +++ b/operator/manager/rpc2/handler.go @@ -69,7 +69,7 @@ func HandlePing() http.HandlerFunc { } // HandleRequest returns an http.HandlerFunc that processes an -// http.Request to reqeust a stage from the queue for execution. +// http.Request to request a stage from the queue for execution. // // POST /rpc/v2/stage func HandleRequest(m manager.BuildManager) http.HandlerFunc { @@ -135,7 +135,7 @@ func HandleInfo(m manager.BuildManager) http.HandlerFunc { writeJSON(w, &details{ Context: res, Netrc: netrc, - Repo: &repositroy{ + Repo: &repository{ Repository: res.Repo, Secret: res.Repo.Secret, }, diff --git a/operator/manager/rpc2/types.go b/operator/manager/rpc2/types.go index 5ec3f4970..f06749b76 100644 --- a/operator/manager/rpc2/types.go +++ b/operator/manager/rpc2/types.go @@ -16,12 +16,12 @@ import ( type details struct { *manager.Context Netrc *core.Netrc `json:"netrc"` - Repo *repositroy `json:"repository"` + Repo *repository `json:"repository"` } // repository wraps a repository object to include the secret // when the repository is marshaled to json. -type repositroy struct { +type repository struct { *core.Repository Secret string `json:"secret"` } diff --git a/operator/runner/machine/config.go b/operator/runner/machine/config.go index 03d36d6da..1fbe5fa36 100644 --- a/operator/runner/machine/config.go +++ b/operator/runner/machine/config.go @@ -38,7 +38,7 @@ type Config struct { } } -// heper function reads and unmarshales the docker-machine +// helper function reads and unmarshalls the docker-machine // configuration from a reader. func parseReader(r io.Reader) (*Config, error) { out := new(Config) diff --git a/operator/runner/machine/machine.go b/operator/runner/machine/machine.go index a2807aa1a..e25faf840 100644 --- a/operator/runner/machine/machine.go +++ b/operator/runner/machine/machine.go @@ -37,7 +37,7 @@ func Load(home, match string) ([]*Config, error) { if err != nil { return nil, err } - // If no match logic is defined, the matchine is + // If no match logic is defined, the machine is // automatically used as a build machine. if match == "" { machines = append(machines, conf) diff --git a/plugin/config/global_test.go b/plugin/config/global_test.go index 3d57ce759..6b2d85869 100644 --- a/plugin/config/global_test.go +++ b/plugin/config/global_test.go @@ -71,7 +71,7 @@ func TestGlobalErr(t *testing.T) { false, time.Minute) _, err := service.Find(noContext, args) if err == nil { - t.Errorf("Expect http.Reponse error") + t.Errorf("Expect http.Response error") } else if err.Error() != "Not Found" { t.Errorf("Expect Not Found error") } diff --git a/plugin/converter/jsonnet/jsonnet.go b/plugin/converter/jsonnet/jsonnet.go index bdb4efa2a..4f2b8998f 100644 --- a/plugin/converter/jsonnet/jsonnet.go +++ b/plugin/converter/jsonnet/jsonnet.go @@ -17,13 +17,13 @@ func Parse(req *core.ConvertArgs, template *core.Template, templateData map[stri vm.ErrorFormatter.SetMaxStackTraceSize(20) var jsonnetFile string - var jsonentFileName string + var jsonnetFileName string if template != nil { jsonnetFile = template.Data - jsonentFileName = template.Name + jsonnetFileName = template.Name } else { jsonnetFile = req.Config.Data - jsonentFileName = req.Repo.Config + jsonnetFileName = req.Repo.Config } // map external inputs if len(templateData) != 0 { @@ -35,9 +35,9 @@ func Parse(req *core.ConvertArgs, template *core.Template, templateData map[stri } // convert the jsonnet file to yaml buf := new(bytes.Buffer) - docs, err := vm.EvaluateSnippetStream(jsonentFileName, jsonnetFile) + docs, err := vm.EvaluateSnippetStream(jsonnetFileName, jsonnetFile) if err != nil { - doc, err2 := vm.EvaluateSnippet(jsonentFileName, jsonnetFile) + doc, err2 := vm.EvaluateSnippet(jsonnetFileName, jsonnetFile) if err2 != nil { return "", err } diff --git a/plugin/registry/encrypted.go b/plugin/registry/encrypted.go index 34fce12d2..e35d1be23 100644 --- a/plugin/registry/encrypted.go +++ b/plugin/registry/encrypted.go @@ -28,7 +28,7 @@ import ( ) // Encrypted returns a new encrypted registry credentials -// provider that sournces credentials from the encrypted strings +// provider that sources credentials from the encrypted strings // in the yaml file. func Encrypted() core.RegistryService { return new(encrypted) diff --git a/plugin/registry/endpoint_test.go b/plugin/registry/endpoint_test.go index 2694fce4d..e5bbde55e 100644 --- a/plugin/registry/endpoint_test.go +++ b/plugin/registry/endpoint_test.go @@ -67,7 +67,7 @@ func TestEndpointSource_Err(t *testing.T) { service := EndpointSource("https://company.com/auths", "GMEuUHQfmrMRsseWxi9YlIeBtn9lm6im", false) _, err := service.List(noContext, &core.RegistryArgs{Repo: &core.Repository{}, Build: &core.Build{}}) if err == nil { - t.Errorf("Expect http.Reponse error") + t.Errorf("Expect http.Response error") } else if err.Error() != "Not Found" { t.Errorf("Expect Not Found error") } diff --git a/scheduler/queue/queue.go b/scheduler/queue/queue.go index 72410036d..8deab988f 100644 --- a/scheduler/queue/queue.go +++ b/scheduler/queue/queue.go @@ -147,7 +147,7 @@ func (q *queue) signal(ctx context.Context) error { continue } - // if the system defines concurrencly limits + // if the system defines concurrency limits // per repository we need to make sure those limits // are not exceeded before proceeding. if shouldThrottle(item, items, item.LimitRepo) == true { @@ -275,7 +275,7 @@ func withinLimits(stage *core.Stage, siblings []*core.Stage) bool { } func shouldThrottle(stage *core.Stage, siblings []*core.Stage, limit int) bool { - // if no throttle limit is defined (defualt) then + // if no throttle limit is defined (default) then // return false to indicate no throttling is needed. if limit == 0 { return false diff --git a/scheduler/queue/queue_test.go b/scheduler/queue/queue_test.go index f15ac604a..6b534d56a 100644 --- a/scheduler/queue/queue_test.go +++ b/scheduler/queue/queue_test.go @@ -148,7 +148,7 @@ func TestMatchResource(t *testing.T) { for i, test := range tests { got, want := matchResource(test.kinda, test.typea, test.kindb, test.typeb), test.want if got != want { - t.Errorf("Unexpectd results at index %d", i) + t.Errorf("Unexpected results at index %d", i) } } } @@ -193,7 +193,7 @@ func TestShouldThrottle(t *testing.T) { for i, test := range tests { stage := stages[i] if got, want := shouldThrottle(stage, stages, stage.LimitRepo), test.Want; got != want { - t.Errorf("Unexpectd results at index %d", i) + t.Errorf("Unexpected results at index %d", i) } } } @@ -219,7 +219,7 @@ func TestWithinLimits(t *testing.T) { }, // stage with concurrency 1, no existing stages - // exist for same repositroy id. expect true. + // exist for same repository id. expect true. { result: true, stage: &core.Stage{ @@ -316,7 +316,7 @@ func TestWithinLimits(t *testing.T) { for i, test := range tests { if got, want := withinLimits(test.stage, test.stages), test.result; got != want { - t.Errorf("Unexpectd results at index %d", i) + t.Errorf("Unexpected results at index %d", i) } } } @@ -352,7 +352,7 @@ func TestWithinLimits_Old(t *testing.T) { for i, test := range tests { stage := stages[i] if got, want := withinLimits(stage, stages), test.Want; got != want { - t.Errorf("Unexpectd results at index %d", i) + t.Errorf("Unexpected results at index %d", i) } } } diff --git a/service/content/content.go b/service/content/content.go index 75300f789..9eeda4a79 100644 --- a/service/content/content.go +++ b/service/content/content.go @@ -49,7 +49,7 @@ type service struct { func (s *service) Find(ctx context.Context, user *core.User, repo, commit, ref, path string) (*core.File, error) { // TODO(gogs) ability to fetch a yaml by pull request ref. // it is not currently possible to fetch the yaml - // configuation file from a pull request sha. This + // configuration file from a pull request sha. This // workaround defaults to master. if s.client.Driver == scm.DriverGogs && strings.HasPrefix(ref, "refs/pull") { diff --git a/service/hook/parser/testdata/gitea_push.json b/service/hook/parser/testdata/gitea_push.json index d5fa3413e..2f9b3ca4b 100644 --- a/service/hook/parser/testdata/gitea_push.json +++ b/service/hook/parser/testdata/gitea_push.json @@ -38,4 +38,4 @@ "Email": "noreply@gogs.io", "Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } -} \ No newline at end of file +} diff --git a/service/hook/parser/testdata/gitea_tag.json b/service/hook/parser/testdata/gitea_tag.json index 9445f09e8..dacc2ac34 100644 --- a/service/hook/parser/testdata/gitea_tag.json +++ b/service/hook/parser/testdata/gitea_tag.json @@ -23,4 +23,4 @@ "Email": "noreply@gogs.io", "Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } -} \ No newline at end of file +} diff --git a/service/hook/parser/testdata/gogs_pull_create.json b/service/hook/parser/testdata/gogs_pull_create.json index 360bcbe2a..eb79219f5 100644 --- a/service/hook/parser/testdata/gogs_pull_create.json +++ b/service/hook/parser/testdata/gogs_pull_create.json @@ -40,4 +40,4 @@ "Email": "noreply@gogs.io", "Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } -} \ No newline at end of file +} diff --git a/service/hook/parser/testdata/gogs_push.json b/service/hook/parser/testdata/gogs_push.json index 32caf145a..15bb470f9 100644 --- a/service/hook/parser/testdata/gogs_push.json +++ b/service/hook/parser/testdata/gogs_push.json @@ -38,4 +38,4 @@ "Email": "noreply@gogs.io", "Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } -} \ No newline at end of file +} diff --git a/service/hook/parser/testdata/gogs_tag.json b/service/hook/parser/testdata/gogs_tag.json index a8e961b19..4f9ee41e1 100644 --- a/service/hook/parser/testdata/gogs_tag.json +++ b/service/hook/parser/testdata/gogs_tag.json @@ -23,4 +23,4 @@ "Email": "noreply@gogs.io", "Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87" } -} \ No newline at end of file +} diff --git a/service/syncer/util.go b/service/syncer/util.go index a445044df..82386e03a 100644 --- a/service/syncer/util.go +++ b/service/syncer/util.go @@ -19,7 +19,7 @@ import ( "github.com/drone/go-scm/scm" ) -// merge is a helper function that mergest a subset of +// merge is a helper function that merges a subset of // values from the source to the destination repository. func merge(dst, src *core.Repository) { dst.Namespace = src.Namespace diff --git a/session/session_test.go b/session/session_test.go index 65ba5cbed..9cada0bda 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -45,7 +45,7 @@ func TestGet_Token_QueryParam(t *testing.T) { } // This test verifies that a user is returned when a valid -// authorization token included in the Authorzation header. +// authorization token included in the Authorization header. func TestGet_Token_Header(t *testing.T) { controller := gomock.NewController(t) defer controller.Finish() diff --git a/store/repos/repos.go b/store/repos/repos.go index 53c32519d..1251f2712 100644 --- a/store/repos/repos.go +++ b/store/repos/repos.go @@ -298,7 +298,7 @@ SELECT ,repo_secret ` -const queryColsBulds = queryCols + ` +const queryColsBuilds = queryCols + ` ,build_id ,build_repo_id ,build_trigger @@ -488,7 +488,7 @@ WHERE repo_id = :repo_id // INNER JOIN perms ON perms.perm_repo_uid = repos.repo_uid // -const queryRepoWithBuild = queryColsBulds + ` +const queryRepoWithBuild = queryColsBuilds + ` FROM repos LEFT OUTER JOIN builds ON build_id = ( SELECT build_id FROM builds WHERE builds.build_repo_id = repos.repo_id @@ -500,7 +500,7 @@ WHERE perms.perm_user_id = :user_id ORDER BY repo_slug ASC ` -const queryRepoWithBuildPostgres = queryColsBulds + ` +const queryRepoWithBuildPostgres = queryColsBuilds + ` FROM repos LEFT OUTER JOIN builds ON build_id = ( SELECT DISTINCT ON (build_repo_id) build_id FROM builds WHERE builds.build_repo_id = repos.repo_id @@ -511,7 +511,7 @@ WHERE perms.perm_user_id = :user_id ORDER BY repo_slug ASC ` -const queryRepoWithBuildAll = queryColsBulds + ` +const queryRepoWithBuildAll = queryColsBuilds + ` FROM repos INNER JOIN perms ON perms.perm_repo_uid = repos.repo_uid INNER JOIN builds ON builds.build_repo_id = repos.repo_id @@ -520,7 +520,7 @@ ORDER BY build_id DESC LIMIT 25; ` -const queryRepoWithBuildIncomplete = queryColsBulds + ` +const queryRepoWithBuildIncomplete = queryColsBuilds + ` FROM repos INNER JOIN builds ON builds.build_repo_id = repos.repo_id WHERE EXISTS ( diff --git a/store/shared/db/conn.go b/store/shared/db/conn.go index 7b53513bc..3d32210f2 100644 --- a/store/shared/db/conn.go +++ b/store/shared/db/conn.go @@ -70,7 +70,7 @@ func pingDatabase(db *sql.DB) (err error) { return } -// helper function to setup the databsae by performing automated +// helper function to setup the database by performing automated // database migration steps. func setupDatabase(db *sql.DB, driver string) error { switch driver { diff --git a/store/shared/encrypt/aesgcm.go b/store/shared/encrypt/aesgcm.go index a7098e85e..831799394 100644 --- a/store/shared/encrypt/aesgcm.go +++ b/store/shared/encrypt/aesgcm.go @@ -21,8 +21,8 @@ import ( "io" ) -// Aesgcm provides an encryper that uses the aesgcm encryption -// alogirthm. +// Aesgcm provides an encrypter that uses the aesgcm encryption +// algorithm. type Aesgcm struct { block cipher.Block Compat bool @@ -56,7 +56,7 @@ func (e *Aesgcm) Decrypt(ciphertext []byte) (string, error) { // mode, it will return the ciphertext as plain text if // decryption fails. This should be used when running the // database in mixed-mode, where there is a mix of encrypted - // and unecrypted content. + // and unencrypted content. if e.Compat { return string(ciphertext), nil } @@ -72,7 +72,7 @@ func (e *Aesgcm) Decrypt(ciphertext []byte) (string, error) { // mode, it will return the ciphertext as plain text if // decryption fails. This should be used when running the // database in mixed-mode, where there is a mix of encrypted - // and unecrypted content. + // and unencrypted content. if err != nil && e.Compat { return string(ciphertext), nil } diff --git a/trigger/dag/dag_test.go b/trigger/dag/dag_test.go index ede561348..c387955b9 100644 --- a/trigger/dag/dag_test.go +++ b/trigger/dag/dag_test.go @@ -66,7 +66,7 @@ func TestAncestors(t *testing.T) { } if v := dag.Ancestors("backend"); len(v) != 0 { - t.Errorf("Expect vertexes with no dependences has zero ancestors") + t.Errorf("Expect vertexes with no dependencies has zero ancestors") } } diff --git a/trigger/skip.go b/trigger/skip.go index 6579b9b62..aba3d08ad 100644 --- a/trigger/skip.go +++ b/trigger/skip.go @@ -90,7 +90,7 @@ func skipMessageEval(str string) bool { // case len(paths) == 0: // return false // // github returns a maximum of 300 changed files from the -// // api response. If there are 300+ chagned files the system +// // api response. If there are 300+ changed files the system // // will force-run all pipelines and pipeline steps. // case len(paths) >= 300: // return false From 0fa03b03e0eb26adf8dd774ceffc0fb956582ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ga=C4=87e=C5=A1a?= Date: Wed, 16 Jun 2021 18:40:28 +0200 Subject: [PATCH 03/10] Limit graceful shutdown duration --- server/server.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/server.go b/server/server.go index 0c9c47510..4c1232412 100644 --- a/server/server.go +++ b/server/server.go @@ -37,6 +37,8 @@ type Server struct { Handler http.Handler } +const timeoutGracefulShutdown = 5 * time.Second + // ListenAndServe initializes a server to respond to HTTP network requests. func (s Server) ListenAndServe(ctx context.Context) error { if s.Acme { @@ -60,7 +62,7 @@ func (s Server) listenAndServe(ctx context.Context) error { g.Go(func() error { <-ctx.Done() - ctxShutdown, cancelFunc := context.WithTimeout(context.Background(), time.Minute) + ctxShutdown, cancelFunc := context.WithTimeout(context.Background(), timeoutGracefulShutdown) defer cancelFunc() return s1.Shutdown(ctxShutdown) @@ -94,7 +96,7 @@ func (s Server) listenAndServeTLS(ctx context.Context) error { <-ctx.Done() var gShutdown errgroup.Group - ctxShutdown, cancelFunc := context.WithTimeout(context.Background(), time.Minute) + ctxShutdown, cancelFunc := context.WithTimeout(context.Background(), timeoutGracefulShutdown) defer cancelFunc() gShutdown.Go(func() error { @@ -142,7 +144,7 @@ func (s Server) listenAndServeAcme(ctx context.Context) error { <-ctx.Done() var gShutdown errgroup.Group - ctxShutdown, cancelFunc := context.WithTimeout(context.Background(), time.Minute) + ctxShutdown, cancelFunc := context.WithTimeout(context.Background(), timeoutGracefulShutdown) defer cancelFunc() gShutdown.Go(func() error { From 1c04be59162b0fe5bfbf26bf8100cba6468943e4 Mon Sep 17 00:00:00 2001 From: Timofei Kushnir Date: Fri, 21 May 2021 14:03:35 +0300 Subject: [PATCH 04/10] Add ctx.build.debug boolean --- plugin/converter/starlark/args.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/converter/starlark/args.go b/plugin/converter/starlark/args.go index f31641d14..d9ebc61f8 100644 --- a/plugin/converter/starlark/args.go +++ b/plugin/converter/starlark/args.go @@ -83,6 +83,7 @@ func fromBuild(v *core.Build) starlark.StringDict { "author_email": starlark.String(v.AuthorEmail), "author_avatar": starlark.String(v.AuthorAvatar), "sender": starlark.String(v.Sender), + "debug": starlark.Bool(v.Debug), "params": fromMap(v.Params), } } From 9a763682f9cf6b032ab2614c144dd82627615de2 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 17 Jun 2021 10:19:51 +0100 Subject: [PATCH 05/10] handle error properly if template doesn't exist in the db --- plugin/converter/template.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/converter/template.go b/plugin/converter/template.go index dcd7aae0a..3f1513105 100644 --- a/plugin/converter/template.go +++ b/plugin/converter/template.go @@ -18,6 +18,7 @@ package converter import ( "context" + "database/sql" "errors" "regexp" "strings" @@ -63,12 +64,12 @@ func (p *templatePlugin) Convert(ctx context.Context, req *core.ConvertArgs) (*c } // get template from db template, err := p.templateStore.FindName(ctx, templateArgs.Load, req.Repo.Namespace) - if err != nil { - return nil, nil - } - if template == nil { + if err == sql.ErrNoRows { return nil, ErrTemplateNotFound } + if err != nil { + return nil, err + } // Check if file is of type Starlark if strings.HasSuffix(templateArgs.Load, ".script") || strings.HasSuffix(templateArgs.Load, ".star") || From 6b30b185f252b18ca105b46f7a3f8083299f771a Mon Sep 17 00:00:00 2001 From: Eoin McAfee <83226740+eoinmcafee00@users.noreply.github.com> Date: Thu, 17 Jun 2021 10:22:26 +0100 Subject: [PATCH 06/10] Task/update scm version (#3091) * bump go-scm to 1.9.0 --- go.mod | 2 +- go.sum | 4 + mock/mockscm/mock_gen.go | 240 ++++++++++++++++++++++----------------- 3 files changed, 141 insertions(+), 105 deletions(-) diff --git a/go.mod b/go.mod index 7485b5852..f51bc8197 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 github.com/drone/go-license v1.0.2 github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2 - github.com/drone/go-scm v1.8.0 + github.com/drone/go-scm v1.15.0 github.com/drone/signal v1.0.0 github.com/dustin/go-humanize v1.0.0 github.com/go-chi/chi v3.3.3+incompatible diff --git a/go.sum b/go.sum index 6dea19231..8405f5546 100644 --- a/go.sum +++ b/go.sum @@ -142,6 +142,10 @@ github.com/drone/go-scm v1.7.2-0.20201111225713-c0438b46084b h1:ivLeFPmHN+9sLMVA github.com/drone/go-scm v1.7.2-0.20201111225713-c0438b46084b/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= github.com/drone/go-scm v1.8.0 h1:kDHu38a11loKf6uaBu75TmY1YPwsSaZdseET738Oy0o= github.com/drone/go-scm v1.8.0/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= +github.com/drone/go-scm v1.9.0 h1:KgaGREXA7Ncu4ccdnk7p93hJwE8B8GLaBHfRprwtUCE= +github.com/drone/go-scm v1.9.0/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= +github.com/drone/go-scm v1.15.0 h1:yBO6lcCeegbEuEaH0QUvJmBVQS/RpYKzuzULHHMT2A4= +github.com/drone/go-scm v1.15.0/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI= github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= diff --git a/mock/mockscm/mock_gen.go b/mock/mockscm/mock_gen.go index bec1dd4e9..98d1d4c97 100644 --- a/mock/mockscm/mock_gen.go +++ b/mock/mockscm/mock_gen.go @@ -6,35 +6,36 @@ package mockscm import ( context "context" + reflect "reflect" + scm "github.com/drone/go-scm/scm" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockContentService is a mock of ContentService interface +// MockContentService is a mock of ContentService interface. type MockContentService struct { ctrl *gomock.Controller recorder *MockContentServiceMockRecorder } -// MockContentServiceMockRecorder is the mock recorder for MockContentService +// MockContentServiceMockRecorder is the mock recorder for MockContentService. type MockContentServiceMockRecorder struct { mock *MockContentService } -// NewMockContentService creates a new mock instance +// NewMockContentService creates a new mock instance. func NewMockContentService(ctrl *gomock.Controller) *MockContentService { mock := &MockContentService{ctrl: ctrl} mock.recorder = &MockContentServiceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockContentService) EXPECT() *MockContentServiceMockRecorder { return m.recorder } -// Create mocks base method +// Create mocks base method. func (m *MockContentService) Create(arg0 context.Context, arg1, arg2 string, arg3 *scm.ContentParams) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2, arg3) @@ -43,14 +44,14 @@ func (m *MockContentService) Create(arg0 context.Context, arg1, arg2 string, arg return ret0, ret1 } -// Create indicates an expected call of Create +// Create indicates an expected call of Create. func (mr *MockContentServiceMockRecorder) Create(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockContentService)(nil).Create), arg0, arg1, arg2, arg3) } -// Delete mocks base method -func (m *MockContentService) Delete(arg0 context.Context, arg1, arg2, arg3 string) (*scm.Response, error) { +// Delete mocks base method. +func (m *MockContentService) Delete(arg0 context.Context, arg1, arg2 string, arg3 *scm.ContentParams) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delete", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(*scm.Response) @@ -58,13 +59,13 @@ func (m *MockContentService) Delete(arg0 context.Context, arg1, arg2, arg3 strin return ret0, ret1 } -// Delete indicates an expected call of Delete +// Delete indicates an expected call of Delete. func (mr *MockContentServiceMockRecorder) Delete(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockContentService)(nil).Delete), arg0, arg1, arg2, arg3) } -// Find mocks base method +// Find mocks base method. func (m *MockContentService) Find(arg0 context.Context, arg1, arg2, arg3 string) (*scm.Content, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0, arg1, arg2, arg3) @@ -74,13 +75,13 @@ func (m *MockContentService) Find(arg0 context.Context, arg1, arg2, arg3 string) return ret0, ret1, ret2 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockContentServiceMockRecorder) Find(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockContentService)(nil).Find), arg0, arg1, arg2, arg3) } -// List mocks base method +// List mocks base method. func (m *MockContentService) List(arg0 context.Context, arg1, arg2, arg3 string, arg4 scm.ListOptions) ([]*scm.ContentInfo, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "List", arg0, arg1, arg2, arg3, arg4) @@ -90,13 +91,13 @@ func (m *MockContentService) List(arg0 context.Context, arg1, arg2, arg3 string, return ret0, ret1, ret2 } -// List indicates an expected call of List +// List indicates an expected call of List. func (mr *MockContentServiceMockRecorder) List(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockContentService)(nil).List), arg0, arg1, arg2, arg3, arg4) } -// Update mocks base method +// Update mocks base method. func (m *MockContentService) Update(arg0 context.Context, arg1, arg2 string, arg3 *scm.ContentParams) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Update", arg0, arg1, arg2, arg3) @@ -105,36 +106,36 @@ func (m *MockContentService) Update(arg0 context.Context, arg1, arg2 string, arg return ret0, ret1 } -// Update indicates an expected call of Update +// Update indicates an expected call of Update. func (mr *MockContentServiceMockRecorder) Update(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockContentService)(nil).Update), arg0, arg1, arg2, arg3) } -// MockGitService is a mock of GitService interface +// MockGitService is a mock of GitService interface. type MockGitService struct { ctrl *gomock.Controller recorder *MockGitServiceMockRecorder } -// MockGitServiceMockRecorder is the mock recorder for MockGitService +// MockGitServiceMockRecorder is the mock recorder for MockGitService. type MockGitServiceMockRecorder struct { mock *MockGitService } -// NewMockGitService creates a new mock instance +// NewMockGitService creates a new mock instance. func NewMockGitService(ctrl *gomock.Controller) *MockGitService { mock := &MockGitService{ctrl: ctrl} mock.recorder = &MockGitServiceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockGitService) EXPECT() *MockGitServiceMockRecorder { return m.recorder } -// CompareChanges mocks base method +// CompareChanges mocks base method. func (m *MockGitService) CompareChanges(arg0 context.Context, arg1, arg2, arg3 string, arg4 scm.ListOptions) ([]*scm.Change, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CompareChanges", arg0, arg1, arg2, arg3, arg4) @@ -144,13 +145,28 @@ func (m *MockGitService) CompareChanges(arg0 context.Context, arg1, arg2, arg3 s return ret0, ret1, ret2 } -// CompareChanges indicates an expected call of CompareChanges +// CompareChanges indicates an expected call of CompareChanges. func (mr *MockGitServiceMockRecorder) CompareChanges(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareChanges", reflect.TypeOf((*MockGitService)(nil).CompareChanges), arg0, arg1, arg2, arg3, arg4) } -// FindBranch mocks base method +// CreateBranch mocks base method. +func (m *MockGitService) CreateBranch(arg0 context.Context, arg1 string, arg2 *scm.CreateBranch) (*scm.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateBranch", arg0, arg1, arg2) + ret0, _ := ret[0].(*scm.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateBranch indicates an expected call of CreateBranch. +func (mr *MockGitServiceMockRecorder) CreateBranch(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBranch", reflect.TypeOf((*MockGitService)(nil).CreateBranch), arg0, arg1, arg2) +} + +// FindBranch mocks base method. func (m *MockGitService) FindBranch(arg0 context.Context, arg1, arg2 string) (*scm.Reference, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindBranch", arg0, arg1, arg2) @@ -160,13 +176,13 @@ func (m *MockGitService) FindBranch(arg0 context.Context, arg1, arg2 string) (*s return ret0, ret1, ret2 } -// FindBranch indicates an expected call of FindBranch +// FindBranch indicates an expected call of FindBranch. func (mr *MockGitServiceMockRecorder) FindBranch(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindBranch", reflect.TypeOf((*MockGitService)(nil).FindBranch), arg0, arg1, arg2) } -// FindCommit mocks base method +// FindCommit mocks base method. func (m *MockGitService) FindCommit(arg0 context.Context, arg1, arg2 string) (*scm.Commit, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindCommit", arg0, arg1, arg2) @@ -176,13 +192,13 @@ func (m *MockGitService) FindCommit(arg0 context.Context, arg1, arg2 string) (*s return ret0, ret1, ret2 } -// FindCommit indicates an expected call of FindCommit +// FindCommit indicates an expected call of FindCommit. func (mr *MockGitServiceMockRecorder) FindCommit(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindCommit", reflect.TypeOf((*MockGitService)(nil).FindCommit), arg0, arg1, arg2) } -// FindTag mocks base method +// FindTag mocks base method. func (m *MockGitService) FindTag(arg0 context.Context, arg1, arg2 string) (*scm.Reference, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindTag", arg0, arg1, arg2) @@ -192,13 +208,13 @@ func (m *MockGitService) FindTag(arg0 context.Context, arg1, arg2 string) (*scm. return ret0, ret1, ret2 } -// FindTag indicates an expected call of FindTag +// FindTag indicates an expected call of FindTag. func (mr *MockGitServiceMockRecorder) FindTag(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindTag", reflect.TypeOf((*MockGitService)(nil).FindTag), arg0, arg1, arg2) } -// ListBranches mocks base method +// ListBranches mocks base method. func (m *MockGitService) ListBranches(arg0 context.Context, arg1 string, arg2 scm.ListOptions) ([]*scm.Reference, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListBranches", arg0, arg1, arg2) @@ -208,13 +224,13 @@ func (m *MockGitService) ListBranches(arg0 context.Context, arg1 string, arg2 sc return ret0, ret1, ret2 } -// ListBranches indicates an expected call of ListBranches +// ListBranches indicates an expected call of ListBranches. func (mr *MockGitServiceMockRecorder) ListBranches(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListBranches", reflect.TypeOf((*MockGitService)(nil).ListBranches), arg0, arg1, arg2) } -// ListChanges mocks base method +// ListChanges mocks base method. func (m *MockGitService) ListChanges(arg0 context.Context, arg1, arg2 string, arg3 scm.ListOptions) ([]*scm.Change, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListChanges", arg0, arg1, arg2, arg3) @@ -224,13 +240,13 @@ func (m *MockGitService) ListChanges(arg0 context.Context, arg1, arg2 string, ar return ret0, ret1, ret2 } -// ListChanges indicates an expected call of ListChanges +// ListChanges indicates an expected call of ListChanges. func (mr *MockGitServiceMockRecorder) ListChanges(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListChanges", reflect.TypeOf((*MockGitService)(nil).ListChanges), arg0, arg1, arg2, arg3) } -// ListCommits mocks base method +// ListCommits mocks base method. func (m *MockGitService) ListCommits(arg0 context.Context, arg1 string, arg2 scm.CommitListOptions) ([]*scm.Commit, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListCommits", arg0, arg1, arg2) @@ -240,13 +256,13 @@ func (m *MockGitService) ListCommits(arg0 context.Context, arg1 string, arg2 scm return ret0, ret1, ret2 } -// ListCommits indicates an expected call of ListCommits +// ListCommits indicates an expected call of ListCommits. func (mr *MockGitServiceMockRecorder) ListCommits(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListCommits", reflect.TypeOf((*MockGitService)(nil).ListCommits), arg0, arg1, arg2) } -// ListTags mocks base method +// ListTags mocks base method. func (m *MockGitService) ListTags(arg0 context.Context, arg1 string, arg2 scm.ListOptions) ([]*scm.Reference, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListTags", arg0, arg1, arg2) @@ -256,36 +272,36 @@ func (m *MockGitService) ListTags(arg0 context.Context, arg1 string, arg2 scm.Li return ret0, ret1, ret2 } -// ListTags indicates an expected call of ListTags +// ListTags indicates an expected call of ListTags. func (mr *MockGitServiceMockRecorder) ListTags(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListTags", reflect.TypeOf((*MockGitService)(nil).ListTags), arg0, arg1, arg2) } -// MockOrganizationService is a mock of OrganizationService interface +// MockOrganizationService is a mock of OrganizationService interface. type MockOrganizationService struct { ctrl *gomock.Controller recorder *MockOrganizationServiceMockRecorder } -// MockOrganizationServiceMockRecorder is the mock recorder for MockOrganizationService +// MockOrganizationServiceMockRecorder is the mock recorder for MockOrganizationService. type MockOrganizationServiceMockRecorder struct { mock *MockOrganizationService } -// NewMockOrganizationService creates a new mock instance +// NewMockOrganizationService creates a new mock instance. func NewMockOrganizationService(ctrl *gomock.Controller) *MockOrganizationService { mock := &MockOrganizationService{ctrl: ctrl} mock.recorder = &MockOrganizationServiceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockOrganizationService) EXPECT() *MockOrganizationServiceMockRecorder { return m.recorder } -// Find mocks base method +// Find mocks base method. func (m *MockOrganizationService) Find(arg0 context.Context, arg1 string) (*scm.Organization, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0, arg1) @@ -295,13 +311,13 @@ func (m *MockOrganizationService) Find(arg0 context.Context, arg1 string) (*scm. return ret0, ret1, ret2 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockOrganizationServiceMockRecorder) Find(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockOrganizationService)(nil).Find), arg0, arg1) } -// FindMembership mocks base method +// FindMembership mocks base method. func (m *MockOrganizationService) FindMembership(arg0 context.Context, arg1, arg2 string) (*scm.Membership, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindMembership", arg0, arg1, arg2) @@ -311,13 +327,13 @@ func (m *MockOrganizationService) FindMembership(arg0 context.Context, arg1, arg return ret0, ret1, ret2 } -// FindMembership indicates an expected call of FindMembership +// FindMembership indicates an expected call of FindMembership. func (mr *MockOrganizationServiceMockRecorder) FindMembership(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindMembership", reflect.TypeOf((*MockOrganizationService)(nil).FindMembership), arg0, arg1, arg2) } -// List mocks base method +// List mocks base method. func (m *MockOrganizationService) List(arg0 context.Context, arg1 scm.ListOptions) ([]*scm.Organization, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "List", arg0, arg1) @@ -327,36 +343,36 @@ func (m *MockOrganizationService) List(arg0 context.Context, arg1 scm.ListOption return ret0, ret1, ret2 } -// List indicates an expected call of List +// List indicates an expected call of List. func (mr *MockOrganizationServiceMockRecorder) List(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockOrganizationService)(nil).List), arg0, arg1) } -// MockPullRequestService is a mock of PullRequestService interface +// MockPullRequestService is a mock of PullRequestService interface. type MockPullRequestService struct { ctrl *gomock.Controller recorder *MockPullRequestServiceMockRecorder } -// MockPullRequestServiceMockRecorder is the mock recorder for MockPullRequestService +// MockPullRequestServiceMockRecorder is the mock recorder for MockPullRequestService. type MockPullRequestServiceMockRecorder struct { mock *MockPullRequestService } -// NewMockPullRequestService creates a new mock instance +// NewMockPullRequestService creates a new mock instance. func NewMockPullRequestService(ctrl *gomock.Controller) *MockPullRequestService { mock := &MockPullRequestService{ctrl: ctrl} mock.recorder = &MockPullRequestServiceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockPullRequestService) EXPECT() *MockPullRequestServiceMockRecorder { return m.recorder } -// Close mocks base method +// Close mocks base method. func (m *MockPullRequestService) Close(arg0 context.Context, arg1 string, arg2 int) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Close", arg0, arg1, arg2) @@ -365,13 +381,13 @@ func (m *MockPullRequestService) Close(arg0 context.Context, arg1 string, arg2 i return ret0, ret1 } -// Close indicates an expected call of Close +// Close indicates an expected call of Close. func (mr *MockPullRequestServiceMockRecorder) Close(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPullRequestService)(nil).Close), arg0, arg1, arg2) } -// Create mocks base method +// Create mocks base method. func (m *MockPullRequestService) Create(arg0 context.Context, arg1 string, arg2 *scm.PullRequestInput) (*scm.PullRequest, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Create", arg0, arg1, arg2) @@ -381,13 +397,13 @@ func (m *MockPullRequestService) Create(arg0 context.Context, arg1 string, arg2 return ret0, ret1, ret2 } -// Create indicates an expected call of Create +// Create indicates an expected call of Create. func (mr *MockPullRequestServiceMockRecorder) Create(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockPullRequestService)(nil).Create), arg0, arg1, arg2) } -// CreateComment mocks base method +// CreateComment mocks base method. func (m *MockPullRequestService) CreateComment(arg0 context.Context, arg1 string, arg2 int, arg3 *scm.CommentInput) (*scm.Comment, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateComment", arg0, arg1, arg2, arg3) @@ -397,13 +413,13 @@ func (m *MockPullRequestService) CreateComment(arg0 context.Context, arg1 string return ret0, ret1, ret2 } -// CreateComment indicates an expected call of CreateComment +// CreateComment indicates an expected call of CreateComment. func (mr *MockPullRequestServiceMockRecorder) CreateComment(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateComment", reflect.TypeOf((*MockPullRequestService)(nil).CreateComment), arg0, arg1, arg2, arg3) } -// DeleteComment mocks base method +// DeleteComment mocks base method. func (m *MockPullRequestService) DeleteComment(arg0 context.Context, arg1 string, arg2, arg3 int) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteComment", arg0, arg1, arg2, arg3) @@ -412,13 +428,13 @@ func (m *MockPullRequestService) DeleteComment(arg0 context.Context, arg1 string return ret0, ret1 } -// DeleteComment indicates an expected call of DeleteComment +// DeleteComment indicates an expected call of DeleteComment. func (mr *MockPullRequestServiceMockRecorder) DeleteComment(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteComment", reflect.TypeOf((*MockPullRequestService)(nil).DeleteComment), arg0, arg1, arg2, arg3) } -// Find mocks base method +// Find mocks base method. func (m *MockPullRequestService) Find(arg0 context.Context, arg1 string, arg2 int) (*scm.PullRequest, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0, arg1, arg2) @@ -428,13 +444,13 @@ func (m *MockPullRequestService) Find(arg0 context.Context, arg1 string, arg2 in return ret0, ret1, ret2 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockPullRequestServiceMockRecorder) Find(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockPullRequestService)(nil).Find), arg0, arg1, arg2) } -// FindComment mocks base method +// FindComment mocks base method. func (m *MockPullRequestService) FindComment(arg0 context.Context, arg1 string, arg2, arg3 int) (*scm.Comment, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindComment", arg0, arg1, arg2, arg3) @@ -444,13 +460,13 @@ func (m *MockPullRequestService) FindComment(arg0 context.Context, arg1 string, return ret0, ret1, ret2 } -// FindComment indicates an expected call of FindComment +// FindComment indicates an expected call of FindComment. func (mr *MockPullRequestServiceMockRecorder) FindComment(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindComment", reflect.TypeOf((*MockPullRequestService)(nil).FindComment), arg0, arg1, arg2, arg3) } -// List mocks base method +// List mocks base method. func (m *MockPullRequestService) List(arg0 context.Context, arg1 string, arg2 scm.PullRequestListOptions) ([]*scm.PullRequest, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "List", arg0, arg1, arg2) @@ -460,13 +476,13 @@ func (m *MockPullRequestService) List(arg0 context.Context, arg1 string, arg2 sc return ret0, ret1, ret2 } -// List indicates an expected call of List +// List indicates an expected call of List. func (mr *MockPullRequestServiceMockRecorder) List(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockPullRequestService)(nil).List), arg0, arg1, arg2) } -// ListChanges mocks base method +// ListChanges mocks base method. func (m *MockPullRequestService) ListChanges(arg0 context.Context, arg1 string, arg2 int, arg3 scm.ListOptions) ([]*scm.Change, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListChanges", arg0, arg1, arg2, arg3) @@ -476,13 +492,13 @@ func (m *MockPullRequestService) ListChanges(arg0 context.Context, arg1 string, return ret0, ret1, ret2 } -// ListChanges indicates an expected call of ListChanges +// ListChanges indicates an expected call of ListChanges. func (mr *MockPullRequestServiceMockRecorder) ListChanges(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListChanges", reflect.TypeOf((*MockPullRequestService)(nil).ListChanges), arg0, arg1, arg2, arg3) } -// ListComments mocks base method +// ListComments mocks base method. func (m *MockPullRequestService) ListComments(arg0 context.Context, arg1 string, arg2 int, arg3 scm.ListOptions) ([]*scm.Comment, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListComments", arg0, arg1, arg2, arg3) @@ -492,13 +508,29 @@ func (m *MockPullRequestService) ListComments(arg0 context.Context, arg1 string, return ret0, ret1, ret2 } -// ListComments indicates an expected call of ListComments +// ListComments indicates an expected call of ListComments. func (mr *MockPullRequestServiceMockRecorder) ListComments(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListComments", reflect.TypeOf((*MockPullRequestService)(nil).ListComments), arg0, arg1, arg2, arg3) } -// Merge mocks base method +// ListCommits mocks base method. +func (m *MockPullRequestService) ListCommits(arg0 context.Context, arg1 string, arg2 int, arg3 scm.ListOptions) ([]*scm.Commit, *scm.Response, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListCommits", arg0, arg1, arg2, arg3) + ret0, _ := ret[0].([]*scm.Commit) + ret1, _ := ret[1].(*scm.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// ListCommits indicates an expected call of ListCommits. +func (mr *MockPullRequestServiceMockRecorder) ListCommits(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListCommits", reflect.TypeOf((*MockPullRequestService)(nil).ListCommits), arg0, arg1, arg2, arg3) +} + +// Merge mocks base method. func (m *MockPullRequestService) Merge(arg0 context.Context, arg1 string, arg2 int) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Merge", arg0, arg1, arg2) @@ -507,36 +539,36 @@ func (m *MockPullRequestService) Merge(arg0 context.Context, arg1 string, arg2 i return ret0, ret1 } -// Merge indicates an expected call of Merge +// Merge indicates an expected call of Merge. func (mr *MockPullRequestServiceMockRecorder) Merge(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Merge", reflect.TypeOf((*MockPullRequestService)(nil).Merge), arg0, arg1, arg2) } -// MockRepositoryService is a mock of RepositoryService interface +// MockRepositoryService is a mock of RepositoryService interface. type MockRepositoryService struct { ctrl *gomock.Controller recorder *MockRepositoryServiceMockRecorder } -// MockRepositoryServiceMockRecorder is the mock recorder for MockRepositoryService +// MockRepositoryServiceMockRecorder is the mock recorder for MockRepositoryService. type MockRepositoryServiceMockRecorder struct { mock *MockRepositoryService } -// NewMockRepositoryService creates a new mock instance +// NewMockRepositoryService creates a new mock instance. func NewMockRepositoryService(ctrl *gomock.Controller) *MockRepositoryService { mock := &MockRepositoryService{ctrl: ctrl} mock.recorder = &MockRepositoryServiceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockRepositoryService) EXPECT() *MockRepositoryServiceMockRecorder { return m.recorder } -// CreateHook mocks base method +// CreateHook mocks base method. func (m *MockRepositoryService) CreateHook(arg0 context.Context, arg1 string, arg2 *scm.HookInput) (*scm.Hook, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateHook", arg0, arg1, arg2) @@ -546,13 +578,13 @@ func (m *MockRepositoryService) CreateHook(arg0 context.Context, arg1 string, ar return ret0, ret1, ret2 } -// CreateHook indicates an expected call of CreateHook +// CreateHook indicates an expected call of CreateHook. func (mr *MockRepositoryServiceMockRecorder) CreateHook(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateHook", reflect.TypeOf((*MockRepositoryService)(nil).CreateHook), arg0, arg1, arg2) } -// CreateStatus mocks base method +// CreateStatus mocks base method. func (m *MockRepositoryService) CreateStatus(arg0 context.Context, arg1, arg2 string, arg3 *scm.StatusInput) (*scm.Status, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateStatus", arg0, arg1, arg2, arg3) @@ -562,13 +594,13 @@ func (m *MockRepositoryService) CreateStatus(arg0 context.Context, arg1, arg2 st return ret0, ret1, ret2 } -// CreateStatus indicates an expected call of CreateStatus +// CreateStatus indicates an expected call of CreateStatus. func (mr *MockRepositoryServiceMockRecorder) CreateStatus(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateStatus", reflect.TypeOf((*MockRepositoryService)(nil).CreateStatus), arg0, arg1, arg2, arg3) } -// DeleteHook mocks base method +// DeleteHook mocks base method. func (m *MockRepositoryService) DeleteHook(arg0 context.Context, arg1, arg2 string) (*scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteHook", arg0, arg1, arg2) @@ -577,13 +609,13 @@ func (m *MockRepositoryService) DeleteHook(arg0 context.Context, arg1, arg2 stri return ret0, ret1 } -// DeleteHook indicates an expected call of DeleteHook +// DeleteHook indicates an expected call of DeleteHook. func (mr *MockRepositoryServiceMockRecorder) DeleteHook(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteHook", reflect.TypeOf((*MockRepositoryService)(nil).DeleteHook), arg0, arg1, arg2) } -// Find mocks base method +// Find mocks base method. func (m *MockRepositoryService) Find(arg0 context.Context, arg1 string) (*scm.Repository, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0, arg1) @@ -593,13 +625,13 @@ func (m *MockRepositoryService) Find(arg0 context.Context, arg1 string) (*scm.Re return ret0, ret1, ret2 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockRepositoryServiceMockRecorder) Find(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockRepositoryService)(nil).Find), arg0, arg1) } -// FindHook mocks base method +// FindHook mocks base method. func (m *MockRepositoryService) FindHook(arg0 context.Context, arg1, arg2 string) (*scm.Hook, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindHook", arg0, arg1, arg2) @@ -609,13 +641,13 @@ func (m *MockRepositoryService) FindHook(arg0 context.Context, arg1, arg2 string return ret0, ret1, ret2 } -// FindHook indicates an expected call of FindHook +// FindHook indicates an expected call of FindHook. func (mr *MockRepositoryServiceMockRecorder) FindHook(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindHook", reflect.TypeOf((*MockRepositoryService)(nil).FindHook), arg0, arg1, arg2) } -// FindPerms mocks base method +// FindPerms mocks base method. func (m *MockRepositoryService) FindPerms(arg0 context.Context, arg1 string) (*scm.Perm, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindPerms", arg0, arg1) @@ -625,13 +657,13 @@ func (m *MockRepositoryService) FindPerms(arg0 context.Context, arg1 string) (*s return ret0, ret1, ret2 } -// FindPerms indicates an expected call of FindPerms +// FindPerms indicates an expected call of FindPerms. func (mr *MockRepositoryServiceMockRecorder) FindPerms(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindPerms", reflect.TypeOf((*MockRepositoryService)(nil).FindPerms), arg0, arg1) } -// List mocks base method +// List mocks base method. func (m *MockRepositoryService) List(arg0 context.Context, arg1 scm.ListOptions) ([]*scm.Repository, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "List", arg0, arg1) @@ -641,13 +673,13 @@ func (m *MockRepositoryService) List(arg0 context.Context, arg1 scm.ListOptions) return ret0, ret1, ret2 } -// List indicates an expected call of List +// List indicates an expected call of List. func (mr *MockRepositoryServiceMockRecorder) List(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockRepositoryService)(nil).List), arg0, arg1) } -// ListHooks mocks base method +// ListHooks mocks base method. func (m *MockRepositoryService) ListHooks(arg0 context.Context, arg1 string, arg2 scm.ListOptions) ([]*scm.Hook, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListHooks", arg0, arg1, arg2) @@ -657,13 +689,13 @@ func (m *MockRepositoryService) ListHooks(arg0 context.Context, arg1 string, arg return ret0, ret1, ret2 } -// ListHooks indicates an expected call of ListHooks +// ListHooks indicates an expected call of ListHooks. func (mr *MockRepositoryServiceMockRecorder) ListHooks(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListHooks", reflect.TypeOf((*MockRepositoryService)(nil).ListHooks), arg0, arg1, arg2) } -// ListStatus mocks base method +// ListStatus mocks base method. func (m *MockRepositoryService) ListStatus(arg0 context.Context, arg1, arg2 string, arg3 scm.ListOptions) ([]*scm.Status, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListStatus", arg0, arg1, arg2, arg3) @@ -673,13 +705,13 @@ func (m *MockRepositoryService) ListStatus(arg0 context.Context, arg1, arg2 stri return ret0, ret1, ret2 } -// ListStatus indicates an expected call of ListStatus +// ListStatus indicates an expected call of ListStatus. func (mr *MockRepositoryServiceMockRecorder) ListStatus(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListStatus", reflect.TypeOf((*MockRepositoryService)(nil).ListStatus), arg0, arg1, arg2, arg3) } -// UpdateHook mocks base method +// UpdateHook mocks base method. func (m *MockRepositoryService) UpdateHook(arg0 context.Context, arg1, arg2 string, arg3 *scm.HookInput) (*scm.Hook, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateHook", arg0, arg1, arg2, arg3) @@ -689,36 +721,36 @@ func (m *MockRepositoryService) UpdateHook(arg0 context.Context, arg1, arg2 stri return ret0, ret1, ret2 } -// UpdateHook indicates an expected call of UpdateHook +// UpdateHook indicates an expected call of UpdateHook. func (mr *MockRepositoryServiceMockRecorder) UpdateHook(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateHook", reflect.TypeOf((*MockRepositoryService)(nil).UpdateHook), arg0, arg1, arg2, arg3) } -// MockUserService is a mock of UserService interface +// MockUserService is a mock of UserService interface. type MockUserService struct { ctrl *gomock.Controller recorder *MockUserServiceMockRecorder } -// MockUserServiceMockRecorder is the mock recorder for MockUserService +// MockUserServiceMockRecorder is the mock recorder for MockUserService. type MockUserServiceMockRecorder struct { mock *MockUserService } -// NewMockUserService creates a new mock instance +// NewMockUserService creates a new mock instance. func NewMockUserService(ctrl *gomock.Controller) *MockUserService { mock := &MockUserService{ctrl: ctrl} mock.recorder = &MockUserServiceMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockUserService) EXPECT() *MockUserServiceMockRecorder { return m.recorder } -// Find mocks base method +// Find mocks base method. func (m *MockUserService) Find(arg0 context.Context) (*scm.User, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Find", arg0) @@ -728,13 +760,13 @@ func (m *MockUserService) Find(arg0 context.Context) (*scm.User, *scm.Response, return ret0, ret1, ret2 } -// Find indicates an expected call of Find +// Find indicates an expected call of Find. func (mr *MockUserServiceMockRecorder) Find(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Find", reflect.TypeOf((*MockUserService)(nil).Find), arg0) } -// FindEmail mocks base method +// FindEmail mocks base method. func (m *MockUserService) FindEmail(arg0 context.Context) (string, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindEmail", arg0) @@ -744,13 +776,13 @@ func (m *MockUserService) FindEmail(arg0 context.Context) (string, *scm.Response return ret0, ret1, ret2 } -// FindEmail indicates an expected call of FindEmail +// FindEmail indicates an expected call of FindEmail. func (mr *MockUserServiceMockRecorder) FindEmail(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindEmail", reflect.TypeOf((*MockUserService)(nil).FindEmail), arg0) } -// FindLogin mocks base method +// FindLogin mocks base method. func (m *MockUserService) FindLogin(arg0 context.Context, arg1 string) (*scm.User, *scm.Response, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FindLogin", arg0, arg1) @@ -760,7 +792,7 @@ func (m *MockUserService) FindLogin(arg0 context.Context, arg1 string) (*scm.Use return ret0, ret1, ret2 } -// FindLogin indicates an expected call of FindLogin +// FindLogin indicates an expected call of FindLogin. func (mr *MockUserServiceMockRecorder) FindLogin(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLogin", reflect.TypeOf((*MockUserService)(nil).FindLogin), arg0, arg1) From 685e6766a75c33f569b17f39404ebc121f6b2554 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 17 Jun 2021 11:17:04 +0100 Subject: [PATCH 07/10] fix issue with kicking off builds using bitbucket server --- service/commit/commit.go | 1 + 1 file changed, 1 insertion(+) diff --git a/service/commit/commit.go b/service/commit/commit.go index bf5fd89f2..2f45a4ea3 100644 --- a/service/commit/commit.go +++ b/service/commit/commit.go @@ -79,6 +79,7 @@ func (s *service) FindRef(ctx context.Context, user *core.User, repo, ref string switch s.client.Driver { case scm.DriverBitbucket: + case scm.DriverStash: ref = scm.TrimRef(ref) branch, _, err := s.client.Git.FindBranch(ctx, repo, ref) // wont work for a Tag if err != nil { From 79ddd384c173062cc64154a3510b0e682ac8db1a Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 17 Jun 2021 12:31:31 +0100 Subject: [PATCH 08/10] bump go-scm v1.15.1 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f51bc8197..6b3d98b69 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 github.com/drone/go-license v1.0.2 github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2 - github.com/drone/go-scm v1.15.0 + github.com/drone/go-scm v1.15.1 github.com/drone/signal v1.0.0 github.com/dustin/go-humanize v1.0.0 github.com/go-chi/chi v3.3.3+incompatible diff --git a/go.sum b/go.sum index 8405f5546..cdf41aafd 100644 --- a/go.sum +++ b/go.sum @@ -146,6 +146,8 @@ github.com/drone/go-scm v1.9.0 h1:KgaGREXA7Ncu4ccdnk7p93hJwE8B8GLaBHfRprwtUCE= github.com/drone/go-scm v1.9.0/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= github.com/drone/go-scm v1.15.0 h1:yBO6lcCeegbEuEaH0QUvJmBVQS/RpYKzuzULHHMT2A4= github.com/drone/go-scm v1.15.0/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= +github.com/drone/go-scm v1.15.1 h1:35m/CcHkYjQ4BlOM7rIIwrki6uDUbUH+Kkb9rv6om3M= +github.com/drone/go-scm v1.15.1/go.mod h1:lXwfbyrIJwFFME5TpzavkwO2T5X8yBK6t6cve7g91x0= github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI= github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= From 8fe5a54b59d225eba5d127e42330e434589a3cb5 Mon Sep 17 00:00:00 2001 From: tphoney Date: Wed, 24 Feb 2021 15:02:42 +0000 Subject: [PATCH 09/10] (feat) adding depends_on, image and detached fields to step --- core/step.go | 25 +++++++----- scripts/build.sh | 0 store/shared/migrate/README.md | 32 +++++++++++++++ store/shared/migrate/mysql/ddl_gen.go | 28 +++++++++++++ .../mysql/files/016_add_columns_steps.sql | 11 +++++ store/shared/migrate/postgres/ddl_gen.go | 28 +++++++++++++ .../postgres/files/017_add_columns_steps.sql | 11 +++++ store/shared/migrate/sqlite/ddl_gen.go | 28 +++++++++++++ .../sqlite/files/016_add_columns_steps.sql | 11 +++++ store/stage/scan.go | 5 +++ store/stage/stage.go | 9 +++++ store/stage/type.go | 15 ++++++- store/step/scan.go | 40 +++++++++++++------ store/step/step.go | 12 ++++++ store/step/step_test.go | 17 ++++---- 15 files changed, 241 insertions(+), 31 deletions(-) mode change 100644 => 100755 scripts/build.sh create mode 100644 store/shared/migrate/README.md create mode 100644 store/shared/migrate/mysql/files/016_add_columns_steps.sql create mode 100644 store/shared/migrate/postgres/files/017_add_columns_steps.sql create mode 100644 store/shared/migrate/sqlite/files/016_add_columns_steps.sql diff --git a/core/step.go b/core/step.go index 76d505b48..495564329 100644 --- a/core/step.go +++ b/core/step.go @@ -19,17 +19,20 @@ import "context" type ( // Step represents an individual step in the stage. Step struct { - ID int64 `json:"id"` - StageID int64 `json:"step_id"` - Number int `json:"number"` - Name string `json:"name"` - Status string `json:"status"` - Error string `json:"error,omitempty"` - ErrIgnore bool `json:"errignore,omitempty"` - ExitCode int `json:"exit_code"` - Started int64 `json:"started,omitempty"` - Stopped int64 `json:"stopped,omitempty"` - Version int64 `json:"version"` + ID int64 `json:"id"` + StageID int64 `json:"step_id"` + Number int `json:"number"` + Name string `json:"name"` + Status string `json:"status"` + Error string `json:"error,omitempty"` + ErrIgnore bool `json:"errignore,omitempty"` + ExitCode int `json:"exit_code"` + Started int64 `json:"started,omitempty"` + Stopped int64 `json:"stopped,omitempty"` + Version int64 `json:"version"` + DependsOn []string `json:"depends_on,omitempty"` + Image string `json:"image,omitempty"` + Detached bool `json:"detached,omitempty"` } // StepStore persists build step information to storage. diff --git a/scripts/build.sh b/scripts/build.sh old mode 100644 new mode 100755 diff --git a/store/shared/migrate/README.md b/store/shared/migrate/README.md new file mode 100644 index 000000000..a31b79963 --- /dev/null +++ b/store/shared/migrate/README.md @@ -0,0 +1,32 @@ +# Building SQL DDL into Drone + +These folders contain the code for the different of databases that drone can use. They contain the SQL necessary to create the necessary tables and migrate between versions (IE the DDL). This SQL is generated into a go file and included as part of the Drone binary. + +## Making a changes to the database DDL + +Any new changes to the database structure are always put into a new SQL file. Follow the naming scheme in the `store/shared/migrate//files` of the SQL files by incrementing the number file name and give it a good description of what changes are being made. + +Changes will need to be implemented for all supported databases, making similar changes for eg Mysql/Postgres/Sqllite. + +**NB** Any changes to the database structure will need to be reflected for the relevant `struct` in the `core` directory. Changing the objects in the `store` directory for the ORM. Finally Possibly in the repositories github.com/drone/drone-go and github.com/drone/runner-go. + +## Generating Go from the SQL files + +To generate the go files you will need to install the golang command line tool `Togo` so it is on your users PATH. + +### Steps to install Togo + +``` bash +# in your workspace +git clone git@github.com:bradrydzewski/togo.git +cd togo +go get github.com/bradrydzewski/togo +``` + +### Generating go DDL + +Enter the desired database's implementation folder, and run the following. It will update the `ddl_gen.go` file. + +``` bash +go generate +``` diff --git a/store/shared/migrate/mysql/ddl_gen.go b/store/shared/migrate/mysql/ddl_gen.go index f60b6098c..37af63600 100644 --- a/store/shared/migrate/mysql/ddl_gen.go +++ b/store/shared/migrate/mysql/ddl_gen.go @@ -164,6 +164,18 @@ var migrations = []struct { name: "create-index-template-namespace", stmt: createIndexTemplateNamespace, }, + { + name: "alter-table-steps-add-column-step-depends-on", + stmt: alterTableStepsAddColumnStepDependsOn, + }, + { + name: "alter-table-steps-add-column-step-image", + stmt: alterTableStepsAddColumnStepImage, + }, + { + name: "alter-table-steps-add-column-step-detached", + stmt: alterTableStepsAddColumnStepDetached, + }, } // Migrate performs the database migration. If the migration fails @@ -686,3 +698,19 @@ CREATE TABLE IF NOT EXISTS templates ( var createIndexTemplateNamespace = ` CREATE INDEX ix_template_namespace ON templates (template_namespace); ` + +// +// 016_add_columns_steps.sql +// + +var alterTableStepsAddColumnStepDependsOn = ` +ALTER TABLE steps ADD COLUMN step_depends_on TEXT NULL; +` + +var alterTableStepsAddColumnStepImage = ` +ALTER TABLE steps ADD COLUMN step_image VARCHAR(1000) NOT NULL DEFAULT ''; +` + +var alterTableStepsAddColumnStepDetached = ` +ALTER TABLE steps ADD COLUMN step_detached BOOLEAN NOT NULL DEFAULT FALSE; +` diff --git a/store/shared/migrate/mysql/files/016_add_columns_steps.sql b/store/shared/migrate/mysql/files/016_add_columns_steps.sql new file mode 100644 index 000000000..6df6c67c1 --- /dev/null +++ b/store/shared/migrate/mysql/files/016_add_columns_steps.sql @@ -0,0 +1,11 @@ +-- name: alter-table-steps-add-column-step-depends-on + +ALTER TABLE steps ADD COLUMN step_depends_on TEXT NULL; + +-- name: alter-table-steps-add-column-step-image + +ALTER TABLE steps ADD COLUMN step_image VARCHAR(1000) NOT NULL DEFAULT ''; + +-- name: alter-table-steps-add-column-step-detached + +ALTER TABLE steps ADD COLUMN step_detached BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/store/shared/migrate/postgres/ddl_gen.go b/store/shared/migrate/postgres/ddl_gen.go index 337e1e44d..149dac1a3 100644 --- a/store/shared/migrate/postgres/ddl_gen.go +++ b/store/shared/migrate/postgres/ddl_gen.go @@ -156,6 +156,18 @@ var migrations = []struct { name: "create-table-template", stmt: createTableTemplate, }, + { + name: "alter-table-steps-add-column-step-depends-on", + stmt: alterTableStepsAddColumnStepDependsOn, + }, + { + name: "alter-table-steps-add-column-step-image", + stmt: alterTableStepsAddColumnStepImage, + }, + { + name: "alter-table-steps-add-column-step-detached", + stmt: alterTableStepsAddColumnStepDetached, + }, } // Migrate performs the database migration. If the migration fails @@ -658,3 +670,19 @@ CREATE TABLE IF NOT EXISTS templates ( CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace); ` + +// +// 017_add_columns_steps.sql +// + +var alterTableStepsAddColumnStepDependsOn = ` +ALTER TABLE steps ADD COLUMN step_depends_on TEXT NOT NULL DEFAULT ''; +` + +var alterTableStepsAddColumnStepImage = ` +ALTER TABLE steps ADD COLUMN step_image VARCHAR(1000) NOT NULL DEFAULT ''; +` + +var alterTableStepsAddColumnStepDetached = ` +ALTER TABLE steps ADD COLUMN step_detached BOOLEAN NOT NULL DEFAULT FALSE; +` diff --git a/store/shared/migrate/postgres/files/017_add_columns_steps.sql b/store/shared/migrate/postgres/files/017_add_columns_steps.sql new file mode 100644 index 000000000..de8c06006 --- /dev/null +++ b/store/shared/migrate/postgres/files/017_add_columns_steps.sql @@ -0,0 +1,11 @@ +-- name: alter-table-steps-add-column-step-depends-on + +ALTER TABLE steps ADD COLUMN step_depends_on TEXT NOT NULL DEFAULT ''; + +-- name: alter-table-steps-add-column-step-image + +ALTER TABLE steps ADD COLUMN step_image VARCHAR(1000) NOT NULL DEFAULT ''; + +-- name: alter-table-steps-add-column-step-detached + +ALTER TABLE steps ADD COLUMN step_detached BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/store/shared/migrate/sqlite/ddl_gen.go b/store/shared/migrate/sqlite/ddl_gen.go index 4afa29b9e..e49312b60 100644 --- a/store/shared/migrate/sqlite/ddl_gen.go +++ b/store/shared/migrate/sqlite/ddl_gen.go @@ -156,6 +156,18 @@ var migrations = []struct { name: "create-table-templates", stmt: createTableTemplates, }, + { + name: "alter-table-steps-add-column-step-depends-on", + stmt: alterTableStepsAddColumnStepDependsOn, + }, + { + name: "alter-table-steps-add-column-step-image", + stmt: alterTableStepsAddColumnStepImage, + }, + { + name: "alter-table-steps-add-column-step-detached", + stmt: alterTableStepsAddColumnStepDetached, + }, } // Migrate performs the database migration. If the migration fails @@ -660,3 +672,19 @@ CREATE TABLE IF NOT EXISTS templates ( CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace); ` + +// +// 016_add_columns_steps.sql +// + +var alterTableStepsAddColumnStepDependsOn = ` +ALTER TABLE steps ADD COLUMN step_depends_on TEXT NOT NULL DEFAULT ''; +` + +var alterTableStepsAddColumnStepImage = ` +ALTER TABLE steps ADD COLUMN step_image TEXT NOT NULL DEFAULT ''; +` + +var alterTableStepsAddColumnStepDetached = ` +ALTER TABLE steps ADD COLUMN step_detached BOOLEAN NOT NULL DEFAULT FALSE; +` diff --git a/store/shared/migrate/sqlite/files/016_add_columns_steps.sql b/store/shared/migrate/sqlite/files/016_add_columns_steps.sql new file mode 100644 index 000000000..7e01996d9 --- /dev/null +++ b/store/shared/migrate/sqlite/files/016_add_columns_steps.sql @@ -0,0 +1,11 @@ +-- name: alter-table-steps-add-column-step-depends-on + +ALTER TABLE steps ADD COLUMN step_depends_on TEXT NOT NULL DEFAULT ''; + +-- name: alter-table-steps-add-column-step-image + +ALTER TABLE steps ADD COLUMN step_image TEXT NOT NULL DEFAULT ''; + +-- name: alter-table-steps-add-column-step-detached + +ALTER TABLE steps ADD COLUMN step_detached BOOLEAN NOT NULL DEFAULT FALSE; diff --git a/store/stage/scan.go b/store/stage/scan.go index a488bc2be..ebe54746d 100644 --- a/store/stage/scan.go +++ b/store/stage/scan.go @@ -112,6 +112,7 @@ func scanRow(scanner db.Scanner, dest *core.Stage) error { func scanRowStep(scanner db.Scanner, stage *core.Stage, step *nullStep) error { depJSON := types.JSONText{} labJSON := types.JSONText{} + stepDepJSON := types.JSONText{} err := scanner.Scan( &stage.ID, &stage.RepoID, @@ -151,9 +152,13 @@ func scanRowStep(scanner db.Scanner, stage *core.Stage, step *nullStep) error { &step.Started, &step.Stopped, &step.Version, + &stepDepJSON, + &step.Image, + &step.Detached, ) json.Unmarshal(depJSON, &stage.DependsOn) json.Unmarshal(labJSON, &stage.Labels) + json.Unmarshal(stepDepJSON, &step.DependsOn) return err } diff --git a/store/stage/stage.go b/store/stage/stage.go index fbf496d88..7791d6a08 100644 --- a/store/stage/stage.go +++ b/store/stage/stage.go @@ -323,6 +323,9 @@ SELECT ,step_started ,step_stopped ,step_version +,step_depends_on +,step_image +,step_detached FROM stages LEFT JOIN steps ON stages.stage_id=steps.step_stage_id @@ -431,6 +434,9 @@ INSERT INTO steps ( ,step_started ,step_stopped ,step_version +,step_depends_on +,step_image +,step_detached ) VALUES ( :step_stage_id ,:step_number @@ -442,5 +448,8 @@ INSERT INTO steps ( ,:step_started ,:step_stopped ,:step_version +,:step_depends_on +,:step_image +,:step_detached ) ` diff --git a/store/stage/type.go b/store/stage/type.go index baa00d396..93c36acca 100644 --- a/store/stage/type.go +++ b/store/stage/type.go @@ -16,8 +16,10 @@ package stage import ( "database/sql" + "encoding/json" "github.com/drone/drone/core" + "github.com/jmoiron/sqlx/types" ) type nullStep struct { @@ -32,10 +34,16 @@ type nullStep struct { Started sql.NullInt64 Stopped sql.NullInt64 Version sql.NullInt64 + DependsOn types.JSONText + Image sql.NullString + Detached sql.NullBool } func (s *nullStep) value() *core.Step { - return &core.Step{ + var dependsOn []string + json.Unmarshal(s.DependsOn, &dependsOn) + + step := &core.Step{ ID: s.ID.Int64, StageID: s.StageID.Int64, Number: int(s.Number.Int64), @@ -47,5 +55,10 @@ func (s *nullStep) value() *core.Step { Started: s.Started.Int64, Stopped: s.Stopped.Int64, Version: s.Version.Int64, + DependsOn: dependsOn, + Image: s.Image.String, + Detached: s.Detached.Bool, } + + return step } diff --git a/store/step/scan.go b/store/step/scan.go index d5e014f52..d6dd94706 100644 --- a/store/step/scan.go +++ b/store/step/scan.go @@ -16,33 +16,44 @@ package step import ( "database/sql" + "encoding/json" "github.com/drone/drone/core" "github.com/drone/drone/store/shared/db" + "github.com/jmoiron/sqlx/types" ) // helper function converts the Step structure to a set // of named query parameters. func toParams(from *core.Step) map[string]interface{} { return map[string]interface{}{ - "step_id": from.ID, - "step_stage_id": from.StageID, - "step_number": from.Number, - "step_name": from.Name, - "step_status": from.Status, - "step_error": from.Error, - "step_errignore": from.ErrIgnore, - "step_exit_code": from.ExitCode, - "step_started": from.Started, - "step_stopped": from.Stopped, - "step_version": from.Version, + "step_id": from.ID, + "step_stage_id": from.StageID, + "step_number": from.Number, + "step_name": from.Name, + "step_status": from.Status, + "step_error": from.Error, + "step_errignore": from.ErrIgnore, + "step_exit_code": from.ExitCode, + "step_started": from.Started, + "step_stopped": from.Stopped, + "step_version": from.Version, + "step_depends_on": encodeSlice(from.DependsOn), + "step_image": from.Image, + "step_detached": from.Detached, } } +func encodeSlice(v []string) types.JSONText { + raw, _ := json.Marshal(v) + return types.JSONText(raw) +} + // helper function scans the sql.Row and copies the column // values to the destination object. func scanRow(scanner db.Scanner, dest *core.Step) error { - return scanner.Scan( + depJSON := types.JSONText{} + err := scanner.Scan( &dest.ID, &dest.StageID, &dest.Number, @@ -54,7 +65,12 @@ func scanRow(scanner db.Scanner, dest *core.Step) error { &dest.Started, &dest.Stopped, &dest.Version, + &depJSON, + &dest.Image, + &dest.Detached, ) + json.Unmarshal(depJSON, &dest.DependsOn) + return err } // helper function scans the sql.Row and copies the column diff --git a/store/step/step.go b/store/step/step.go index e43350bdc..5ade4da1b 100644 --- a/store/step/step.go +++ b/store/step/step.go @@ -156,6 +156,9 @@ SELECT ,step_started ,step_stopped ,step_version +,step_depends_on +,step_image +,step_detached ` const queryKey = queryBase + ` @@ -185,6 +188,9 @@ SET ,step_started = :step_started ,step_stopped = :step_stopped ,step_version = :step_version_new +,step_depends_on = :step_depends_on +,step_image = :step_image +,step_detached = :step_detached WHERE step_id = :step_id AND step_version = :step_version_old ` @@ -201,6 +207,9 @@ INSERT INTO steps ( ,step_started ,step_stopped ,step_version +,step_depends_on +,step_image +,step_detached ) VALUES ( :step_stage_id ,:step_number @@ -212,6 +221,9 @@ INSERT INTO steps ( ,:step_started ,:step_stopped ,:step_version +,:step_depends_on +,:step_image +,:step_detached ) ` diff --git a/store/step/step_test.go b/store/step/step_test.go index 92906cfde..7f2b7a7d0 100644 --- a/store/step/step_test.go +++ b/store/step/step_test.go @@ -51,13 +51,16 @@ func TestStep(t *testing.T) { func testStepCreate(store *stepStore, stage *core.Stage) func(t *testing.T) { return func(t *testing.T) { item := &core.Step{ - StageID: stage.ID, - Number: 2, - Name: "clone", - Status: core.StatusRunning, - ExitCode: 0, - Started: 1522878684, - Stopped: 0, + StageID: stage.ID, + Number: 2, + Name: "clone", + Status: core.StatusRunning, + ExitCode: 0, + Started: 1522878684, + Stopped: 0, + DependsOn: []string{"backend", "frontend"}, + Image: "ubuntu", + Detached: false, } err := store.Create(noContext, item) if err != nil { From 9b42d5ddaeb15060555d5b60504a312d27b69d7c Mon Sep 17 00:00:00 2001 From: Eoin McAfee <83226740+eoinmcafee00@users.noreply.github.com> Date: Tue, 22 Jun 2021 16:33:40 +0100 Subject: [PATCH 10/10] remove deprecated steps --- BUILDING | 2 -- 1 file changed, 2 deletions(-) diff --git a/BUILDING b/BUILDING index 75209bf61..fe4ee3168 100644 --- a/BUILDING +++ b/BUILDING @@ -2,8 +2,6 @@ 2. Install go 1.11 or later with Go modules enabled 3. Install binaries to $GOPATH/bin - go install github.com/drone/drone/cmd/drone-agent - go install github.com/drone/drone/cmd/drone-controller go install github.com/drone/drone/cmd/drone-server 4. Start the server at localhost:8080