Skip to content

Commit

Permalink
API version generated file (gravitational#7157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger authored Jun 18, 2021
1 parent 24063e6 commit a3aab98
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ifeq ("$(OS)","windows")
BINARIES=$(BUILDDIR)/tsh
endif

VERSRC = version.go gitref.go
VERSRC = version.go gitref.go api/version.go

KUBECONFIG ?=
TEST_KUBE ?=
Expand All @@ -134,7 +134,7 @@ export
# This is the default build target for convenience of working on
# a web UI.
.PHONY: all
all: $(VERSRC)
all: version
@echo "---> Building OSS binaries."
$(MAKE) $(BINARIES)

Expand Down Expand Up @@ -457,7 +457,11 @@ lint-helm:
fi; \
done

# This rule triggers re-generation of version.go and gitref.go if Makefile changes
# This rule triggers re-generation of version files if Makefile changes.
.PHONY: version
version: $(VERSRC)

# This rule triggers re-generation of version files specified if Makefile changes.
$(VERSRC): Makefile
VERSION=$(VERSION) $(MAKE) -f version.mk setver

Expand Down
5 changes: 0 additions & 5 deletions api/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,3 @@ const (
// requests a connection to the remote auth server.
RemoteAuthServer = "@remote-auth-server"
)

const (
// TODO(Joerger): change this to generated value
Version = "7.0.0-dev"
)
4 changes: 2 additions & 2 deletions api/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package metadata
import (
"context"

"github.com/gravitational/teleport/api/constants"
"github.com/gravitational/teleport/api"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
Expand All @@ -31,7 +31,7 @@ const (
// defaultMetadata returns the default metadata which will be added to all outgoing calls.
func defaultMetadata() map[string]string {
return map[string]string{
VersionKey: constants.Version,
VersionKey: api.Version,
}
}

Expand Down
11 changes: 11 additions & 0 deletions api/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make version'*/

package api

const (
Version = "7.0.0-dev"
)

// Gitref variable is automatically set to the output of git-describe
// during the build process
var Gitref string
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make setver'*/
/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make version'*/

package teleport

Expand Down
13 changes: 11 additions & 2 deletions version.mk
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
GITREF=`git describe --dirty --long --tags`

# $(VERSION_GO) will be written to version.go
VERSION_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make setver'*/\n\n\
VERSION_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make version'*/\n\n\
package teleport\n\
const( Version = \"$(VERSION)\" )\n\
// Gitref variable is automatically set to the output of "git-describe" \n\
// during the build process\n\
var Gitref string\n"

# $(API_VERSION_GO) will be written to api/version.go
API_VERSION_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make version'*/\n\n\
package api\n\
const( Version = \"$(VERSION)\" )\n\
// Gitref variable is automatically set to the output of "git-describe" \n\
// during the build process\n\
var Gitref string\n"

# $(GIT_GO) will be written to gitref.go
GITREF_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY make */ \n\n\
GITREF_GO="/* DO NOT EDIT THIS FILE. IT IS GENERATED BY 'make version' */ \n\n\
package teleport\n\
func init() { Gitref = \"$(GITREF)\"} "

Expand All @@ -19,6 +27,7 @@ func init() { Gitref = \"$(GITREF)\"} "
.PHONY:setver
setver: helm-version
@printf $(VERSION_GO) | gofmt > version.go
@printf $(API_VERSION_GO) | gofmt > ./api/version.go
@printf $(GITREF_GO) | gofmt > gitref.go

# helm-version automatically updates the versions of Helm charts to match the version set in the Makefile,
Expand Down

0 comments on commit a3aab98

Please sign in to comment.