From fdb7fbdc1c6d2822d3653e90ece42569ab2611c3 Mon Sep 17 00:00:00 2001 From: Lei Da Date: Mon, 23 Sep 2024 18:49:56 +0800 Subject: [PATCH] connect to git mirror server only if use gitea --- builder/git/mirrorserver.go | 2 ++ component/mirror.go | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/builder/git/mirrorserver.go b/builder/git/mirrorserver.go index 89f352a5..7e6b2366 100644 --- a/builder/git/mirrorserver.go +++ b/builder/git/mirrorserver.go @@ -18,5 +18,7 @@ func NewMirrorServer(config *config.Config) (mirrorserver.MirrorServer, error) { return mirrorServer, err } + //TODO: implement gitaly based mirrorserver + return nil, errors.New("undefined mirror server type") } diff --git a/component/mirror.go b/component/mirror.go index befc9e95..c21571e1 100644 --- a/component/mirror.go +++ b/component/mirror.go @@ -45,11 +45,13 @@ type MirrorComponent struct { func NewMirrorComponent(config *config.Config) (*MirrorComponent, error) { var err error c := &MirrorComponent{} - c.mirrorServer, err = git.NewMirrorServer(config) - if err != nil { - newError := fmt.Errorf("fail to create git mirror server,error:%w", err) - slog.Error(newError.Error()) - return nil, newError + if config.GitServer.Type == types.GitServerTypeGitea { + c.mirrorServer, err = git.NewMirrorServer(config) + if err != nil { + newError := fmt.Errorf("fail to create git mirror server,error:%w", err) + slog.Error(newError.Error()) + return nil, newError + } } c.mq, err = queue.GetPriorityQueueInstance() if err != nil {