no longer pass build flags via ldflags

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-06 21:23:43 -07:00
parent 26322fa7d5
commit 8465dae8a3
5 changed files with 13 additions and 43 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

1
resources/BUILDREF Normal file
View File

@ -0,0 +1 @@
26322fa7d5382c9c03cfab9d49ee8c317fbaad6c

View File

@ -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)