no longer pass build flags via ldflags
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
26322fa7d5
commit
8465dae8a3
4
Makefile
4
Makefile
|
@ -10,11 +10,11 @@ GO111MODULE=on
|
|||
|
||||
run:
|
||||
@echo your version of go must be greater than 2.10. Your version is ${GOVERSION}
|
||||
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT} -X main.GOVERSION='${GOVERSION}' -X main.BUILDTIME='${BUILDTIME}' -X main.VERSION=${VERSION}"
|
||||
go build
|
||||
./cloud-control-panel
|
||||
|
||||
build:
|
||||
go build -ldflags "-X main.GITCOMMIT=${GITCOMMIT}"
|
||||
go build
|
||||
|
||||
default-config: config-delete
|
||||
echo loading the test config
|
||||
|
|
40
config.go
40
config.go
|
@ -25,7 +25,7 @@ import "reflect"
|
|||
|
||||
import "github.com/golang/protobuf/jsonpb"
|
||||
import pb "git.wit.com/wit/witProtobuf"
|
||||
import "git.wit.com/wit/shell"
|
||||
// import "git.wit.com/wit/shell"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
|
@ -223,27 +223,10 @@ func parseConfig() {
|
|||
}
|
||||
}
|
||||
|
||||
version := shell.Run("cat VERSION")
|
||||
version = fmt.Sprintf("%s", strings.Trim(version, "\n"))
|
||||
|
||||
// version, _ := ioutil.ReadFile("VERSION")
|
||||
// version = fmt.Sprintf("%s", version.String())
|
||||
|
||||
perl(version)
|
||||
|
||||
log.Println("VERSION =", version)
|
||||
log.Println("len(VERSION) =", len(version))
|
||||
|
||||
tagref := shell.Run("cat .git/refs/tags/v" + version)
|
||||
perl(tagref)
|
||||
tagref = strings.TrimSpace(tagref)
|
||||
log.Println("VERSION git tag ref =", tagref)
|
||||
|
||||
config.Gitref = shell.Run("git rev-list -1 HEAD")
|
||||
|
||||
config.Goversion = shell.Run("go version")
|
||||
// config.Gitref = shell.Run("git rev-list -1 HEAD")
|
||||
|
||||
config.Dirty = false
|
||||
/*
|
||||
if (tagref == config.Gitref) {
|
||||
log.Println("setting config.Dirty = false")
|
||||
config.Dirty = false
|
||||
|
@ -251,23 +234,8 @@ func parseConfig() {
|
|||
log.Println("setting config.Dirty = true")
|
||||
config.Dirty = true
|
||||
}
|
||||
*/
|
||||
|
||||
buf := shell.Wget("https://mirrors.wit.com/cloud/control-panel/VERSION")
|
||||
upstream := shell.Chomp(buf)
|
||||
|
||||
epoch := shell.Run("git log -1 --format=%at v" + version)
|
||||
// epoch = chomp(epoch)
|
||||
|
||||
if (! config.Dirty) {
|
||||
// See if a newer version of this control panel exists
|
||||
|
||||
// if (epoch > time.now().Unix()) // seconds since epoch
|
||||
}
|
||||
|
||||
log.Println("epoch =", epoch)
|
||||
log.Println("version =", version)
|
||||
log.Println("upstream =", upstream)
|
||||
log.Println("tagref =", tagref)
|
||||
log.Println("config.Gitref =", config.Gitref)
|
||||
log.Println("config.Goversion =", config.Goversion)
|
||||
log.Println("config.Dirty =", config.Dirty)
|
||||
|
|
8
main.go
8
main.go
|
@ -20,10 +20,7 @@ import "git.wit.com/wit/shell"
|
|||
import "github.com/gobuffalo/packr"
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var GITCOMMIT string // this is passed in as an ldflag
|
||||
// var GOVERSION string // this is passed in as an ldflag
|
||||
// var BUILDTIME string // this is passed in as an ldflag
|
||||
// var VERSION string // this is passed in as an ldflag
|
||||
// var GITCOMMIT string // this is passed in as an ldflag
|
||||
|
||||
var State string // used as a State machine
|
||||
var sigChan chan os.Signal
|
||||
|
@ -100,6 +97,9 @@ func main() {
|
|||
|
||||
epoch := fmt.Sprintf("%d", time.Now().Unix())
|
||||
shell.Write("./resources/BUILDDATE", epoch)
|
||||
|
||||
ref := shell.Run("git rev-list -1 HEAD")
|
||||
shell.Write("./resources/BUILDREF", ref)
|
||||
// for {}
|
||||
|
||||
// This puts all the files in that directory in the binary
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
26322fa7d5382c9c03cfab9d49ee8c317fbaad6c
|
|
@ -22,15 +22,16 @@ func upgrade() {
|
|||
myBUILDVERSION = shell.Chomp(myBUILDVERSION)
|
||||
config.Version = myBUILDVERSION
|
||||
config.Builddate = shell.Int64(myBUILDDATE)
|
||||
config.Goversion = runtime.Version()
|
||||
|
||||
log.Println()
|
||||
log.Println("config.Dirty =", config.Dirty)
|
||||
log.Println("config.Goversion =", config.Goversion)
|
||||
log.Println()
|
||||
log.Println("myBUILDVERSION =", myBUILDVERSION)
|
||||
log.Println("myBUILDDATE =", myBUILDDATE)
|
||||
log.Println("mirrorsBUILDDATE =", mirrorsBUILDDATE)
|
||||
log.Println()
|
||||
log.Println("runtime.Version =", runtime.Version())
|
||||
log.Println("Number of CPUs =", runtime.NumCPU())
|
||||
log.Println("Number of GoRoutines =", runtime.NumGoroutine())
|
||||
log.Println("runtime.GOARCH =", runtime.GOARCH)
|
||||
|
|
Loading…
Reference in New Issue