Documentation ¶
Overview ¶
A library for polling a Git repository for changes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeType ¶
type ChangeType int
const ( ChangeTypeUpdate ChangeType = iota ChangeTypeCreate ChangeTypeDelete )
type FilterFunc ¶
type GitAuthConfig ¶
type GitAuthConfig struct { // The filepath to the SSH key. Required if the Username and Password are not set. SshKey string `validation:"required_without=Username Password"` // The username for the git repo. Required if the SshKey is not set or if the Password is set. Username string `validation:"required_without=SshKey,required_with=Password"` // The password for the git repo. Required if the SshKey is not set or if the Username is set. Password string `validation:"require_without=SshKey,required_with=Username"` }
type GitChange ¶
type GitChange struct { // The name and absolute path to the changed file. Filepath string // The commit sha associated with the change. Sha string // The type of change that occurred e.g. added, created, deleted the file. ChangeType ChangeType }
Represents a change to a file within the target Git repo.
type GitConfig ¶
type GitConfig struct { // Authentication/authorization for the git repo to poll. Required. Auth GitAuthConfig `validate:"required"` // The remote git repository that should be polled. Required. Remote string `validate:"required"` // The branch of the git repo to poll. Defaults to master. Branch string // The directory that the git repository will be cloned into. Defaults to the current directory. CloneDirectory string }
type HandleFunc ¶
type HandleFunc func(change GitChange)
type PollConfig ¶
type PollConfig struct { Git GitConfig `validate:"required"` // Function that is called when a change is detected. If true is returned for the change, The function set for // HandleChange will trigger. If false is returned, HandleChange will not be called. Filter FilterFunc // Function that is called when a change occurs to a file in the git repository. HandleChange HandleFunc // The polling interval. Defaults to 30 seconds. Interval time.Duration }
type Poller ¶
type Poller interface { // Start polling your git repo without blocking. The poller will diff the remote against the local clone directory at // the specified interval and return all changes through the configured callback and the returned channel. StartAsync() (chan GitChange, error) // Start polling your git repo blocking whatever thread it is run on. The poller will diff the remote against the // local clone directory at the specified interval and return all changes through the configured callback. Start() error // Stop all polling. Stop() // Diff the remote and the local and return all differences. Poll() ([]GitChange, error) }
func NewPoller ¶
func NewPoller(config PollConfig) (Poller, error)
Create a new Poller from config. Will return an error for misconfiguration.
Click to show internal directories.
Click to hide internal directories.