Browse Source

Removed the bash info generation, now using ldflags

dependabot/npm_and_yarn/web/prismjs-1.21.0
Max Schmitt 8 years ago
parent
commit
944f3e491f
  1. 3
      Makefile
  2. 12
      build/info.sh
  3. 2
      handlers/handlers.go
  4. 18
      handlers/public.go
  5. 2
      static/src/About/About.js

3
Makefile

@ -11,7 +11,6 @@ buildNodeFrontend:
embedFrontend:
cd handlers/tmpls && esc -o tmpls.go -pkg tmpls -include ^*\.html .
cd handlers && esc -o static.go -pkg handlers -prefix ../static/build ../static/build
bash build/info.sh
getCMDDependencies:
go get -v github.com/mattn/goveralls
@ -31,6 +30,6 @@ buildProject:
buildDockerImage:
rm -rf docker_releases
mkdir docker_releases
CGO_ENABLED=0 gox -output="docker_releases/{{.Dir}}_{{.OS}}_{{.Arch}}/{{.Dir}}" -osarch="linux/amd64 linux/arm"
CGO_ENABLED=0 gox -output="docker_releases/{{.Dir}}_{{.OS}}_{{.Arch}}/{{.Dir}}" -osarch="linux/amd64 linux/arm" -ldflags="-X util.ldFlagNodeJS=`node --version` -X util.ldFlagCommit=`git rev-parse HEAD` -X util.ldFlagYarn=`yarn --version` -X util.ldFlagCompilationTime=`date --iso-8601=seconds`"
docker build -t maxibanki/golang_url_shortener:arm -f Dockerfile.arm .
docker build -t maxibanki/golang_url_shortener -f Dockerfile.amd64 .

12
build/info.sh

@ -1,12 +0,0 @@
cat > util/info.go <<EOL
package util
// VersionInfo contains the generated information which is
// done at build time and used for the frontend page About
var VersionInfo = map[string]string{
"nodeJS": "`node --version`",
"commit": "`git rev-parse HEAD`",
"compilationTime": "`date --iso-8601=seconds`",
"yarn": "`yarn --version`",
}
EOL

2
handlers/handlers.go

@ -90,7 +90,7 @@ func (h *Handler) setHandlers() error {
h.engine.NoRoute(h.handleAccess, func(c *gin.Context) {
c.Header("Vary", "Accept-Encoding")
c.Header("Cache-Control", "public, max-age=2592000")
c.Header("ETag", util.VersionInfo["commit"])
c.Header("ETag", util.VersionInfo.Commit)
}, gin.WrapH(http.FileServer(FS(false))))
return nil
}

18
handlers/public.go

@ -140,14 +140,16 @@ func (h *Handler) handleGetVisitors(c *gin.Context) {
}
func (h *Handler) handleInfo(c *gin.Context) {
info := gin.H{
"providers": h.providers,
"go": runtime.Version(),
}
for k, v := range util.VersionInfo {
info[k] = v
}
c.JSON(http.StatusOK, info)
out := struct {
util.Info
Providers []string `json:"providers"`
Go string
}{
util.VersionInfo,
h.providers,
strings.Replace(runtime.Version(), "go", "", 1),
}
c.JSON(http.StatusOK, out)
}
func (h *Handler) handleRecent(c *gin.Context) {

2
static/src/About/About.js

@ -42,7 +42,7 @@ export default class AboutComponent extends Component {
</Table.Row>
<Table.Row>
<Table.Cell>Go Version</Table.Cell>
<Table.Cell>{info.go.replace("go", "")}</Table.Cell>
<Table.Cell>{info.go}</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>React Version</Table.Cell>

Loading…
Cancel
Save