Skip to content

Commit cee8722

Browse files
authored
Add default version set to minimum support version for tcld (#246)
1 parent d446ede commit cee8722

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

app/version.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ import (
88
"time"
99

1010
"github.com/urfave/cli/v2"
11+
"golang.org/x/mod/semver"
1112
)
1213

1314
const (
15+
// MinSupportedVersion is the minimum tcld version supported by our APIs.
16+
// This string must be updated when we deprecate older versions, but should be
17+
// done carefully as this will likely break user's current usage of tcld.
18+
MinSupportedVersion = "v0.1.3"
19+
20+
// DefaultVersionString is the version which is sent over if no version was available.
21+
// This can happen if a user builds the latest main branch, as the version string provided
22+
// to us from Go tooling is `(devel)`
23+
DefaultVersionString = MinSupportedVersion + "-no-version-available"
24+
1425
pseudoVersionMinLen = len("vX.0.0-yyyymmddhhmmss-abcdefabcdef")
1526
pseudoVersionCommitInfoLen = len("yyyymmddhhmmss-abcdefabcdef")
1627
)
@@ -62,6 +73,10 @@ func NewBuildInfo() BuildInfo {
6273
info := BuildInfo{
6374
Version: di.Main.Version,
6475
}
76+
if !semver.IsValid(di.Main.Version) {
77+
info.Version = DefaultVersionString
78+
}
79+
6580
if len(di.Main.Version) >= pseudoVersionMinLen {
6681
// Used when compiled with `go install`.
6782
// See https://go.dev/ref/mod#pseudo-versions for more info on the expected string format

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/urfave/cli/v2 v2.25.3
1414
go.uber.org/fx v1.19.2
1515
go.uber.org/multierr v1.6.0
16-
golang.org/x/mod v0.8.0
16+
golang.org/x/mod v0.12.0
1717
google.golang.org/grpc v1.54.0
1818
)
1919

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
6969
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
7070
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
7171
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
72+
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
73+
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
7274
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
7375
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
7476
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=

0 commit comments

Comments
 (0)