mirror of
https://github.com/openziti/zrok.git
synced 2025-02-16 18:20:51 +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]
|
on: [push]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
ubuntu-build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -27,7 +27,7 @@ jobs:
|
|||||||
CI: ""
|
CI: ""
|
||||||
|
|
||||||
- name: go build
|
- 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
|
- name: test
|
||||||
run: go test -v ./...
|
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 mtr *metricsAgent
|
||||||
var idb influxdb2.Client
|
var idb influxdb2.Client
|
||||||
|
|
||||||
const version = "v0.2.0"
|
|
||||||
|
|
||||||
func Run(inCfg *Config) error {
|
func Run(inCfg *Config) error {
|
||||||
cfg = inCfg
|
cfg = inCfg
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"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/controller/store"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
"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 {
|
func (self *enableHandler) zrokTags() *rest_model_edge.Tags {
|
||||||
return &rest_model_edge.Tags{
|
return &rest_model_edge.Tags{
|
||||||
SubTags: map[string]interface{}{
|
SubTags: map[string]interface{}{
|
||||||
"zrok": version,
|
"zrok": build.String(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"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/controller/store"
|
||||||
"github.com/openziti-test-kitchen/zrok/model"
|
"github.com/openziti-test-kitchen/zrok/model"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
"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 {
|
func (self *tunnelHandler) zrokTags(svcName string) *rest_model.Tags {
|
||||||
return &rest_model.Tags{
|
return &rest_model.Tags{
|
||||||
SubTags: map[string]interface{}{
|
SubTags: map[string]interface{}{
|
||||||
"zrok": version,
|
"zrok": build.String(),
|
||||||
"zrok-service-name": svcName,
|
"zrok-service-name": svcName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"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"
|
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func versionHandler(_ metadata.VersionParams) middleware.Responder {
|
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