Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build_tag to summary API endpoint #911

Merged
merged 4 commits into from
Oct 7, 2021
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
14 changes: 7 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/skywire-visor/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian

- id: skywire-cli
binary: skywire-cli
Expand All @@ -55,7 +55,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/skywire-cli/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian
- id: skychat
binary: apps/skychat
goos:
Expand All @@ -75,7 +75,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/apps/skychat/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian
- id: skysocks
binary: apps/skysocks
goos:
Expand All @@ -95,7 +95,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/apps/skysocks/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian
- id: skysocks-client
binary: apps/skysocks-client
goos:
Expand All @@ -115,7 +115,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/apps/skysocks-client/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian
- id: vpn-server
binary: apps/vpn-server
goos:
Expand All @@ -135,7 +135,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/apps/vpn-server/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian
- id: vpn-client
binary: apps/vpn-client
goos:
Expand All @@ -155,7 +155,7 @@ builds:
env:
- CGO_ENABLED=0
main: ./cmd/apps/vpn-client/
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}}
ldflags: -s -w -X github.com/skycoin/dmsg/buildinfo.version={{.Version}} -X github.com/skycoin/dmsg/buildinfo.commit={{.ShortCommit}} -X github.com/skycoin/dmsg/buildinfo.date={{.Date}} github.com/skycoin/skywire/pkg/visor.BuildTag=skybian
archives:
- format: tar.gz
wrap_in_directory: false
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ BUILDINFO_PATH := $(DMSG_BASE)/buildinfo
BUILDINFO_VERSION := -X $(BUILDINFO_PATH).version=$(VERSION)
BUILDINFO_DATE := -X $(BUILDINFO_PATH).date=$(DATE)
BUILDINFO_COMMIT := -X $(BUILDINFO_PATH).commit=$(COMMIT)
BUILDTAGINFO := -X $(PROJECT_BASE)/pkg/visor.BuildTag=$(BUILDTAG)

BUILDINFO?=$(BUILDINFO_VERSION) $(BUILDINFO_DATE) $(BUILDINFO_COMMIT)
BUILDINFO?=$(BUILDINFO_VERSION) $(BUILDINFO_DATE) $(BUILDINFO_COMMIT) $(BUILDTAGINFO)

BUILD_OPTS?="-ldflags=$(BUILDINFO)" -mod=vendor $(RACE_FLAG)
BUILD_OPTS_DEPLOY?="-ldflags=$(BUILDINFO) -w -s"
Expand Down
6 changes: 4 additions & 2 deletions cmd/skywire-visor/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package commands

import (
"context"
"embed"
"fmt"
"io"
"io/fs"
"io/ioutil"
"net/http"
_ "net/http/pprof" // nolint:gosec // https://golang.org/doc/diagnostics.html#profiling
Expand All @@ -17,6 +15,9 @@ import (
"syscall"
"time"

"embed"
"io/fs"

"github.com/pkg/profile"
"github.com/skycoin/dmsg/buildinfo"
"github.com/skycoin/dmsg/cmdutil"
Expand Down Expand Up @@ -86,6 +87,7 @@ func runVisor(args []string) {
WithField("systemd", restartCtx.Systemd()).
WithField("parent_systemd", restartCtx.ParentSystemd()).
WithField("skybian_build_version", os.Getenv("SKYBIAN_BUILD_VERSION")).
WithField("build_tag", visor.BuildTag).
Debugf("Process info")

// Versions v0.2.3 and below return 0 exit-code after update and do not trigger systemd to restart a process
Expand Down
5 changes: 5 additions & 0 deletions pkg/visor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ type Summary struct {
MinHops uint16 `json:"min_hops"`
PersistentTransports []transport.PersistentTransports `json:"persistent_transports"`
SkybianBuildVersion string `json:"skybian_build_version"`
BuildTag string `json:"build_tag"`
}

// BuildTag variable that will set when building binary
var BuildTag string

// Summary implements API.
func (v *Visor) Summary() (*Summary, error) {
overview, err := v.Overview()
Expand Down Expand Up @@ -214,6 +218,7 @@ func (v *Visor) Summary() (*Summary, error) {
MinHops: v.conf.Routing.MinHops,
PersistentTransports: pts,
SkybianBuildVersion: skybianBuildVersion,
BuildTag: BuildTag,
}

return summary, nil
Expand Down