gitsync

package
v0.0.0-...-ae73b0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSHA256 = "0000000000000000000000000000000000000000000000000000000000000000"
View Source
const DirectoryWalkTimeout = 30
View Source
const MaxCalculateFiles = 100
View Source
const MaxDelay = 5
View Source
const SyncTimeout = 300 //5 minutes at most

Variables

This section is empty.

Functions

func DeepCopyMap

func DeepCopyMap(src map[string][]string, dst map[string][]string) error

func GetRepoLocalName

func GetRepoLocalName(repo string) string

func PathIncludes

func PathIncludes(s []string, absPath string) bool

func PluginDetails

func PluginDetails(c *gin.Context)

func Register

func Register(pluginName string, plugin Plugin)

Register used to for plugin registration

func RepoEqualIgnoreSchemaAndLevel

func RepoEqualIgnoreSchemaAndLevel(base, compare string) (bool, error)

func StringInclude

func StringInclude(s []string, name string) bool

Types

type EventFilter

type EventFilter interface {
	StartLoop()
}

type GitEvent

type GitEvent struct {
	GroupName string
	RepoName  string
	Files     []string
}

type GitMeta

type GitMeta struct {
	//Git repo to watch
	Repo string
	//Git branch
	Branch string
	//Whether to checkout submodules
	SubModules string
	//Git repo schema, https or ssh
	Schema RepoSchema
	//Files to watch, relatively
	WatchFiles []string
}

func GetRepo

func GetRepo(s []GitMeta, name string) *GitMeta

type GitMetaContainer

type GitMetaContainer struct {
	Meta  *GitMeta
	Ready bool
}

type GitSyncRunner

type GitSyncRunner struct {
	ParentFolder string
	Meta         *GitMeta
	EventChannel chan<- *GitEvent
	CloseChannel chan bool
	SyncInterval int

	WebhookEndpoint string
	// contains filtered or unexported fields
}

func NewGitSyncRunner

func NewGitSyncRunner(group, parentFolder string, repo *GitMeta, eventChannel chan<- *GitEvent, interval int, logger *zap.Logger, gitSyncPath string, webhookEndpoint string) (*GitSyncRunner, error)

func (*GitSyncRunner) CalculateDigestForDirectory

func (g *GitSyncRunner) CalculateDigestForDirectory(filepath string) string

func (*GitSyncRunner) CalculateDigestForSingleFile

func (g *GitSyncRunner) CalculateDigestForSingleFile(filepath string) (string, error)

func (*GitSyncRunner) Close

func (g *GitSyncRunner) Close() error

func (*GitSyncRunner) CompareDigestAndNotify

func (g *GitSyncRunner) CompareDigestAndNotify()

func (*GitSyncRunner) GetRepo

func (g *GitSyncRunner) GetRepo() *GitMeta

func (*GitSyncRunner) RepoUpdated

func (g *GitSyncRunner) RepoUpdated()

func (*GitSyncRunner) StartLoop

func (g *GitSyncRunner) StartLoop()

func (*GitSyncRunner) SyncRepo

func (g *GitSyncRunner) SyncRepo(ctx context.Context, onetime bool) bool

func (*GitSyncRunner) WatchSync

func (g *GitSyncRunner) WatchSync(ctx context.Context)

type HashResult

type HashResult struct {
	// contains filtered or unexported fields
}

type Plugin

type Plugin interface {
	GetMeta() *PluginMeta
	Load(files map[string][]string) error
	RegisterEndpoints(group *gin.RouterGroup)
}

type PluginContainer

type PluginContainer struct {
	Plugin       Plugin
	Ready        bool
	Channel      chan *GitEvent
	FlushChannel chan int
	Logger       *zap.Logger
	// contains filtered or unexported fields
}

func NewPluginContainer

func NewPluginContainer(p Plugin) *PluginContainer

func (*PluginContainer) AddEvents

func (p *PluginContainer) AddEvents(repo, filename string)

func (*PluginContainer) Close

func (p *PluginContainer) Close()

func (*PluginContainer) FlushEvents

func (p *PluginContainer) FlushEvents() map[string][]string

func (*PluginContainer) StartLoop

func (p *PluginContainer) StartLoop()

type PluginMeta

type PluginMeta struct {
	//Plugin name used for identity, case insensitive
	Name string
	//Description for this plugin
	Description string
	//API groups, the exposed api endpoint would be: /version/data/routerGroup-name/register-endpoint
	Group string
	//Git repositories to watch
	Repos []GitMeta
}

type RepoSchema

type RepoSchema string
const (
	Https RepoSchema = "https"
	Ssh   RepoSchema = "ssh"
)

type Runner

type Runner interface {
	GetRepo() *GitMeta
	StartLoop()
	Close() error
	RepoUpdated()
}

type SyncManager

type SyncManager struct {
	SyncInterval int

	Runners map[string]Runner
	// contains filtered or unexported fields
}

func NewSyncManager

func NewSyncManager(routerGroup *gin.RouterGroup) (*SyncManager, error)

func (*SyncManager) Close

func (s *SyncManager) Close()

func (*SyncManager) GetBaseFolder

func (s *SyncManager) GetBaseFolder() string

func (*SyncManager) GetEnabledPlugins

func (s *SyncManager) GetEnabledPlugins() map[string]*PluginContainer

func (*SyncManager) Initialize

func (s *SyncManager) Initialize() error

func (*SyncManager) OnePluginInitialized

func (s *SyncManager) OnePluginInitialized() bool

func (*SyncManager) StartLoop

func (s *SyncManager) StartLoop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL