Add build script and basic versioning
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
ca822496b0
commit
12530471d0
|
@ -0,0 +1 @@
|
|||
/kubectl-persistent-logger
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
gitchanges="false"
|
||||
if [[ `git status --porcelain` ]]; then
|
||||
gitchanges="true"
|
||||
fi
|
||||
gitsha1=$(git rev-parse HEAD | head -c 9)
|
||||
buildtime=$(date --iso-8601=seconds)
|
||||
|
||||
go build -ldflags "-X main.gitchanges=$gitchanges -X main.gitSHA1=$gitsha1 -X main.buildTime=$buildtime"
|
14
main.go
14
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
|
@ -12,16 +13,29 @@ import (
|
|||
clientconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
|
||||
)
|
||||
|
||||
var (
|
||||
gitChanges = "unknown"
|
||||
gitSHA1 = "unknown"
|
||||
buildTime = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
container string
|
||||
strictExist bool
|
||||
version bool
|
||||
)
|
||||
|
||||
flag.StringVar(&container, "container", "", "name of a specific container")
|
||||
flag.BoolVar(&strictExist, "strict", false, "require deployment to exist on launch")
|
||||
flag.BoolVar(&version, "version", false, "print version and exit")
|
||||
flag.Parse()
|
||||
|
||||
if version {
|
||||
fmt.Fprintf(os.Stderr, "kubectl-persistent-logger, gitSHA1 = %s, gitChanges = %s, buildTime = %v\n", gitSHA1, gitChanges, buildTime)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
var params logs.WatcherParams
|
||||
|
||||
switch len(flag.Args()) {
|
||||
|
|
Loading…
Reference in New Issue