{"modulePath":"github.com/bmbstack/caddy","version":"v0.7.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package git\n\nPackage git is the middleware that pull sites from git repo\n\nCaddyfile Syntax :\n\n\tgit repo path {\n\t\trepo\n\t\tpath\n\t\tbranch\n\t\tkey\n\t\tinterval\n\t\tthen command args\n\t}\n\trepo \t- git repository\n\t\tcompulsory. Both ssh (e.g. git@github.com:user/project.git)\n\t\tand https(e.g. https://github.com/user/project) are supported.\n\t\tCan be specified in either config block or top level\n\n\tpath \t- directory to pull into, relative to site root\n\t\toptional. Defaults to site root.\n\n\tbranch \t- git branch or tag\n\t\toptional. Defaults to master\n\n\tkey \t- path to private ssh key\n\t\toptional. Required for private repositories. e.g. /home/user/.ssh/id_rsa\n\n\tinterval- interval between git pulls in seconds\n\t\toptional. Defaults to 3600 (1 Hour).\n\n\tthen\t- command to execute after successful pull\n\t\toptional. If set, will execute only when there are new changes.\n\nExamples :\n\npublic repo pulled into site root\n\n\tgit github.com/user/myproject\n\npublic repo pulled into \\\u003croot\u003e/mysite\n\n\tgit https://github.com/user/myproject mysite\n\nprivate repo pulled into \\\u003croot\u003e/mysite with tag v1.0 and interval of 1 day.\n\n\tgit {\n\t\trepo \tgit@github.com:user/myproject\n\t\tbranch \tv1.0\n\t\tpath\tmysite\n\t\tkey \t/home/user/.ssh/id_rsa\n\t\tinterval 86400 # 1 day\n\t}\n\nCaddyfile with private git repo and php support via fastcgi. path defaults to /var/www/html/myphpsite as specified in root config.\n\n\t0.0.0.0:8080\n\n\tgit {\n\t\trepo \tgit@github.com:user/myphpsite\n\t\tkey \t/home/user/.ssh/id_rsa\n\t\tinterval 86400 # 1 day\n\t}\n\n\tfastcgi / 127.0.0.1:9000 php\n\n\troot /var/www/html/myphpsite\n\nA pull is first attempted after initialization. Afterwards, a pull is attempted after request to server and if time taken since last successful pull is higher than interval.\n\nAfter the first successful pull (should be during initialization except an error occurs), subsequent pulls are done in background and do not impact request time.\n\nNote: private repositories are currently only supported and tested on Linux and OSX\n\n## Constants\n\n```go\nconst DefaultInterval time.Duration = time.Hour * 1\n```\nDefaultInterval is the minimum interval to delay before requesting another git pull\n\n## Variables\n\n```go\nvar Logger *log.Logger\n```\nLogger is used to log errors; if nil, the default log.Logger is used.\n\n```go\nvar Services = \u0026services{}\n```\nServices holds all git pulling services and provides the function to stop them.\n\n## Functions\n\n```go\nfunc Init() error\n```\nInit validates git installation, locates the git executable binary in PATH and check for available shell to use.\n\n```go\nfunc SetOS(os gitos.OS)\n```\nSetOS sets the OS to be used. Intended to be used for tests to abstract OS level git actions.\n\n```go\nfunc Start(repo *Repo)\n```\nStart starts a new background service to pull periodically.\n\n## Types\n\n```go\ntype Repo struct {\n\tURL      string        // Repository URL\n\tPath     string        // Directory to pull to\n\tHost     string        // Git domain host e.g. github.com\n\tBranch   string        // Git branch\n\tKeyPath  string        // Path to private ssh key\n\tInterval time.Duration // Interval between pulls\n\tThen     string        // Command to execute after successful git pull\n\n\tsync.Mutex\n\t// contains filtered or unexported fields\n}\n```\nRepo is the structure that holds required information of a git repository.\n\n```go\nfunc (r *Repo) Prepare() error\n```\nPrepare prepares for a git pull and validates the configured directory\n\n```go\nfunc (r *Repo) Pull() error\n```\nPull attempts a git clone. It retries at most numRetries times if error occurs\n\n","path":"github.com/bmbstack/caddy/middleware/git","name":"git","synopsis":"Package git is the middleware that pull sites from git repo Caddyfile Syntax : git repo path { repo path branch key interval then command args } repo - git repository compulsory.","isRedistributable":true}
