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:
Maksim Nabokikh 2021-05-18 01:55:24 +03:00 committed by GitHub
parent 47d029a51b
commit 20875c972e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 18 deletions

View File

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

View File

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

View File

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

View File

@ -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,10 +29,11 @@ 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,
version: version,
}
}
@ -42,6 +42,7 @@ type dexAPI struct {
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
}

View File

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

View File

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