pkgdash/internal/source/source.go

33 lines
1023 B
Go
Raw Normal View History

package source
import (
"context"
"git.unistack.org/unistack-org/pkgdash/internal/configcli"
"git.unistack.org/unistack-org/pkgdash/internal/modules"
"git.unistack.org/unistack-org/pkgdash/internal/source/gitea"
"git.unistack.org/unistack-org/pkgdash/internal/source/github"
"git.unistack.org/unistack-org/pkgdash/internal/source/gitlab"
"git.unistack.org/unistack-org/pkgdash/internal/source/gogs"
)
type SourceControl interface {
RequestOpen(ctx context.Context, branch string, path string, mod modules.Update) error
RequestClose(ctx context.Context, cfg *configcli.Config, branch string, path string) error
RequestUpdate(ctx context.Context, cfg *configcli.Config, branch string, path string, mod modules.Update) error
}
func NewSourceControl(cfg configcli.Config) SourceControl {
switch cfg.Source.TypeGit {
case "github":
return github.NewGithub(cfg)
case "gitlab":
return gitlab.NewGitlab(cfg)
case "gitea":
return gitea.NewGitea(cfg)
case "gogs":
return gogs.NewGogs(cfg)
}
return nil
}