Merge remote-tracking branch 'origin/master'

This commit is contained in:
Brad Rydzewski 2021-06-23 19:02:38 -04:00
commit 1e1ab2d04d
58 changed files with 460 additions and 207 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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 {

4
go.mod
View file

@ -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.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
@ -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

8
go.sum
View file

@ -146,6 +146,12 @@ 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/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=
@ -194,6 +200,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=

View file

@ -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()

View file

@ -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)
}

View file

@ -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
}

View file

@ -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
})

View file

@ -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)

View file

@ -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 {

View file

@ -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)

View file

@ -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 {

View file

@ -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")
}

View file

@ -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,
},

View file

@ -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"`
}

View file

@ -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)

View file

@ -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)

View file

@ -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")
}

View file

@ -29,13 +29,13 @@ func Parse(req *core.ConvertArgs, template *core.Template, templateData map[stri
}
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 {
@ -48,9 +48,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
}

View file

@ -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),
}
}

View file

@ -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") ||

View file

@ -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)

View file

@ -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")
}

View file

@ -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

View file

@ -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)
}
}
}

0
scripts/build.sh Normal file → Executable file
View file

View file

@ -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 {

View file

@ -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 {

View file

@ -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") {

View file

@ -38,4 +38,4 @@
"Email": "noreply@gogs.io",
"Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
}
}
}

View file

@ -23,4 +23,4 @@
"Email": "noreply@gogs.io",
"Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
}
}
}

View file

@ -40,4 +40,4 @@
"Email": "noreply@gogs.io",
"Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
}
}
}

View file

@ -38,4 +38,4 @@
"Email": "noreply@gogs.io",
"Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
}
}
}

View file

@ -23,4 +23,4 @@
"Email": "noreply@gogs.io",
"Avatar": "https://secure.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87"
}
}
}

View file

@ -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

View file

@ -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()

View file

@ -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 (

View file

@ -72,7 +72,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 {

View file

@ -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
}

View file

@ -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/<db>/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
```

View file

@ -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;
`

View file

@ -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;

View file

@ -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;
`

View file

@ -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;

View file

@ -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;
`

View file

@ -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;

View file

@ -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
}

View file

@ -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
)
`

View file

@ -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
}

View file

@ -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

View file

@ -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
)
`

View file

@ -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 {

View file

@ -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")
}
}

View file

@ -94,7 +94,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