-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding version.Version, GitCommit, BuildDate; Put Version in App Gwy …
…tag (#202)
- Loading branch information
1 parent
75335bc
commit 64723c3
Showing
6 changed files
with
78 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package controller | ||
|
||
// An App Gateway tag: Resources tagged with this are exclusively managed by a Kubernetes Ingress. | ||
const isManagedByK8sIngress = "managed-by-k8s-ingress" | ||
const managedByK8sIngress = "managed-by-k8s-ingress" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// BuildDate is the date when the binary was built | ||
var BuildDate string | ||
|
||
// GitCommit is the commit hash when the binary was built | ||
var GitCommit string | ||
|
||
// Version is the version of the compiled software | ||
var Version string | ||
|
||
// PrintVersionAndExit prints the version and exits | ||
func PrintVersionAndExit() { | ||
fmt.Printf("Version: %s; Commit: %s; Date: %s\n", Version, GitCommit, BuildDate) | ||
os.Exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,66 @@ | ||
#!/bin/bash | ||
|
||
# colors | ||
COLOR_RESET='\e[0m' | ||
COLOR_BLUE='\e[44;97m' | ||
COLOR_RED='\e[101;97m' | ||
COLOR_GREEN='\e[42;97m' | ||
|
||
|
||
export GOOS=linux | ||
export GOBIN=`pwd`/bin | ||
|
||
GO_PROJ="github.com/Azure/application-gateway-kubernetes-ingress" | ||
GO_PKGS=`go list ./... | grep -v vendor/` | ||
GO_FILES=`find . -type f -name '*.go' -not -path "./vendor/*"` | ||
|
||
echo -e "\e[44;97m Running go lint.. \e[0m" | ||
ORG_PATH="github.com/Azure" | ||
PROJECT_NAME="application-gateway-kubernetes-ingress" | ||
REPO_PATH="${ORG_PATH}/${PROJECT_NAME}" | ||
|
||
VERSION_VAR="${REPO_PATH}/pkg/version.Version" | ||
VERSION=$(git describe --abbrev=0 --tags) | ||
|
||
DATE_VAR="${REPO_PATH}/pkg/version.BuildDate" | ||
BUILD_DATE=$(date +%Y-%m-%d-%H:%MT%z) | ||
|
||
COMMIT_VAR="${REPO_PATH}/pkg/version.GitCommit" | ||
GIT_HASH=$(git rev-parse --short HEAD) | ||
|
||
|
||
echo -e "$COLOR_BLUE Running go lint.. $COLOR_RESET" | ||
golint $GO_PKGS > /tmp/lint.out | ||
cat /tmp/lint.out | ||
cat /tmp/lint.out | ||
if [ -s /tmp/lint.out ]; then | ||
echo -e "\e[101;97m golint FAILED \e[0m"`` | ||
echo -e "$COLOR_RED golint FAILED $COLOR_RESET" | ||
exit 1 | ||
else | ||
echo -e "\e[42;97m golint SUCCEEDED \e[0m" | ||
echo -e "$COLOR_GREEN golint SUCCEEDED $COLOR_RESET" | ||
fi | ||
|
||
echo -e "\e[44;97m Running govet ... \e[0m" | ||
echo -e "$COLOR_BLUE Running govet ... $COLOR_RESET" | ||
if go vet -v $GO_PKGS; then | ||
echo -e "\e[42;97m govet SUCCEEDED \e[0m" | ||
echo -e "$COLOR_GREEN govet SUCCEEDED $COLOR_RESET" | ||
else | ||
echo -e "\e[101;97m govet FAILED \e[0m"`` | ||
echo -e "$COLOR_RED govet FAILED $COLOR_RESET" | ||
exit 1 | ||
fi | ||
|
||
echo -e "\e[44;97m Running goimports ... \e[0m" | ||
echo -e "$COLOR_BLUE Running goimports ... $COLOR_RESET" | ||
goimports -local $GO_PROJ -w $GO_FILES > /tmp/goimports.out | ||
cat /tmp/goimports.out | ||
if [ -s /tmp/goimports.out ]; then | ||
echo -e "\e[101;97m goimports FAILED \e[0m"`` | ||
echo -e "$COLOR_RED goimports FAILED $COLOR_RESET" | ||
exit 1 | ||
else | ||
echo -e "\e[42;97m goimports SUCCEEDED \e[0m" | ||
echo -e "$COLOR_GREEN goimports SUCCEEDED $COLOR_RESET" | ||
fi | ||
|
||
echo -e "\e[44;97m Compiling ... \e[0m" | ||
if go install -v ./cmd/appgw-ingress; then | ||
echo -e "$COLOR_BLUE Compiling ... $COLOR_RESET" | ||
if go install -ldflags "-s -X ${VERSION_VAR}=${VERSION} -X ${DATE_VAR}=${BUILD_DATE} -X ${COMMIT_VAR}=${GIT_HASH}" -v ./cmd/appgw-ingress; then | ||
chmod -R 777 bin | ||
echo -e "\e[42;97m Build SUCCEEDED \e[0m" | ||
echo -e "$COLOR_GREEN Build SUCCEEDED $COLOR_RESET" | ||
else | ||
echo -e "\e[101;97m Build FAILED \e[0m" | ||
echo -e "$COLOR_RED Build FAILED $COLOR_RESET" | ||
exit 1 | ||
fi | ||
fi |