Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/latest/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
}

variables_to_export = [
"version",
"envoyVersion",
"gatewayAPIVersion",
]
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import (
func GetRootCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "envoy-gateway",
Short: "Manages Envoy Proxy as a standalone or Kubernetes-based application gateway",
Short: "Envoy Gateway",
Long: "Manages Envoy Proxy as a standalone or Kubernetes-based application gateway",
}

cmd.AddCommand(getServerCommand())
cmd.AddCommand(getVersionsCommand())
cmd.AddCommand(getxDSTestCommand())
cmd.AddCommand(getCertGenCommand())
cmd.AddCommand(getVersionsCommand())

return cmd
}
42 changes: 42 additions & 0 deletions internal/cmd/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package version

import (
"fmt"
"runtime/debug"
"strings"

"github.com/envoyproxy/gateway/internal/ir"
)

var (
EnvoyGatewayVersion string
GatewayAPIVersion string
EnvoyVersion = strings.Split(ir.DefaultProxyImage, ":")[1]
GitCommitID string
)

func init() {
bi, ok := debug.ReadBuildInfo()
if ok {
for _, dep := range bi.Deps {
if dep.Path == "sigs.k8s.io/gateway-api" {
GatewayAPIVersion = dep.Version
}
}
}
}

// Print shows the versions of the Envoy Gateway.
func Print() error {
fmt.Printf("ENVOY_GATEWAY_VERSION: %s\n", EnvoyGatewayVersion)
fmt.Printf("ENVOY_VERSION: %s\n", EnvoyVersion)
fmt.Printf("GATEWAYAPI_VERSION: %s\n", GatewayAPIVersion)
fmt.Printf("GIT_COMMIT_ID: %s\n", GitCommitID)

return nil
}
36 changes: 5 additions & 31 deletions internal/cmd/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ package cmd

import (
"fmt"
"runtime/debug"
"strings"

"github.com/envoyproxy/gateway/internal/ir"
"github.com/envoyproxy/gateway/internal/cmd/version"
"github.com/spf13/cobra"
)

Expand All @@ -36,36 +34,12 @@ func getVersionsCommand() *cobra.Command {

// versions shows the versions of the Envoy Gateway.
func versions(envOutput bool) error {
envoyVersion := strings.Split(ir.DefaultProxyImage, ":")[1]

if envOutput {
fmt.Printf("ENVOY_VERSION=\"%s\"\n", envoyVersion)
fmt.Printf("ENVOY_VERSION=\"%s\"\n", version.EnvoyVersion)
fmt.Printf("GATEWAYAPI_VERSION=\"%s\"\n", version.GatewayAPIVersion)
fmt.Printf("ENVOY_GATEWAY_VERSION=\"%s\"\n", version.EnvoyGatewayVersion)
} else {
fmt.Printf("Envoy: %s\n", envoyVersion)
}

bi, ok := debug.ReadBuildInfo()
if !ok {
return fmt.Errorf("could not read build info")
}

foundGatewayAPI := false

for _, dep := range bi.Deps {
if dep.Path == "sigs.k8s.io/gateway-api" {
if envOutput {
fmt.Printf("GATEWAYAPI_VERSION=\"%s\"\n", dep.Version)
} else {
fmt.Printf("Gateway API: %s\n", dep.Version)
}

foundGatewayAPI = true
break
}
}

if !foundGatewayAPI {
return fmt.Errorf("could not find Gateway API version")
return version.Print()
}

return nil
Expand Down
9 changes: 8 additions & 1 deletion tools/make/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#
# All make targets related to golang are defined in this file.

VERSION_PACKAGE := github.com/envoyproxy/gateway/internal/cmd/version

GO_LDFLAGS += -X $(VERSION_PACKAGE).EnvoyGatewayVersion=$(shell cat VERSION) \
-X $(VERSION_PACKAGE).GitCommitID=$(GIT_COMMIT)

GIT_COMMIT:=$(shell git rev-parse HEAD)

GOPATH := $(shell go env GOPATH)
ifeq ($(origin GOBIN), undefined)
GOBIN := $(GOPATH)/bin
Expand All @@ -20,7 +27,7 @@ go.build.%:
$(eval OS := $(word 1,$(subst _, ,$(PLATFORM))))
$(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM))))
@$(call log, "Building binary $(COMMAND) with commit $(REV) for $(OS) $(ARCH)")
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o $(OUTPUT_DIR)/$(OS)/$(ARCH)/$(COMMAND) $(ROOT_PACKAGE)/cmd/$(COMMAND)
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o $(OUTPUT_DIR)/$(OS)/$(ARCH)/$(COMMAND) -ldflags "$(GO_LDFLAGS)" $(ROOT_PACKAGE)/cmd/$(COMMAND)

# Build the envoy-gateway binaries in the hosted platforms.
.PHONY: go.build
Expand Down
1 change: 0 additions & 1 deletion tools/make/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ $(tools.bindir)/%: $(tools.srcdir)/%.sh
#
tools/controller-gen = $(tools.bindir)/controller-gen
tools/golangci-lint = $(tools.bindir)/golangci-lint
tools/goversion = $(tools.bindir)/goversion
tools/kustomize = $(tools.bindir)/kustomize
tools/kind = $(tools.bindir)/kind
tools/setup-envtest = $(tools.bindir)/setup-envtest
Expand Down
13 changes: 0 additions & 13 deletions tools/src/goversion/go.mod

This file was deleted.

16 changes: 0 additions & 16 deletions tools/src/goversion/go.sum

This file was deleted.

11 changes: 0 additions & 11 deletions tools/src/goversion/pin.go

This file was deleted.