mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
config/git-sync: add envvar prefix, fix README
This commit is contained in:
parent
0003d5d983
commit
d67db4ecfa
@ -1,4 +1,4 @@
|
||||
FROM golang:1.4-onbuild
|
||||
VOLUME ["/git"]
|
||||
CMD ["-dest", "/git"]
|
||||
ENV GIT_SYNC_DEST /git
|
||||
ENTRYPOINT ["/go/bin/git-sync"]
|
||||
|
@ -10,7 +10,7 @@ It can be used to source a container volume with the content of a git repo.
|
||||
# build the container
|
||||
docker build -t git-sync .
|
||||
# run the git-sync container
|
||||
docker run -d -e INTERVAL=1s -e REPO=https://github.com/GoogleCloudPlatform/kubernetes -e BRANCH=gh-pages -v /git-data:/usr/share/nginx/html git-sync
|
||||
docker run -d -e GIT_SYNC_INTERVAL=1s -e GIT_SYNC_REPO=https://github.com/GoogleCloudPlatform/kubernetes -e GIT_SYNC_BRANCH=gh-pages -v /git-data:/git git-sync
|
||||
# run a nginx container to serve sync'ed content
|
||||
docker run -d -p 8080:80 -v /git-data:/var/www nginx
|
||||
docker run -d -p 8080:80 -v /git-data:/usr/share/nginx/html nginx
|
||||
```
|
||||
|
@ -11,11 +11,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var interval = flag.String("interval", env("INTERVAL", "60s"), "git pull interval")
|
||||
var repo = flag.String("repo", env("REPO", ""), "git repo url")
|
||||
var branch = flag.String("branch", env("BRANCH", "master"), "git branch")
|
||||
var hook = flag.String("hook", env("HOOK", "/"), "web hook path")
|
||||
var dest = flag.String("dest", env("DEST", ""), "destination path")
|
||||
var interval = flag.String("interval", env("GIT_SYNC_INTERVAL", "60s"), "git pull interval")
|
||||
var repo = flag.String("repo", env("GIT_SYNC_REPO", ""), "git repo url")
|
||||
var branch = flag.String("branch", env("GIT_SYNC_BRANCH", "master"), "git branch")
|
||||
var handler = flag.String("handler", env("GIT_SYNC_HANDLER", "/"), "web hook handler")
|
||||
var dest = flag.String("dest", env("GIT_SYNC_DEST", ""), "destination path")
|
||||
|
||||
func env(key, def string) string {
|
||||
if env := os.Getenv(key); env != "" {
|
||||
@ -24,7 +24,7 @@ func env(key, def string) string {
|
||||
return def
|
||||
}
|
||||
|
||||
const usage = "usage: REPO= DEST= [INTERVAL= BRANCH= HOOK=] git-sync -repo GIT_REPO_URL -dest PATH [-interval -branch -hook]"
|
||||
const usage = "usage: GIT_SYNC_REPO= GIT_SYNC_DEST= [GIT_SYNC_INTERVAL= GIT_SYNC_BRANCH= GIT_SYNC_HANDLER=] git-sync -repo GIT_REPO_URL -dest PATH [-interval -branch -handler]"
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
@ -44,7 +44,7 @@ func main() {
|
||||
gitSync()
|
||||
}
|
||||
}()
|
||||
http.HandleFunc(*hook, func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandleFunc(*handler, func(w http.ResponseWriter, r *http.Request) {
|
||||
gitSync()
|
||||
})
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
|
Loading…
Reference in New Issue
Block a user