Discard package "version" (#2107)
* Discard package "version" Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Inject api version Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Pass version arg to the dex API Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
parent
47d029a51b
commit
20875c972e
6 changed files with 14 additions and 18 deletions
2
Makefile
2
Makefile
|
@ -17,7 +17,7 @@ group=$(shell id -g -n)
|
|||
|
||||
export GOBIN=$(PWD)/bin
|
||||
|
||||
LD_FLAGS="-w -X $(REPO_PATH)/version.Version=$(VERSION)"
|
||||
LD_FLAGS="-w -X main.version=$(VERSION)"
|
||||
|
||||
# Dependency versions
|
||||
GOLANGCI_VERSION = 1.32.2
|
||||
|
|
|
@ -449,7 +449,7 @@ func runServe(options serveOptions) error {
|
|||
}
|
||||
|
||||
grpcSrv := grpc.NewServer(grpcOptions...)
|
||||
api.RegisterDexServer(grpcSrv, server.NewAPI(serverConfig.Storage, logger))
|
||||
api.RegisterDexServer(grpcSrv, server.NewAPI(serverConfig.Storage, logger, version))
|
||||
|
||||
grpcMetrics.InitializeMetrics(grpcSrv)
|
||||
if c.GRPC.Reflection {
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/dexidp/dex/version"
|
||||
)
|
||||
|
||||
var version = "DEV"
|
||||
|
||||
func commandVersion() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
|
@ -16,7 +16,7 @@ func commandVersion() *cobra.Command {
|
|||
Run: func(_ *cobra.Command, _ []string) {
|
||||
fmt.Printf(
|
||||
"Dex Version: %s\nGo Version: %s\nGo OS/ARCH: %s %s\n",
|
||||
version.Version,
|
||||
version,
|
||||
runtime.Version(),
|
||||
runtime.GOOS,
|
||||
runtime.GOARCH,
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/dexidp/dex/pkg/log"
|
||||
"github.com/dexidp/dex/server/internal"
|
||||
"github.com/dexidp/dex/storage"
|
||||
"github.com/dexidp/dex/version"
|
||||
)
|
||||
|
||||
// apiVersion increases every time a new call is added to the API. Clients should use this info
|
||||
|
@ -30,18 +29,20 @@ const (
|
|||
)
|
||||
|
||||
// NewAPI returns a server which implements the gRPC API interface.
|
||||
func NewAPI(s storage.Storage, logger log.Logger) api.DexServer {
|
||||
func NewAPI(s storage.Storage, logger log.Logger, version string) api.DexServer {
|
||||
return dexAPI{
|
||||
s: s,
|
||||
logger: logger,
|
||||
s: s,
|
||||
logger: logger,
|
||||
version: version,
|
||||
}
|
||||
}
|
||||
|
||||
type dexAPI struct {
|
||||
api.UnimplementedDexServer
|
||||
|
||||
s storage.Storage
|
||||
logger log.Logger
|
||||
s storage.Storage
|
||||
logger log.Logger
|
||||
version string
|
||||
}
|
||||
|
||||
func (d dexAPI) CreateClient(ctx context.Context, req *api.CreateClientReq) (*api.CreateClientResp, error) {
|
||||
|
@ -223,7 +224,7 @@ func (d dexAPI) DeletePassword(ctx context.Context, req *api.DeletePasswordReq)
|
|||
|
||||
func (d dexAPI) GetVersion(ctx context.Context, req *api.VersionReq) (*api.VersionResp, error) {
|
||||
return &api.VersionResp{
|
||||
Server: version.Version,
|
||||
Server: d.version,
|
||||
Api: apiVersion,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func newAPI(s storage.Storage, logger log.Logger, t *testing.T) *apiClient {
|
|||
}
|
||||
|
||||
serv := grpc.NewServer()
|
||||
api.RegisterDexServer(serv, NewAPI(s, logger))
|
||||
api.RegisterDexServer(serv, NewAPI(s, logger, "test"))
|
||||
go serv.Serve(l)
|
||||
|
||||
// Dial will retry automatically if the serv.Serve() goroutine
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
// Package version contains version information for this app.
|
||||
package version
|
||||
|
||||
// Version is set by the build scripts.
|
||||
var Version = "was not built properly"
|
Reference in a new issue