From 4663aa1e3a5c08551657bdcd2341f62533ebfce6 Mon Sep 17 00:00:00 2001 From: Josh Holloway Date: Thu, 16 Jun 2016 19:45:36 +0100 Subject: [PATCH] Add GITHUB_TOKEN to allow go get from private repos --- README.md | 2 ++ builder-cross/build_environment.sh | 5 +++++ builder/build_environment.sh | 5 +++++ tester/build_environment.sh | 5 +++++ 4 files changed, 17 insertions(+) diff --git a/README.md b/README.md index e8094ab..3304585 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ If you just want to compile your application without packaging it in a Docker im * LDFLAGS - flags to pass to the linker (defaults to '-s') * COMPRESS_BINARY - if set to true, will use UPX to compress the final binary (defaults to false) * OUTPUT - if set, will use the `-o` option with `go build` to output the final binary to the value of this env var +* GITHUB_TOKEN - if set, will use "https://${GITHUB_TOKEN}:x-oauth-basic@github.com/" to download dependencies from github. Allowing access to private repos. The above are environment variables to be passed to the docker run command: @@ -120,6 +121,7 @@ The above are environment variables to be passed to the docker run command: -e LDFLAGS='-extldflags "-static"' \ -e COMPRESS_BINARY=true \ -e OUTPUT=/bin/my_go_binary \ + -e GITHUB_TOKEN=my_github_auth_token \ -v $(pwd):/src \ centurylink/golang-builder diff --git a/builder-cross/build_environment.sh b/builder-cross/build_environment.sh index f505fbb..8b79aca 100755 --- a/builder-cross/build_environment.sh +++ b/builder-cross/build_environment.sh @@ -29,6 +29,11 @@ mkdir -p "$(dirname "$pkgPath")" # Link source dir into GOPATH ln -sf /src "$pkgPath" +# If a github token is present use that.. +if [ "${GITHUB_TOKEN}" != "" ]; then + git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" +fi + if [ -e "$pkgPath/vendor" ]; then # Enable vendor experiment diff --git a/builder/build_environment.sh b/builder/build_environment.sh index f505fbb..8b79aca 100755 --- a/builder/build_environment.sh +++ b/builder/build_environment.sh @@ -29,6 +29,11 @@ mkdir -p "$(dirname "$pkgPath")" # Link source dir into GOPATH ln -sf /src "$pkgPath" +# If a github token is present use that.. +if [ "${GITHUB_TOKEN}" != "" ]; then + git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" +fi + if [ -e "$pkgPath/vendor" ]; then # Enable vendor experiment diff --git a/tester/build_environment.sh b/tester/build_environment.sh index f505fbb..8b79aca 100755 --- a/tester/build_environment.sh +++ b/tester/build_environment.sh @@ -29,6 +29,11 @@ mkdir -p "$(dirname "$pkgPath")" # Link source dir into GOPATH ln -sf /src "$pkgPath" +# If a github token is present use that.. +if [ "${GITHUB_TOKEN}" != "" ]; then + git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" +fi + if [ -e "$pkgPath/vendor" ]; then # Enable vendor experiment