git

package module
v0.0.0-...-8360cff Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 14 Imported by: 0

README

git

Name

git - pull git repositories.

Description

git clones a git repository into the site. This makes it possible to deploy your zones with a simple git push.

The git plugin starts a service routine that runs during the lifetime of the server. When the service starts, it clones the repository. While the server is still up, it pulls the latest every so often. You can also set up a webhook to pull immediately after a push. In regular git fashion, a pull only includes changes, so it is very efficient.

If a pull fails, the service will retry up to three times. If the pull was not successful by then, it won't try again until the next interval.

This plugin requires git to be installed on the system.

Webhooks are not supported, this is a pure pull model.

Syntax

git REPO [PATH]
  • REPO is the URL to the repository; SSH and HTTPS URLs are supported

  • PATH is the path, relative to site root, to clone the repository into; default is site root

This simplified syntax pulls from master every 3600 seconds (1 hour) and only works for public repositories.

For more control or to use a private repository, use the following syntax:

git [REPO PATH] {
	repo        REPO
	path        PATH
	branch      BRANCH
	interval    INTERVAL
	args        ARGS
	pull_args   PULL_ARGS
}
  • REPO is the URL to the repository; only HTTPS URLs are supported.

  • PATH is the path to clone the repository into; default is site root (if set). It can be absolute or relative (to site root). See the root plugin.

  • BRANCH is the branch or tag to pull; default is master branch. {latest} is a placeholder for latest tag which ensures the most recent tag is always pulled.

  • INTERVAl is the number of seconds between pulls; default is 3600 (1 hour), minimum 5. An interval of -1 disables periodic pull.

  • ARGS is the additional cli args to pass to git clone e.g. --depth=1. git clone is called when the source is being fetched the first time.

  • PULL_ARGS is the additional cli args to pass to git pull e.g. -s recursive -X theirs. git pull is used when the source is being updated.

Examples

Public repository pulled into site root every hour:

example.org {
    root /etc/zones
    git github.com/user/myproject
}

Public repository pulled into the "subdir" directory in the site root:

example.org {
    root /etc/zones
    git github.com/user/myproject subdir
}

Also See

The root plugin for setting the root.

Documentation

Index

Constants

View Source
const (
	// DefaultInterval is the minimum interval to delay before
	// requesting another git pull
	DefaultInterval time.Duration = time.Hour
)

Variables

View Source
var (
	// Services holds all git pulling services and provides the function to stop them.
	Services = &services{}
)

Functions

func Start

func Start(repo *Repo)

Start starts a new background service to pull periodically.

Types

type Git

type Git []*Repo

Git represent multiple repositories.

func (Git) Repo

func (g Git) Repo(i int) *Repo

Repo retrieves repository at i or nil if not found.

type Repo

type Repo struct {
	URL       string        // Repository URL
	Path      string        // Directory to pull to
	Branch    string        // Git branch
	Interval  time.Duration // Interval between pulls
	CloneArgs []string      // Additonal cli args to pass to git clone
	PullArgs  []string      // Additonal cli args to pass to git pull

	sync.Mutex
	// contains filtered or unexported fields
}

Repo is the structure that holds required information of a git repository.

func (*Repo) Prepare

func (r *Repo) Prepare() error

Prepare prepares for a git pull and validates the configured directory

func (*Repo) Pull

func (r *Repo) Pull() error

Pull attempts a git pull. It retries at most numRetries times if error occurs

Jump to

Keyboard shortcuts

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