cmd/printdep: add --next flag to use rc Go build hash instead
Updates tailscale/corp#36382 Change-Id: Ib7474b0aab901e98f0fe22761e26fd181650743c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
a374cc344e
commit
8f8236feb3
@@ -17,6 +17,9 @@ func init() {
|
|||||||
panic("binary built with tailscale_go build tag but failed to read build info or find tailscale.toolchain.rev in build info")
|
panic("binary built with tailscale_go build tag but failed to read build info or find tailscale.toolchain.rev in build info")
|
||||||
}
|
}
|
||||||
want := strings.TrimSpace(GoToolchainRev)
|
want := strings.TrimSpace(GoToolchainRev)
|
||||||
|
if os.Getenv("TS_GO_NEXT") == "1" {
|
||||||
|
want = strings.TrimSpace(GoToolchainNextRev)
|
||||||
|
}
|
||||||
if tsRev != want {
|
if tsRev != want {
|
||||||
if os.Getenv("TS_PERMIT_TOOLCHAIN_MISMATCH") == "1" {
|
if os.Getenv("TS_PERMIT_TOOLCHAIN_MISMATCH") == "1" {
|
||||||
fmt.Fprintf(os.Stderr, "tailscale.toolchain.rev = %q, want %q; but ignoring due to TS_PERMIT_TOOLCHAIN_MISMATCH=1\n", tsRev, want)
|
fmt.Fprintf(os.Stderr, "tailscale.toolchain.rev = %q, want %q; but ignoring due to TS_PERMIT_TOOLCHAIN_MISMATCH=1\n", tsRev, want)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var (
|
|||||||
goToolchain = flag.Bool("go", false, "print the supported Go toolchain git hash (a github.com/tailscale/go commit)")
|
goToolchain = flag.Bool("go", false, "print the supported Go toolchain git hash (a github.com/tailscale/go commit)")
|
||||||
goToolchainURL = flag.Bool("go-url", false, "print the URL to the tarball of the Tailscale Go toolchain")
|
goToolchainURL = flag.Bool("go-url", false, "print the URL to the tarball of the Tailscale Go toolchain")
|
||||||
alpine = flag.Bool("alpine", false, "print the tag of alpine docker image")
|
alpine = flag.Bool("alpine", false, "print the tag of alpine docker image")
|
||||||
|
next = flag.Bool("next", false, "if set, modifies --go or --go-url to use the upcoming/unreleased/rc Go release version instead")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -27,8 +28,12 @@ func main() {
|
|||||||
fmt.Println(strings.TrimSpace(ts.AlpineDockerTag))
|
fmt.Println(strings.TrimSpace(ts.AlpineDockerTag))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
goRev := strings.TrimSpace(ts.GoToolchainRev)
|
||||||
|
if *next {
|
||||||
|
goRev = strings.TrimSpace(ts.GoToolchainNextRev)
|
||||||
|
}
|
||||||
if *goToolchain {
|
if *goToolchain {
|
||||||
fmt.Println(strings.TrimSpace(ts.GoToolchainRev))
|
fmt.Println(goRev)
|
||||||
}
|
}
|
||||||
if *goToolchainURL {
|
if *goToolchainURL {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
@@ -36,6 +41,6 @@ func main() {
|
|||||||
default:
|
default:
|
||||||
log.Fatalf("unsupported GOOS %q", runtime.GOOS)
|
log.Fatalf("unsupported GOOS %q", runtime.GOOS)
|
||||||
}
|
}
|
||||||
fmt.Printf("https://github.com/tailscale/go/releases/download/build-%s/%s-%s.tar.gz\n", strings.TrimSpace(ts.GoToolchainRev), runtime.GOOS, runtime.GOARCH)
|
fmt.Printf("https://github.com/tailscale/go/releases/download/build-%s/%s-%s.tar.gz\n", goRev, runtime.GOOS, runtime.GOARCH)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ var AlpineDockerTag string
|
|||||||
//go:embed go.toolchain.rev
|
//go:embed go.toolchain.rev
|
||||||
var GoToolchainRev string
|
var GoToolchainRev string
|
||||||
|
|
||||||
|
// GoToolchainNextRev is like GoToolchainRev, but when using the
|
||||||
|
// "go.toolchain.next.rev" when TS_GO_NEXT=1 is set in the environment.
|
||||||
|
//
|
||||||
|
//go:embed go.toolchain.next.rev
|
||||||
|
var GoToolchainNextRev string
|
||||||
|
|
||||||
//lint:ignore U1000 used by tests + assert_ts_toolchain_match.go w/ right build tags
|
//lint:ignore U1000 used by tests + assert_ts_toolchain_match.go w/ right build tags
|
||||||
func tailscaleToolchainRev() (gitHash string, ok bool) {
|
func tailscaleToolchainRev() (gitHash string, ok bool) {
|
||||||
bi, ok := debug.ReadBuildInfo()
|
bi, ok := debug.ReadBuildInfo()
|
||||||
|
|||||||
Reference in New Issue
Block a user