Skip to content

Commit

Permalink
fix #368 build on FreeBSD and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bnfinet committed Feb 21, 2021
1 parent 6e33d2a commit 09a72ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ All Vouch Proxy configuration items are documented in [config/config.yml_example
- [set `HTTP_PROXY` to relay Vouch Proxy IdP requests through an outbound proxy server](https://github.com/vouch/vouch-proxy/issues/291)
- [Reverse Proxy for Google Cloud Run Services](https://github.com/karthikv2k/oauth_reverse_proxy)
- [Enable native TLS in Vouch Proxy](https://github.com/vouch/vouch-proxy/pull/332#issue-522612010)
- [FreeBSD support](https://github.com/vouch/vouch-proxy/issues/368)

Please do help us to expand this list.

Expand Down
37 changes: 15 additions & 22 deletions do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ NAME=vouch-proxy
HTTPPORT=9090
GODOC_PORT=5050

#--YetAnotherBugHunter 02/20/21
#-- Added function Hostname() to hide
#-- the detail of querying for a host's
#-- fully-qualified domain name since how
#-- this is done can vary based on the OS.
run () {
go run main.go
}

Hostname() {
build () {
local VERSION=$(git describe --always --long)
local DT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO-8601
local FQDN=$(_hostname)
local SEMVER=$(git tag --list --sort="v:refname" | tail -n -1)
local BRANCH=$(git rev-parse --abbrev-ref HEAD)
local UNAME=$(uname)
go build -i -v -ldflags=" -X main.version=${VERSION} -X main.uname=${UNAME} -X main.builddt=${DT} -X main.host=${FQDN} -X main.semver=${SEMVER} -X main.branch=${BRANCH}" .
}

_hostname() {
local FQDN
local HOSTNAME_CMD

Expand All @@ -34,28 +42,14 @@ GODOC_PORT=5050
esac

FQDN=$($HOSTNAME_CMD)
#-- Can't test against $? since the assignment to FQDN always succeeds even if $HOSTNAME_CMD fails.
if [ "$FQDN" = "" ]; then
if [ -z "$FQDN" ]; then
>&2 echo "error: Could determine the fully qualified domain name using command $HOSTNAME_CMD"
return 1
fi
echo $FQDN
return 0;
}

run () {
go run main.go
}

build () {
local VERSION=$(git describe --always --long)
local DT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # ISO-8601
local FQDN=$(Hostname)
local SEMVER=$(git tag --list --sort="v:refname" | tail -n -1)
local BRANCH=$(git rev-parse --abbrev-ref HEAD)
go build -i -v -ldflags=" -X main.version=${VERSION} -X main.builddt=${DT} -X main.host=${FQDN} -X main.semver=${SEMVER} -X main.branch=${BRANCH}" .
}

install () {
cp ./vouch-proxy ${GOPATH}/bin/vouch-proxy
}
Expand Down Expand Up @@ -346,7 +340,6 @@ profile() {
go tool pprof -http=0.0.0.0:19091 http://0.0.0.0:9090/debug/pprof/profile?seconds=10
}


gofmt() {
# segfault's without exec since it would just call this function infinitely :)
exec gofmt -w -s .
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
host = "undefined"
semver = "undefined"
branch = "undefined"
uname = "undefined"
staticDir = "/static/"
logger *zap.SugaredLogger
fastlog *zap.Logger
Expand Down Expand Up @@ -122,6 +123,7 @@ func main() {
// "semver": semver,
"version", version,
"buildtime", builddt,
"uname", uname,
"buildhost", host,
"branch", branch,
"semver", semver,
Expand Down

0 comments on commit 09a72ca

Please sign in to comment.