mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
add build-time version metadata (#70)
This commit is contained in:
parent
1938896dd5
commit
e062a9f61f
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -1,9 +1,9 @@
|
||||
name: Go package
|
||||
name: Core Build
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
ubuntu-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -27,7 +27,7 @@ jobs:
|
||||
CI: ""
|
||||
|
||||
- name: go build
|
||||
run: go build -v ./...
|
||||
run: go build -ldflags "-X github.com/openziti-test-kitchen/zrok/build.Version=${{ github.ref }} -X github.com/openziti-test-kitchen/zrok/build.Hash=${{ github.sha }}" ./...
|
||||
|
||||
- name: test
|
||||
run: go test -v ./...
|
14
build/metadata.go
Normal file
14
build/metadata.go
Normal file
@ -0,0 +1,14 @@
|
||||
package build
|
||||
|
||||
import "fmt"
|
||||
|
||||
var Version string
|
||||
var Hash string
|
||||
|
||||
func String() string {
|
||||
if Version != "" {
|
||||
return fmt.Sprintf("%v [%v]", Version, Hash)
|
||||
} else {
|
||||
return "<developer_build>"
|
||||
}
|
||||
}
|
@ -16,8 +16,6 @@ var str *store.Store
|
||||
var mtr *metricsAgent
|
||||
var idb influxdb2.Client
|
||||
|
||||
const version = "v0.2.0"
|
||||
|
||||
func Run(inCfg *Config) error {
|
||||
cfg = inCfg
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/build"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
||||
@ -165,7 +166,7 @@ func (self *enableHandler) createEdgeRouterPolicy(id string, edge *rest_manageme
|
||||
func (self *enableHandler) zrokTags() *rest_model_edge.Tags {
|
||||
return &rest_model_edge.Tags{
|
||||
SubTags: map[string]interface{}{
|
||||
"zrok": version,
|
||||
"zrok": build.String(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/build"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
@ -264,7 +265,7 @@ func (self *tunnelHandler) proxyUrl(svcName string) string {
|
||||
func (self *tunnelHandler) zrokTags(svcName string) *rest_model.Tags {
|
||||
return &rest_model.Tags{
|
||||
SubTags: map[string]interface{}{
|
||||
"zrok": version,
|
||||
"zrok": build.String(),
|
||||
"zrok-service-name": svcName,
|
||||
},
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package controller
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/build"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
|
||||
)
|
||||
|
||||
func versionHandler(_ metadata.VersionParams) middleware.Responder {
|
||||
return metadata.NewVersionOK().WithPayload(version)
|
||||
return metadata.NewVersionOK().WithPayload(rest_model_zrok.Version(build.String()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user