Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d67db4ec
Commit
d67db4ec
authored
Dec 22, 2014
by
Johan Euphrosine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config/git-sync: add envvar prefix, fix README
parent
0003d5d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
Dockerfile
contrib/git-sync/Dockerfile
+1
-1
README.md
contrib/git-sync/README.md
+2
-2
main.go
contrib/git-sync/main.go
+7
-7
No files found.
contrib/git-sync/Dockerfile
View file @
d67db4ec
FROM
golang:1.4-onbuild
VOLUME
["/git"]
CMD
["-dest", "/git"]
ENV
GIT_SYNC_DEST /git
ENTRYPOINT
["/go/bin/git-sync"]
contrib/git-sync/README.md
View file @
d67db4ec
...
...
@@ -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
```
contrib/git-sync/main.go
View file @
d67db4ec
...
...
@@ -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
h
ook
=
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
h
andler
=
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
(
*
h
ook
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
http
.
HandleFunc
(
*
h
andler
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
gitSync
()
})
log
.
Fatal
(
http
.
ListenAndServe
(
":8080"
,
nil
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment