mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-20 11:58:39 +00:00
version: unexport all vars, turn Short/Long into funcs
The other formerly exported values aren't used outside the package, so just unexport them. Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
9e6b4d7ad8
commit
8b2ae47c31
@ -62,9 +62,9 @@ ENV VERSION_GIT_HASH=$VERSION_GIT_HASH
|
|||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
RUN GOARCH=$TARGETARCH go install -ldflags="\
|
RUN GOARCH=$TARGETARCH go install -ldflags="\
|
||||||
-X tailscale.com/version.Long=$VERSION_LONG \
|
-X tailscale.com/version.long=$VERSION_LONG \
|
||||||
-X tailscale.com/version.Short=$VERSION_SHORT \
|
-X tailscale.com/version.short=$VERSION_SHORT \
|
||||||
-X tailscale.com/version.GitCommit=$VERSION_GIT_HASH" \
|
-X tailscale.com/version.gitCommit=$VERSION_GIT_HASH" \
|
||||||
-v ./cmd/tailscale ./cmd/tailscaled ./cmd/containerboot
|
-v ./cmd/tailscale ./cmd/tailscaled ./cmd/containerboot
|
||||||
|
|
||||||
FROM alpine:3.16
|
FROM alpine:3.16
|
||||||
|
@ -46,7 +46,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
tags=""
|
tags=""
|
||||||
ldflags="-X tailscale.com/version.Long=${LONG} -X tailscale.com/version.Short=${SHORT} -X tailscale.com/version.GitCommit=${GIT_HASH}"
|
ldflags="-X tailscale.com/version.long=${LONG} -X tailscale.com/version.short=${SHORT} -X tailscale.com/version.gitCommit=${GIT_HASH}"
|
||||||
|
|
||||||
# build_dist.sh arguments must precede go build arguments.
|
# build_dist.sh arguments must precede go build arguments.
|
||||||
while [ "$#" -gt 1 ]; do
|
while [ "$#" -gt 1 ]; do
|
||||||
|
@ -43,9 +43,9 @@ case "$TARGET" in
|
|||||||
tailscale.com/cmd/tailscaled:/usr/local/bin/tailscaled, \
|
tailscale.com/cmd/tailscaled:/usr/local/bin/tailscaled, \
|
||||||
tailscale.com/cmd/containerboot:/usr/local/bin/containerboot" \
|
tailscale.com/cmd/containerboot:/usr/local/bin/containerboot" \
|
||||||
--ldflags="\
|
--ldflags="\
|
||||||
-X tailscale.com/version.Long=${VERSION_LONG} \
|
-X tailscale.com/version.long=${VERSION_LONG} \
|
||||||
-X tailscale.com/version.Short=${VERSION_SHORT} \
|
-X tailscale.com/version.short=${VERSION_SHORT} \
|
||||||
-X tailscale.com/version.GitCommit=${VERSION_GIT_HASH}" \
|
-X tailscale.com/version.gitCommit=${VERSION_GIT_HASH}" \
|
||||||
--base="${BASE}" \
|
--base="${BASE}" \
|
||||||
--tags="${TAGS}" \
|
--tags="${TAGS}" \
|
||||||
--repos="${REPOS}" \
|
--repos="${REPOS}" \
|
||||||
@ -58,9 +58,9 @@ case "$TARGET" in
|
|||||||
go run github.com/tailscale/mkctr \
|
go run github.com/tailscale/mkctr \
|
||||||
--gopaths="tailscale.com/cmd/k8s-operator:/usr/local/bin/operator" \
|
--gopaths="tailscale.com/cmd/k8s-operator:/usr/local/bin/operator" \
|
||||||
--ldflags="\
|
--ldflags="\
|
||||||
-X tailscale.com/version.Long=${VERSION_LONG} \
|
-X tailscale.com/version.long=${VERSION_LONG} \
|
||||||
-X tailscale.com/version.Short=${VERSION_SHORT} \
|
-X tailscale.com/version.short=${VERSION_SHORT} \
|
||||||
-X tailscale.com/version.GitCommit=${VERSION_GIT_HASH}" \
|
-X tailscale.com/version.gitCommit=${VERSION_GIT_HASH}" \
|
||||||
--base="${BASE}" \
|
--base="${BASE}" \
|
||||||
--tags="${TAGS}" \
|
--tags="${TAGS}" \
|
||||||
--repos="${REPOS}" \
|
--repos="${REPOS}" \
|
||||||
|
@ -160,12 +160,12 @@ type updater struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (up *updater) currentOrDryRun(ver string) bool {
|
func (up *updater) currentOrDryRun(ver string) bool {
|
||||||
if version.Short == ver {
|
if version.Short() == ver {
|
||||||
fmt.Printf("already running %v; no update needed\n", ver)
|
fmt.Printf("already running %v; no update needed\n", ver)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if updateArgs.dryRun {
|
if updateArgs.dryRun {
|
||||||
fmt.Printf("Current: %v, Latest: %v\n", version.Short, ver)
|
fmt.Printf("Current: %v, Latest: %v\n", version.Short(), ver)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -173,11 +173,11 @@ func (up *updater) currentOrDryRun(ver string) bool {
|
|||||||
|
|
||||||
func (up *updater) confirm(ver string) error {
|
func (up *updater) confirm(ver string) error {
|
||||||
if updateArgs.yes {
|
if updateArgs.yes {
|
||||||
log.Printf("Updating Tailscale from %v to %v; --yes given, continuing without prompts.\n", version.Short, ver)
|
log.Printf("Updating Tailscale from %v to %v; --yes given, continuing without prompts.\n", version.Short(), ver)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("This will update Tailscale from %v to %v. Continue? [y/n] ", version.Short, ver)
|
fmt.Printf("This will update Tailscale from %v to %v. Continue? [y/n] ", version.Short(), ver)
|
||||||
var resp string
|
var resp string
|
||||||
fmt.Scanln(&resp)
|
fmt.Scanln(&resp)
|
||||||
resp = strings.ToLower(resp)
|
resp = strings.ToLower(resp)
|
||||||
@ -430,7 +430,7 @@ func installMSI(msi string) error {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
uninstallVersion := version.Short
|
uninstallVersion := version.Short()
|
||||||
if v := os.Getenv("TS_DEBUG_UNINSTALL_VERSION"); v != "" {
|
if v := os.Getenv("TS_DEBUG_UNINSTALL_VERSION"); v != "" {
|
||||||
uninstallVersion = v
|
uninstallVersion = v
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ func beWindowsSubprocess() bool {
|
|||||||
// Remove the date/time prefix; the logtail + file loggers add it.
|
// Remove the date/time prefix; the logtail + file loggers add it.
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
log.Printf("Program starting: v%v: %#v", version.Long, os.Args)
|
log.Printf("Program starting: v%v: %#v", version.Long(), os.Args)
|
||||||
log.Printf("subproc mode: logid=%v", logid)
|
log.Printf("subproc mode: logid=%v", logid)
|
||||||
if err := envknob.ApplyDiskConfigError(); err != nil {
|
if err := envknob.ApplyDiskConfigError(); err != nil {
|
||||||
log.Printf("Error reading environment config: %v", err)
|
log.Printf("Error reading environment config: %v", err)
|
||||||
|
@ -54,7 +54,7 @@ func runBuildPkg() {
|
|||||||
log.Fatalf("Cannot copy readme: %v", err)
|
log.Fatalf("Cannot copy readme: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Built package version %s", version.Long)
|
log.Printf("Built package version %s", version.Long())
|
||||||
}
|
}
|
||||||
|
|
||||||
func precompressWasm() error {
|
func precompressWasm() error {
|
||||||
@ -78,7 +78,7 @@ func updateVersion() error {
|
|||||||
if err := json.Unmarshal(packageJSONBytes, &packageJSON); err != nil {
|
if err := json.Unmarshal(packageJSONBytes, &packageJSON); err != nil {
|
||||||
return fmt.Errorf("Could not unmarshal package.json: %w", err)
|
return fmt.Errorf("Could not unmarshal package.json: %w", err)
|
||||||
}
|
}
|
||||||
packageJSON["version"] = version.Long
|
packageJSON["version"] = version.Long()
|
||||||
|
|
||||||
packageJSONBytes, err = json.MarshalIndent(packageJSON, "", " ")
|
packageJSONBytes, err = json.MarshalIndent(packageJSON, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1736,7 +1736,7 @@ func (s *Server) ExpVar() expvar.Var {
|
|||||||
}))
|
}))
|
||||||
m.Set("counter_tcp_rtt", &s.tcpRtt)
|
m.Set("counter_tcp_rtt", &s.tcpRtt)
|
||||||
var expvarVersion expvar.String
|
var expvarVersion expvar.String
|
||||||
expvarVersion.Set(version.Long)
|
expvarVersion.Set(version.Long())
|
||||||
m.Set("version", &expvarVersion)
|
m.Set("version", &expvarVersion)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -485,5 +485,5 @@ func IPCVersion() string {
|
|||||||
if v := String("TS_DEBUG_FAKE_IPC_VERSION"); v != "" {
|
if v := String("TS_DEBUG_FAKE_IPC_VERSION"); v != "" {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
return version.Long
|
return version.Long()
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func New() *tailcfg.Hostinfo {
|
|||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
hostname = dnsname.FirstLabel(hostname)
|
hostname = dnsname.FirstLabel(hostname)
|
||||||
return &tailcfg.Hostinfo{
|
return &tailcfg.Hostinfo{
|
||||||
IPNVersion: version.Long,
|
IPNVersion: version.Long(),
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
OS: version.OS(),
|
OS: version.OS(),
|
||||||
OSVersion: GetOSVersion(),
|
OSVersion: GetOSVersion(),
|
||||||
|
@ -145,7 +145,7 @@ func (b *LocalBackend) handleC2NUpdate(w http.ResponseWriter, r *http.Request) {
|
|||||||
res.Err = "invalid JSON from cmd/tailscale version --json"
|
res.Err = "invalid JSON from cmd/tailscale version --json"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ver.Long != version.Long {
|
if ver.Long != version.Long() {
|
||||||
res.Err = "cmd/tailscale version mismatch"
|
res.Err = "cmd/tailscale version mismatch"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ func (b *LocalBackend) getCertPEM(ctx context.Context, logf logger.Logf, traceAC
|
|||||||
}
|
}
|
||||||
ac := &acme.Client{
|
ac := &acme.Client{
|
||||||
Key: key,
|
Key: key,
|
||||||
UserAgent: "tailscaled/" + version.Long,
|
UserAgent: "tailscaled/" + version.Long(),
|
||||||
}
|
}
|
||||||
|
|
||||||
a, err := ac.GetReg(ctx, "" /* pre-RFC param */)
|
a, err := ac.GetReg(ctx, "" /* pre-RFC param */)
|
||||||
|
@ -592,7 +592,7 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func
|
|||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
sb.MutateStatus(func(s *ipnstate.Status) {
|
sb.MutateStatus(func(s *ipnstate.Status) {
|
||||||
s.Version = version.Long
|
s.Version = version.Long()
|
||||||
s.TUN = !wgengine.IsNetstack(b.e)
|
s.TUN = !wgengine.IsNetstack(b.e)
|
||||||
s.BackendState = b.state.String()
|
s.BackendState = b.state.String()
|
||||||
s.AuthURL = b.authURLSticky
|
s.AuthURL = b.authURLSticky
|
||||||
@ -1853,7 +1853,7 @@ func (b *LocalBackend) WatchNotifications(ctx context.Context, mask ipn.NotifyWa
|
|||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
const initialBits = ipn.NotifyInitialState | ipn.NotifyInitialPrefs | ipn.NotifyInitialNetMap
|
const initialBits = ipn.NotifyInitialState | ipn.NotifyInitialPrefs | ipn.NotifyInitialNetMap
|
||||||
if mask&initialBits != 0 {
|
if mask&initialBits != 0 {
|
||||||
ini = &ipn.Notify{Version: version.Long}
|
ini = &ipn.Notify{Version: version.Long()}
|
||||||
if mask&ipn.NotifyInitialState != 0 {
|
if mask&ipn.NotifyInitialState != 0 {
|
||||||
ini.State = ptr.To(b.state)
|
ini.State = ptr.To(b.state)
|
||||||
if b.state == ipn.NeedsLogin {
|
if b.state == ipn.NeedsLogin {
|
||||||
@ -1952,7 +1952,7 @@ func (b *LocalBackend) send(n ipn.Notify) {
|
|||||||
n.Prefs = ptr.To(stripKeysFromPrefs(*n.Prefs))
|
n.Prefs = ptr.To(stripKeysFromPrefs(*n.Prefs))
|
||||||
}
|
}
|
||||||
if n.Version == "" {
|
if n.Version == "" {
|
||||||
n.Version = version.Long
|
n.Version = version.Long()
|
||||||
}
|
}
|
||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
|
@ -155,7 +155,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "invalid localapi request", http.StatusForbidden)
|
http.Error(w, "invalid localapi request", http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Tailscale-Version", version.Long)
|
w.Header().Set("Tailscale-Version", version.Long())
|
||||||
w.Header().Set("Tailscale-Cap", strconv.Itoa(int(tailcfg.CurrentCapabilityVersion)))
|
w.Header().Set("Tailscale-Cap", strconv.Itoa(int(tailcfg.CurrentCapabilityVersion)))
|
||||||
w.Header().Set("Content-Security-Policy", `default-src 'none'; frame-ancestors 'none'; script-src 'none'; script-src-elem 'none'; script-src-attr 'none'`)
|
w.Header().Set("Content-Security-Policy", `default-src 'none'; frame-ancestors 'none'; script-src 'none'; script-src-elem 'none'; script-src-attr 'none'`)
|
||||||
w.Header().Set("X-Frame-Options", "DENY")
|
w.Header().Set("X-Frame-Options", "DENY")
|
||||||
@ -731,7 +731,7 @@ func InUseOtherUserIPNStream(w http.ResponseWriter, r *http.Request, err error)
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
js, err := json.Marshal(&ipn.Notify{
|
js, err := json.Marshal(&ipn.Notify{
|
||||||
Version: version.Long,
|
Version: version.Long(),
|
||||||
State: ptr.To(ipn.InUseOtherUser),
|
State: ptr.To(ipn.InUseOtherUser),
|
||||||
ErrMessage: ptr.To(err.Error()),
|
ErrMessage: ptr.To(err.Error()),
|
||||||
})
|
})
|
||||||
|
@ -612,7 +612,7 @@ func NewWithConfigPath(collection, dir, cmdName string) *Policy {
|
|||||||
log.SetOutput(logOutput)
|
log.SetOutput(logOutput)
|
||||||
|
|
||||||
log.Printf("Program starting: v%v, Go %v: %#v",
|
log.Printf("Program starting: v%v, Go %v: %#v",
|
||||||
version.Long,
|
version.Long(),
|
||||||
goVersion(),
|
goVersion(),
|
||||||
os.Args)
|
os.Args)
|
||||||
log.Printf("LogID: %v", newc.PublicID)
|
log.Printf("LogID: %v", newc.PublicID)
|
||||||
|
@ -413,7 +413,7 @@ func (f *forwarder) sendDoH(ctx context.Context, urlBase string, c *http.Client,
|
|||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", dohType)
|
req.Header.Set("Content-Type", dohType)
|
||||||
req.Header.Set("Accept", dohType)
|
req.Header.Set("Accept", dohType)
|
||||||
req.Header.Set("User-Agent", "tailscaled/"+version.Long)
|
req.Header.Set("User-Agent", "tailscaled/"+version.Long())
|
||||||
|
|
||||||
hres, err := c.Do(req)
|
hres, err := c.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -52,7 +52,7 @@ func Debugger(mux *http.ServeMux) *DebugHandler {
|
|||||||
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||||
|
|
||||||
ret.KVFunc("Uptime", func() any { return Uptime() })
|
ret.KVFunc("Uptime", func() any { return Uptime() })
|
||||||
ret.KV("Version", version.Long)
|
ret.KV("Version", version.Long())
|
||||||
ret.Handle("vars", "Metrics (Go)", expvar.Handler())
|
ret.Handle("vars", "Metrics (Go)", expvar.Handler())
|
||||||
ret.Handle("varz", "Metrics (Prometheus)", http.HandlerFunc(VarzHandler))
|
ret.Handle("varz", "Metrics (Prometheus)", http.HandlerFunc(VarzHandler))
|
||||||
ret.Handle("pprof/", "pprof", http.HandlerFunc(pprof.Index))
|
ret.Handle("pprof/", "pprof", http.HandlerFunc(pprof.Index))
|
||||||
|
@ -37,7 +37,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
expvar.Publish("process_start_unix_time", expvar.Func(func() any { return timeStart.Unix() }))
|
expvar.Publish("process_start_unix_time", expvar.Func(func() any { return timeStart.Unix() }))
|
||||||
expvar.Publish("version", expvar.Func(func() any { return version.Long }))
|
expvar.Publish("version", expvar.Func(func() any { return version.Long() }))
|
||||||
expvar.Publish("go_version", expvar.Func(func() any { return runtime.Version() }))
|
expvar.Publish("go_version", expvar.Func(func() any { return runtime.Version() }))
|
||||||
expvar.Publish("counter_uptime_sec", expvar.Func(func() any { return int64(Uptime().Seconds()) }))
|
expvar.Publish("counter_uptime_sec", expvar.Func(func() any { return int64(Uptime().Seconds()) }))
|
||||||
expvar.Publish("gauge_goroutines", expvar.Func(func() any { return runtime.NumGoroutine() }))
|
expvar.Publish("gauge_goroutines", expvar.Func(func() any { return runtime.NumGoroutine() }))
|
||||||
|
@ -11,20 +11,20 @@ import (
|
|||||||
|
|
||||||
func String() string {
|
func String() string {
|
||||||
var ret strings.Builder
|
var ret strings.Builder
|
||||||
ret.WriteString(Short)
|
ret.WriteString(short)
|
||||||
ret.WriteByte('\n')
|
ret.WriteByte('\n')
|
||||||
if IsUnstableBuild() {
|
if IsUnstableBuild() {
|
||||||
fmt.Fprintf(&ret, " track: unstable (dev); frequent updates and bugs are likely\n")
|
fmt.Fprintf(&ret, " track: unstable (dev); frequent updates and bugs are likely\n")
|
||||||
}
|
}
|
||||||
if GitCommit != "" {
|
if gitCommit != "" {
|
||||||
var dirty string
|
var dirty string
|
||||||
if GitDirty {
|
if gitDirty {
|
||||||
dirty = "-dirty"
|
dirty = "-dirty"
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&ret, " tailscale commit: %s%s\n", GitCommit, dirty)
|
fmt.Fprintf(&ret, " tailscale commit: %s%s\n", gitCommit, dirty)
|
||||||
}
|
}
|
||||||
if ExtraGitCommit != "" {
|
if extraGitCommit != "" {
|
||||||
fmt.Fprintf(&ret, " other commit: %s\n", ExtraGitCommit)
|
fmt.Fprintf(&ret, " other commit: %s\n", extraGitCommit)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&ret, " go version: %s\n", runtime.Version())
|
fmt.Fprintf(&ret, " go version: %s\n", runtime.Version())
|
||||||
return strings.TrimSpace(ret.String())
|
return strings.TrimSpace(ret.String())
|
||||||
|
@ -110,7 +110,7 @@ func IsUnstableBuild() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initUnstable() {
|
func initUnstable() {
|
||||||
_, rest, ok := strings.Cut(Short, ".")
|
_, rest, ok := strings.Cut(short, ".")
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -187,12 +187,12 @@ type Meta struct {
|
|||||||
func GetMeta() Meta {
|
func GetMeta() Meta {
|
||||||
return Meta{
|
return Meta{
|
||||||
MajorMinorPatch: majorMinorPatch,
|
MajorMinorPatch: majorMinorPatch,
|
||||||
Short: Short,
|
Short: short,
|
||||||
Long: Long,
|
Long: long,
|
||||||
GitCommit: GitCommit,
|
GitCommit: gitCommit,
|
||||||
GitDirty: GitDirty,
|
GitDirty: gitDirty,
|
||||||
ExtraGitCommit: ExtraGitCommit,
|
ExtraGitCommit: extraGitCommit,
|
||||||
IsDev: strings.Contains(Short, "-dev"), // TODO(bradfitz): could make a bool for this in init
|
IsDev: strings.Contains(short, "-dev"), // TODO(bradfitz): could make a bool for this in init
|
||||||
UnstableBranch: IsUnstableBuild(),
|
UnstableBranch: IsUnstableBuild(),
|
||||||
Cap: int(tailcfg.CurrentCapabilityVersion),
|
Cap: int(tailcfg.CurrentCapabilityVersion),
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,10 @@ import (
|
|||||||
tailscaleroot "tailscale.com"
|
tailscaleroot "tailscale.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var long = ""
|
||||||
|
|
||||||
|
var short = ""
|
||||||
|
|
||||||
// Long is a full version number for this build, of the form
|
// Long is a full version number for this build, of the form
|
||||||
// "x.y.z-commithash" for builds stamped in the usual way (see
|
// "x.y.z-commithash" for builds stamped in the usual way (see
|
||||||
// build_dist.sh in the root) or, for binaries built by hand with the
|
// build_dist.sh in the root) or, for binaries built by hand with the
|
||||||
@ -18,23 +22,27 @@ import (
|
|||||||
// where "1.23.0" comes from ../VERSION.txt and the part after dev
|
// where "1.23.0" comes from ../VERSION.txt and the part after dev
|
||||||
// is YYYYMMDD of the commit time, and the part after -t is the commit
|
// is YYYYMMDD of the commit time, and the part after -t is the commit
|
||||||
// hash. The dirty suffix is whether there are uncommitted changes.
|
// hash. The dirty suffix is whether there are uncommitted changes.
|
||||||
var Long = ""
|
func Long() string {
|
||||||
|
return long
|
||||||
|
}
|
||||||
|
|
||||||
// Short is a short version number for this build, of the form
|
// Short is a short version number for this build, of the form
|
||||||
// "x.y.z" for builds stamped in the usual way (see
|
// "x.y.z" for builds stamped in the usual way (see
|
||||||
// build_dist.sh in the root) or, for binaries built by hand with the
|
// build_dist.sh in the root) or, for binaries built by hand with the
|
||||||
// go tool, it's like Long's dev form, but ending at the date part,
|
// go tool, it's like Long's dev form, but ending at the date part,
|
||||||
// of the form "1.23.0-dev20220316".
|
// of the form "1.23.0-dev20220316".
|
||||||
var Short = ""
|
func Short() string {
|
||||||
|
return short
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
defer func() {
|
defer func() {
|
||||||
// Must be run after Short has been initialized, easiest way to do that
|
// Must be run after Short has been initialized, easiest way to do that
|
||||||
// is a defer.
|
// is a defer.
|
||||||
majorMinorPatch, _, _ = strings.Cut(Short, "-")
|
majorMinorPatch, _, _ = strings.Cut(short, "-")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if Long != "" && Short != "" {
|
if long != "" && short != "" {
|
||||||
// Built in the recommended way, using build_dist.sh.
|
// Built in the recommended way, using build_dist.sh.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -43,8 +51,8 @@ func init() {
|
|||||||
// stamping.
|
// stamping.
|
||||||
bi, ok := debug.ReadBuildInfo()
|
bi, ok := debug.ReadBuildInfo()
|
||||||
if !ok {
|
if !ok {
|
||||||
Long = strings.TrimSpace(tailscaleroot.VersionDotTxt) + "-ERR-BuildInfo"
|
long = strings.TrimSpace(tailscaleroot.VersionDotTxt) + "-ERR-BuildInfo"
|
||||||
Short = Long
|
short = long
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var dirty string // "-dirty" suffix if dirty
|
var dirty string // "-dirty" suffix if dirty
|
||||||
@ -52,7 +60,7 @@ func init() {
|
|||||||
for _, s := range bi.Settings {
|
for _, s := range bi.Settings {
|
||||||
switch s.Key {
|
switch s.Key {
|
||||||
case "vcs.revision":
|
case "vcs.revision":
|
||||||
GitCommit = s.Value
|
gitCommit = s.Value
|
||||||
case "vcs.time":
|
case "vcs.time":
|
||||||
if len(s.Value) >= len("yyyy-mm-dd") {
|
if len(s.Value) >= len("yyyy-mm-dd") {
|
||||||
commitDate = s.Value[:len("yyyy-mm-dd")]
|
commitDate = s.Value[:len("yyyy-mm-dd")]
|
||||||
@ -61,30 +69,30 @@ func init() {
|
|||||||
case "vcs.modified":
|
case "vcs.modified":
|
||||||
if s.Value == "true" {
|
if s.Value == "true" {
|
||||||
dirty = "-dirty"
|
dirty = "-dirty"
|
||||||
GitDirty = true
|
gitDirty = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commitHashAbbrev := GitCommit
|
commitHashAbbrev := gitCommit
|
||||||
if len(commitHashAbbrev) >= 9 {
|
if len(commitHashAbbrev) >= 9 {
|
||||||
commitHashAbbrev = commitHashAbbrev[:9]
|
commitHashAbbrev = commitHashAbbrev[:9]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backup path, using Go 1.18's built-in git stamping.
|
// Backup path, using Go 1.18's built-in git stamping.
|
||||||
Short = strings.TrimSpace(tailscaleroot.VersionDotTxt) + "-dev" + commitDate
|
short = strings.TrimSpace(tailscaleroot.VersionDotTxt) + "-dev" + commitDate
|
||||||
Long = Short + "-t" + commitHashAbbrev + dirty
|
long = short + "-t" + commitHashAbbrev + dirty
|
||||||
}
|
}
|
||||||
|
|
||||||
// GitCommit, if non-empty, is the git commit of the
|
// GitCommit, if non-empty, is the git commit of the
|
||||||
// github.com/tailscale/tailscale repository at which Tailscale was
|
// github.com/tailscale/tailscale repository at which Tailscale was
|
||||||
// built. Its format is the one returned by `git describe --always
|
// built. Its format is the one returned by `git describe --always
|
||||||
// --exclude "*" --dirty --abbrev=200`.
|
// --exclude "*" --dirty --abbrev=200`.
|
||||||
var GitCommit = ""
|
var gitCommit = ""
|
||||||
|
|
||||||
// GitDirty is whether Go stamped the binary as having dirty version
|
// GitDirty is whether Go stamped the binary as having dirty version
|
||||||
// control changes in the working directory (debug.ReadBuildInfo
|
// control changes in the working directory (debug.ReadBuildInfo
|
||||||
// setting "vcs.modified" was true).
|
// setting "vcs.modified" was true).
|
||||||
var GitDirty bool
|
var gitDirty bool
|
||||||
|
|
||||||
// ExtraGitCommit, if non-empty, is the git commit of a "supplemental"
|
// ExtraGitCommit, if non-empty, is the git commit of a "supplemental"
|
||||||
// repository at which Tailscale was built. Its format is the same as
|
// repository at which Tailscale was built. Its format is the same as
|
||||||
@ -96,7 +104,7 @@ var GitDirty bool
|
|||||||
// Android OSS repository). Together, GitCommit and ExtraGitCommit
|
// Android OSS repository). Together, GitCommit and ExtraGitCommit
|
||||||
// exactly describe what repositories and commits were used in a
|
// exactly describe what repositories and commits were used in a
|
||||||
// build.
|
// build.
|
||||||
var ExtraGitCommit = ""
|
var extraGitCommit = ""
|
||||||
|
|
||||||
// majorMinorPatch is the major.minor.patch portion of Short.
|
// majorMinorPatch is the major.minor.patch portion of Short.
|
||||||
var majorMinorPatch string
|
var majorMinorPatch string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user