mirror of
https://github.com/harness/drone.git
synced 2025-05-09 21:44:33 +08:00
commit
f647e9ac0e
@ -4,7 +4,7 @@
|
|||||||
local golang = "golang:1.11";
|
local golang = "golang:1.11";
|
||||||
|
|
||||||
# defines a temporary volume so that the Go cache can
|
# defines a temporary volume so that the Go cache can
|
||||||
# be shared with all pipeine steps.
|
# be shared with all pipeline steps.
|
||||||
local volumes = [
|
local volumes = [
|
||||||
{
|
{
|
||||||
name: "gopath",
|
name: "gopath",
|
||||||
|
@ -82,7 +82,7 @@ func main() {
|
|||||||
Errorln("cannot ping the docker daemon")
|
Errorln("cannot ping the docker daemon")
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
} else {
|
} else {
|
||||||
logrus.Debugln("succussfully pinged the docker daemon")
|
logrus.Debugln("successfully pinged the docker daemon")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper funciton configures the logging.
|
// helper function configures the logging.
|
||||||
func initLogging(c config.Config) {
|
func initLogging(c config.Config) {
|
||||||
if c.Logging.Debug {
|
if c.Logging.Debug {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
|
@ -128,7 +128,7 @@ func isKubernetes() bool {
|
|||||||
return os.Getenv("KUBERNETES_SERVICE_HOST") != ""
|
return os.Getenv("KUBERNETES_SERVICE_HOST") != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper funciton configures the logging.
|
// helper function configures the logging.
|
||||||
func initLogging(c config.Config) {
|
func initLogging(c config.Config) {
|
||||||
if c.Logging.Debug {
|
if c.Logging.Debug {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
|
@ -36,7 +36,7 @@ var loginSet = wire.NewSet(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// provideLogin is a Wire provider function that returns an
|
// provideLogin is a Wire provider function that returns an
|
||||||
// autenticator based on the environment configuration.
|
// authenticator based on the environment configuration.
|
||||||
func provideLogin(config config.Config) login.Middleware {
|
func provideLogin(config config.Config) login.Middleware {
|
||||||
switch {
|
switch {
|
||||||
case config.Bitbucket.ClientID != "":
|
case config.Bitbucket.ClientID != "":
|
||||||
@ -57,7 +57,7 @@ func provideLogin(config config.Config) login.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// provideBitbucketLogin is a Wire provider function that
|
// provideBitbucketLogin is a Wire provider function that
|
||||||
// returns a Bitbucket Cloud autenticator based on the
|
// returns a Bitbucket Cloud authenticator based on the
|
||||||
// environment configuration.
|
// environment configuration.
|
||||||
func provideBitbucketLogin(config config.Config) login.Middleware {
|
func provideBitbucketLogin(config config.Config) login.Middleware {
|
||||||
if config.Bitbucket.ClientID == "" {
|
if config.Bitbucket.ClientID == "" {
|
||||||
@ -71,7 +71,7 @@ func provideBitbucketLogin(config config.Config) login.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// provideGithubLogin is a Wire provider function that returns
|
// provideGithubLogin is a Wire provider function that returns
|
||||||
// a GitHub autenticator based on the environment configuration.
|
// a GitHub authenticator based on the environment configuration.
|
||||||
func provideGithubLogin(config config.Config) login.Middleware {
|
func provideGithubLogin(config config.Config) login.Middleware {
|
||||||
if config.Github.ClientID == "" {
|
if config.Github.ClientID == "" {
|
||||||
return nil
|
return nil
|
||||||
@ -87,7 +87,7 @@ func provideGithubLogin(config config.Config) login.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// provideGiteaLogin is a Wire provider function that returns
|
// provideGiteaLogin is a Wire provider function that returns
|
||||||
// a Gitea autenticator based on the environment configuration.
|
// a Gitea authenticator based on the environment configuration.
|
||||||
func provideGiteaLogin(config config.Config) login.Middleware {
|
func provideGiteaLogin(config config.Config) login.Middleware {
|
||||||
if config.Gitea.Server == "" {
|
if config.Gitea.Server == "" {
|
||||||
return nil
|
return nil
|
||||||
@ -112,7 +112,7 @@ func provideGiteaLogin(config config.Config) login.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// provideGitlabLogin is a Wire provider function that returns
|
// provideGitlabLogin is a Wire provider function that returns
|
||||||
// a GitLab autenticator based on the environment configuration.
|
// a GitLab authenticator based on the environment configuration.
|
||||||
func provideGitlabLogin(config config.Config) login.Middleware {
|
func provideGitlabLogin(config config.Config) login.Middleware {
|
||||||
if config.GitLab.ClientID == "" {
|
if config.GitLab.ClientID == "" {
|
||||||
return nil
|
return nil
|
||||||
@ -127,7 +127,7 @@ func provideGitlabLogin(config config.Config) login.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// provideGogsLogin is a Wire provider function that returns
|
// provideGogsLogin is a Wire provider function that returns
|
||||||
// a Gogs autenticator based on the environment configuration.
|
// a Gogs authenticator based on the environment configuration.
|
||||||
func provideGogsLogin(config config.Config) login.Middleware {
|
func provideGogsLogin(config config.Config) login.Middleware {
|
||||||
if config.Gogs.Server == "" {
|
if config.Gogs.Server == "" {
|
||||||
return nil
|
return nil
|
||||||
@ -141,7 +141,7 @@ func provideGogsLogin(config config.Config) login.Middleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// provideStashLogin is a Wire provider function that returns
|
// provideStashLogin is a Wire provider function that returns
|
||||||
// a Stash autenticator based on the environment configuration.
|
// a Stash authenticator based on the environment configuration.
|
||||||
func provideStashLogin(config config.Config) login.Middleware {
|
func provideStashLogin(config config.Config) login.Middleware {
|
||||||
if config.Stash.ConsumerKey == "" {
|
if config.Stash.ConsumerKey == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -131,7 +131,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper funciton configures the logging.
|
// helper function configures the logging.
|
||||||
func initLogging(c config.Config) {
|
func initLogging(c config.Config) {
|
||||||
if c.Logging.Debug {
|
if c.Logging.Debug {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
|
@ -18,7 +18,7 @@ import "context"
|
|||||||
|
|
||||||
// AdmissionService grants access to the system. The service can
|
// AdmissionService grants access to the system. The service can
|
||||||
// be used to restrict access to authorized users, such as
|
// be used to restrict access to authorized users, such as
|
||||||
// members of an organiozation in your soruce control management
|
// members of an organization in your source control management
|
||||||
// system.
|
// system.
|
||||||
type AdmissionService interface {
|
type AdmissionService interface {
|
||||||
Admit(context.Context, *User) error
|
Admit(context.Context, *User) error
|
||||||
|
@ -47,7 +47,7 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PermStore defines operations for working with
|
// PermStore defines operations for working with
|
||||||
// repostiory permissions.
|
// repository permissions.
|
||||||
PermStore interface {
|
PermStore interface {
|
||||||
// Find returns a project member from the
|
// Find returns a project member from the
|
||||||
// datastore.
|
// datastore.
|
||||||
|
@ -23,7 +23,7 @@ type Message struct {
|
|||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pubsub provides publish subscriber capablities, distributing
|
// Pubsub provides publish subscriber capabilities, distributing
|
||||||
// messages from multiple publishers to multiple subscribers.
|
// messages from multiple publishers to multiple subscribers.
|
||||||
type Pubsub interface {
|
type Pubsub interface {
|
||||||
// Publish publishes the message to all subscribers.
|
// Publish publishes the message to all subscribers.
|
||||||
|
@ -77,7 +77,7 @@ type (
|
|||||||
ListRecent(context.Context, int64) ([]*Repository, error)
|
ListRecent(context.Context, int64) ([]*Repository, error)
|
||||||
|
|
||||||
// ListIncomplete returns a non-unique repository list form
|
// ListIncomplete returns a non-unique repository list form
|
||||||
// the datastore with incmoplete builds.
|
// the datastore with incomplete builds.
|
||||||
ListIncomplete(context.Context) ([]*Repository, error)
|
ListIncomplete(context.Context) ([]*Repository, error)
|
||||||
|
|
||||||
// Find returns a repository from the datastore.
|
// Find returns a repository from the datastore.
|
||||||
|
@ -16,7 +16,7 @@ package core
|
|||||||
|
|
||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
// Syncer synchonrizes the account repository list.
|
// Syncer synchronizes the account repository list.
|
||||||
type Syncer interface {
|
type Syncer interface {
|
||||||
Sync(context.Context, *User) (*Batch, error)
|
Sync(context.Context, *User) (*Batch, error)
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ func InjectRepository(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Debugln("api: cannot cache repository permissions")
|
log.WithError(err).Debugln("api: cannot cache repository permissions")
|
||||||
} else {
|
} else {
|
||||||
log.Debugln("api: repository permissions synchrnoized")
|
log.Debugln("api: repository permissions synchronized")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"github.com/drone/drone/logger"
|
"github.com/drone/drone/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HandleAuthentication returns an http.HandlerFunc middlewrae that authenticates
|
// HandleAuthentication returns an http.HandlerFunc middleware that authenticates
|
||||||
// the http.Request and errors if the account cannot be authenticated.
|
// the http.Request and errors if the account cannot be authenticated.
|
||||||
func HandleAuthentication(session core.Session) func(http.Handler) http.Handler {
|
func HandleAuthentication(session core.Session) func(http.Handler) http.Handler {
|
||||||
return func(next http.Handler) http.Handler {
|
return func(next http.Handler) http.Handler {
|
||||||
|
@ -29,7 +29,7 @@ type CCProject struct {
|
|||||||
WebURL string `xml:"webUrl,attr"`
|
WebURL string `xml:"webUrl,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new CCPojrect from the Repository and Build details.
|
// New creates a new CCProject from the Repository and Build details.
|
||||||
func New(r *core.Repository, b *core.Build, link string) *CCProjects {
|
func New(r *core.Repository, b *core.Build, link string) *CCProjects {
|
||||||
proj := &CCProject{
|
proj := &CCProject{
|
||||||
Name: r.Slug,
|
Name: r.Slug,
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// HandleRepair returns an http.HandlerFunc that processes http
|
// HandleRepair returns an http.HandlerFunc that processes http
|
||||||
// requests to repair the repository hooks and sync the repository
|
// requests to repair the repository hooks and sync the repository
|
||||||
// deetails.
|
// details.
|
||||||
func HandleRepair(
|
func HandleRepair(
|
||||||
hooks core.HookService,
|
hooks core.HookService,
|
||||||
repoz core.RepositoryService,
|
repoz core.RepositoryService,
|
||||||
|
@ -39,7 +39,7 @@ func HandleSync(syncer core.Syncer, repos core.RepositoryStore) http.HandlerFunc
|
|||||||
_, err := syncer.Sync(ctx, viewer)
|
_, err := syncer.Sync(ctx, viewer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.FromContext(ctx).WithError(err).
|
logger.FromContext(ctx).WithError(err).
|
||||||
Debugln("api: cannot synchrnoize account")
|
Debugln("api: cannot synchronize account")
|
||||||
}
|
}
|
||||||
}(ctx, viewer)
|
}(ctx, viewer)
|
||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
@ -50,7 +50,7 @@ func HandleSync(syncer core.Syncer, repos core.RepositoryStore) http.HandlerFunc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
render.InternalError(w, err)
|
render.InternalError(w, err)
|
||||||
logger.FromRequest(r).WithError(err).
|
logger.FromRequest(r).WithError(err).
|
||||||
Warnln("api: cannot synchrnoize account")
|
Warnln("api: cannot synchronize account")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
list, err := repos.List(r.Context(), viewer.ID)
|
list, err := repos.List(r.Context(), viewer.ID)
|
||||||
|
@ -141,7 +141,7 @@ func HandleLogin(
|
|||||||
user.Expiry = tok.Expires.Unix()
|
user.Expiry = tok.Expires.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user account has never been synchrnoized we
|
// If the user account has never been synchronized we
|
||||||
// execute the synchonrization logic.
|
// execute the synchonrization logic.
|
||||||
if time.Unix(user.Synced, 0).Add(syncPeriod).Before(time.Now()) {
|
if time.Unix(user.Synced, 0).Add(syncPeriod).Before(time.Now()) {
|
||||||
user.Syncing = true
|
user.Syncing = true
|
||||||
|
@ -438,7 +438,7 @@ func (m *Manager) Netrc(ctx context.Context, id int64) (*core.Netrc, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logger = logger.WithError(err)
|
logger = logger.WithError(err)
|
||||||
logger = logger.WithField("repo.name", repo.Slug)
|
logger = logger.WithField("repo.name", repo.Slug)
|
||||||
logger.Warnln("manager: cannot gernerate netrc")
|
logger.Warnln("manager: cannot generate netrc")
|
||||||
}
|
}
|
||||||
return netrc, err
|
return netrc, err
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ func (s *Client) Before(ctx context.Context, step *core.Step) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// the step ID and version (optomistic locking) are
|
// the step ID and version (optimistic locking) are
|
||||||
// updated when the step is created. Copy the updated
|
// updated when the step is created. Copy the updated
|
||||||
// values back to the original step object.
|
// values back to the original step object.
|
||||||
step.ID = out.ID
|
step.ID = out.ID
|
||||||
@ -138,7 +138,7 @@ func (s *Client) After(ctx context.Context, step *core.Step) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// the step version (optomistic locking) is updated
|
// the step version (optimistic locking) is updated
|
||||||
// when the step is created. Copy the updated values
|
// when the step is created. Copy the updated values
|
||||||
// back to the original step object.
|
// back to the original step object.
|
||||||
step.Version = out.Version
|
step.Version = out.Version
|
||||||
@ -173,7 +173,7 @@ func (s *Client) AfterAll(ctx context.Context, stage *core.Stage) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// the stage timestamps and version (optomistic locking)
|
// the stage timestamps and version (optimistic locking)
|
||||||
// are updated when the step is created. Copy the updated
|
// are updated when the step is created. Copy the updated
|
||||||
// values back to the original step object.
|
// values back to the original step object.
|
||||||
stage.Version = out.Version
|
stage.Version = out.Version
|
||||||
@ -237,7 +237,7 @@ func (s *Client) send(ctx context.Context, path string, in, out interface{}) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the response for a 409 conflict. This indicates an
|
// Check the response for a 409 conflict. This indicates an
|
||||||
// optimtistic lock error, in which case multiple clients may
|
// optimistic lock error, in which case multiple clients may
|
||||||
// be attempting to update the same record. Convert this error
|
// be attempting to update the same record. Convert this error
|
||||||
// code to a proper error.
|
// code to a proper error.
|
||||||
if res.StatusCode == 409 {
|
if res.StatusCode == 409 {
|
||||||
|
@ -342,7 +342,7 @@ func TestAfterAll(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBefore_OptomisticLock(t *testing.T) {
|
func TestBefore_OptimisticLock(t *testing.T) {
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
gock.New("http://drone.company.com").
|
gock.New("http://drone.company.com").
|
||||||
@ -353,14 +353,14 @@ func TestBefore_OptomisticLock(t *testing.T) {
|
|||||||
gock.InterceptClient(client.client.HTTPClient)
|
gock.InterceptClient(client.client.HTTPClient)
|
||||||
err := client.Before(noContext, new(core.Step))
|
err := client.Before(noContext, new(core.Step))
|
||||||
if err != db.ErrOptimisticLock {
|
if err != db.ErrOptimisticLock {
|
||||||
t.Errorf("Want optomistic lock error")
|
t.Errorf("Want optimistic lock error")
|
||||||
}
|
}
|
||||||
if gock.IsPending() {
|
if gock.IsPending() {
|
||||||
t.Errorf("Unfinished requests")
|
t.Errorf("Unfinished requests")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAfter_OptomisticLock(t *testing.T) {
|
func TestAfter_OptimisticLock(t *testing.T) {
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
gock.New("http://drone.company.com").
|
gock.New("http://drone.company.com").
|
||||||
@ -371,14 +371,14 @@ func TestAfter_OptomisticLock(t *testing.T) {
|
|||||||
gock.InterceptClient(client.client.HTTPClient)
|
gock.InterceptClient(client.client.HTTPClient)
|
||||||
err := client.After(noContext, new(core.Step))
|
err := client.After(noContext, new(core.Step))
|
||||||
if err != db.ErrOptimisticLock {
|
if err != db.ErrOptimisticLock {
|
||||||
t.Errorf("Want optomistic lock error")
|
t.Errorf("Want optimistic lock error")
|
||||||
}
|
}
|
||||||
if gock.IsPending() {
|
if gock.IsPending() {
|
||||||
t.Errorf("Unfinished requests")
|
t.Errorf("Unfinished requests")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBeforeAll_OptomisticLock(t *testing.T) {
|
func TestBeforeAll_OptimisticLock(t *testing.T) {
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
gock.New("http://drone.company.com").
|
gock.New("http://drone.company.com").
|
||||||
@ -389,14 +389,14 @@ func TestBeforeAll_OptomisticLock(t *testing.T) {
|
|||||||
gock.InterceptClient(client.client.HTTPClient)
|
gock.InterceptClient(client.client.HTTPClient)
|
||||||
err := client.BeforeAll(noContext, new(core.Stage))
|
err := client.BeforeAll(noContext, new(core.Stage))
|
||||||
if err != db.ErrOptimisticLock {
|
if err != db.ErrOptimisticLock {
|
||||||
t.Errorf("Want optomistic lock error")
|
t.Errorf("Want optimistic lock error")
|
||||||
}
|
}
|
||||||
if gock.IsPending() {
|
if gock.IsPending() {
|
||||||
t.Errorf("Unfinished requests")
|
t.Errorf("Unfinished requests")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAfterAll_OptomisticLock(t *testing.T) {
|
func TestAfterAll_OptimisticLock(t *testing.T) {
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
gock.New("http://drone.company.com").
|
gock.New("http://drone.company.com").
|
||||||
@ -407,7 +407,7 @@ func TestAfterAll_OptomisticLock(t *testing.T) {
|
|||||||
gock.InterceptClient(client.client.HTTPClient)
|
gock.InterceptClient(client.client.HTTPClient)
|
||||||
err := client.AfterAll(noContext, new(core.Stage))
|
err := client.AfterAll(noContext, new(core.Stage))
|
||||||
if err != db.ErrOptimisticLock {
|
if err != db.ErrOptimisticLock {
|
||||||
t.Errorf("Want optomistic lock error")
|
t.Errorf("Want optimistic lock error")
|
||||||
}
|
}
|
||||||
if gock.IsPending() {
|
if gock.IsPending() {
|
||||||
t.Errorf("Unfinished requests")
|
t.Errorf("Unfinished requests")
|
||||||
|
@ -517,7 +517,7 @@ func (r *Runner) Run(ctx context.Context, id int64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start starts N build runner processes. Each process polls
|
// Start starts N build runner processes. Each process polls
|
||||||
// the server for pednding builds to execute.
|
// the server for pending builds to execute.
|
||||||
func (r *Runner) Start(ctx context.Context, n int) error {
|
func (r *Runner) Start(ctx context.Context, n int) error {
|
||||||
var g errgroup.Group
|
var g errgroup.Group
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
@ -536,7 +536,7 @@ func (r *Runner) start(ctx context.Context) error {
|
|||||||
default:
|
default:
|
||||||
// This error is ignored on purpose. The system
|
// This error is ignored on purpose. The system
|
||||||
// should not exit the runner on error. The run
|
// should not exit the runner on error. The run
|
||||||
// funciton logs all errors, which should be enough
|
// function logs all errors, which should be enough
|
||||||
// to surface potential issues to an administrator.
|
// to surface potential issues to an administrator.
|
||||||
r.poll(ctx)
|
r.poll(ctx)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
// user is a human being.
|
// user is a human being.
|
||||||
var ErrCannotVerify = errors.New("Cannot verify user authenticity")
|
var ErrCannotVerify = errors.New("Cannot verify user authenticity")
|
||||||
|
|
||||||
// Nobot enfoces an admission policy that restricts access to
|
// Nobot enforces an admission policy that restricts access to
|
||||||
// users accounts that were recently created and may be bots.
|
// users accounts that were recently created and may be bots.
|
||||||
// The policy expects the source control management system will
|
// The policy expects the source control management system will
|
||||||
// identify and remove the bot accounts before they would be
|
// identify and remove the bot accounts before they would be
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
// user account and admissions are closed.
|
// user account and admissions are closed.
|
||||||
var ErrClosed = errors.New("User registration is disabled")
|
var ErrClosed = errors.New("User registration is disabled")
|
||||||
|
|
||||||
// Open enfoces an open admission policy by default unless
|
// Open enforces an open admission policy by default unless
|
||||||
// disabled.
|
// disabled.
|
||||||
func Open(disabled bool) core.AdmissionService {
|
func Open(disabled bool) core.AdmissionService {
|
||||||
return &closed{disabled: disabled}
|
return &closed{disabled: disabled}
|
||||||
|
@ -44,7 +44,7 @@ func (c *combined) List(ctx context.Context, req *core.RegistryArgs) ([]*core.Re
|
|||||||
}
|
}
|
||||||
// if trace level debugging is enabled we print
|
// if trace level debugging is enabled we print
|
||||||
// all registry credentials retrieved from the
|
// all registry credentials retrieved from the
|
||||||
// various registy sources.
|
// various registry sources.
|
||||||
logger := logger.FromContext(ctx)
|
logger := logger.FromContext(ctx)
|
||||||
if logrus.IsLevelEnabled(logrus.TraceLevel) {
|
if logrus.IsLevelEnabled(logrus.TraceLevel) {
|
||||||
if len(all) == 0 {
|
if len(all) == 0 {
|
||||||
|
@ -49,7 +49,7 @@ import (
|
|||||||
// TODO(bradrydzewski): gitea, push hook missing repository html url
|
// TODO(bradrydzewski): gitea, push hook missing repository html url
|
||||||
|
|
||||||
// TODO(bradrydzewski): bitbucket, pull request hook missing author email.
|
// TODO(bradrydzewski): bitbucket, pull request hook missing author email.
|
||||||
// TODO(bradrydzewski): bitbucket, hooks missing defualt repository branch.
|
// TODO(bradrydzewski): bitbucket, hooks missing default repository branch.
|
||||||
|
|
||||||
// TODO(bradrydzewski): github, push hook timestamp is negative value.
|
// TODO(bradrydzewski): github, push hook timestamp is negative value.
|
||||||
// TODO(bradrydzewski): github, pull request message is empty
|
// TODO(bradrydzewski): github, pull request message is empty
|
||||||
|
@ -38,7 +38,7 @@ func convertRepository(src *scm.Repository) *core.Repository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convertVisibility is a helper function that returns the
|
// convertVisibility is a helper function that returns the
|
||||||
// repository visibliity based on the privacy flag.
|
// repository visibility based on the privacy flag.
|
||||||
func convertVisibility(src *scm.Repository) string {
|
func convertVisibility(src *scm.Repository) string {
|
||||||
switch {
|
switch {
|
||||||
case src.Private == true:
|
case src.Private == true:
|
||||||
|
@ -55,7 +55,7 @@ func (s *Synchronizer) SetFilter(fn FilterFunc) {
|
|||||||
s.match = fn
|
s.match = fn
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync synchonrizes the user repository list in 6 easy steps.
|
// Sync synchronizes the user repository list in 6 easy steps.
|
||||||
func (s *Synchronizer) Sync(ctx context.Context, user *core.User) (*core.Batch, error) {
|
func (s *Synchronizer) Sync(ctx context.Context, user *core.User) (*core.Batch, error) {
|
||||||
logger := logrus.WithField("login", user.Login)
|
logger := logrus.WithField("login", user.Login)
|
||||||
logger.Debugln("syncer: begin repository sync")
|
logger.Debugln("syncer: begin repository sync")
|
||||||
|
@ -121,7 +121,7 @@ func (db *DB) Driver() Driver {
|
|||||||
return db.driver
|
return db.driver
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close cloes the database connection.
|
// Close closes the database connection.
|
||||||
func (db *DB) Close() error {
|
func (db *DB) Close() error {
|
||||||
return db.conn.Close()
|
return db.conn.Close()
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ func TestCron(t *testing.T) {
|
|||||||
defer controller.Finish()
|
defer controller.Finish()
|
||||||
|
|
||||||
checkBuild := func(_ context.Context, _ *core.Repository, hook *core.Hook) {
|
checkBuild := func(_ context.Context, _ *core.Repository, hook *core.Hook) {
|
||||||
ignoreHookFileds := cmpopts.IgnoreFields(core.Hook{},
|
ignoreHookFields := cmpopts.IgnoreFields(core.Hook{},
|
||||||
"Source", "Before")
|
"Source", "Before")
|
||||||
if diff := cmp.Diff(hook, dummyHook, ignoreHookFileds); diff != "" {
|
if diff := cmp.Diff(hook, dummyHook, ignoreHookFields); diff != "" {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ func TestCron_Cancel(t *testing.T) {
|
|||||||
|
|
||||||
// This unit tests demonstrates that if an error is encountered
|
// This unit tests demonstrates that if an error is encountered
|
||||||
// when returning a list of ready cronjobs, the process exits
|
// when returning a list of ready cronjobs, the process exits
|
||||||
// immadiately with an error message.
|
// immediately with an error message.
|
||||||
func TestCron_ErrorList(t *testing.T) {
|
func TestCron_ErrorList(t *testing.T) {
|
||||||
controller := gomock.NewController(t)
|
controller := gomock.NewController(t)
|
||||||
defer controller.Finish()
|
defer controller.Finish()
|
||||||
@ -484,6 +484,6 @@ var (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreBuildFileds = cmpopts.IgnoreFields(core.Build{},
|
ignoreBuildFields = cmpopts.IgnoreFields(core.Build{},
|
||||||
"Created", "Updated")
|
"Created", "Updated")
|
||||||
)
|
)
|
||||||
|
@ -77,7 +77,7 @@ func skipMessageEval(str string) bool {
|
|||||||
// func skipPaths(document *config.Config, paths []string) bool {
|
// func skipPaths(document *config.Config, paths []string) bool {
|
||||||
// switch {
|
// switch {
|
||||||
// // changed files are only returned for push and pull request
|
// // changed files are only returned for push and pull request
|
||||||
// // events. If the list of changed files is empty the sytem will
|
// // events. If the list of changed files is empty the system will
|
||||||
// // force-run all pipelines and pipeline steps
|
// // force-run all pipelines and pipeline steps
|
||||||
// case len(paths) == 0:
|
// case len(paths) == 0:
|
||||||
// return false
|
// return false
|
||||||
|
@ -33,19 +33,19 @@ func TestTrigger(t *testing.T) {
|
|||||||
defer controller.Finish()
|
defer controller.Finish()
|
||||||
|
|
||||||
checkBuild := func(_ context.Context, build *core.Build, stages []*core.Stage) {
|
checkBuild := func(_ context.Context, build *core.Build, stages []*core.Stage) {
|
||||||
if diff := cmp.Diff(build, dummyBuild, ignoreBuildFileds); diff != "" {
|
if diff := cmp.Diff(build, dummyBuild, ignoreBuildFields); diff != "" {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(stages, dummyStages, ignoreStageFileds); diff != "" {
|
if diff := cmp.Diff(stages, dummyStages, ignoreStageFields); diff != "" {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkStatus := func(_ context.Context, _ *core.User, req *core.StatusInput) error {
|
checkStatus := func(_ context.Context, _ *core.User, req *core.StatusInput) error {
|
||||||
if diff := cmp.Diff(req.Build, dummyBuild, ignoreBuildFileds); diff != "" {
|
if diff := cmp.Diff(req.Build, dummyBuild, ignoreBuildFields); diff != "" {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(req.Repo, dummyRepo, ignoreStageFileds); diff != "" {
|
if diff := cmp.Diff(req.Repo, dummyRepo, ignoreStageFields); diff != "" {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -88,7 +88,7 @@ func TestTrigger(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if diff := cmp.Diff(build, dummyBuild, ignoreBuildFileds); diff != "" {
|
if diff := cmp.Diff(build, dummyBuild, ignoreBuildFields); diff != "" {
|
||||||
t.Errorf(diff)
|
t.Errorf(diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,9 +487,9 @@ var (
|
|||||||
Data: "kind: pipeline\ntrigger: { event: { exclude: push } }",
|
Data: "kind: pipeline\ntrigger: { event: { exclude: push } }",
|
||||||
}
|
}
|
||||||
|
|
||||||
ignoreBuildFileds = cmpopts.IgnoreFields(core.Build{},
|
ignoreBuildFields = cmpopts.IgnoreFields(core.Build{},
|
||||||
"Created", "Updated")
|
"Created", "Updated")
|
||||||
|
|
||||||
ignoreStageFileds = cmpopts.IgnoreFields(core.Stage{},
|
ignoreStageFields = cmpopts.IgnoreFields(core.Stage{},
|
||||||
"Created", "Updated")
|
"Created", "Updated")
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user