cmd/tailscale/cli: allow effective GOOS to be changed for integration tests
Adds TS_DEBUG_UP_FLAG_GOOS for integration tests to make "tailscale up" act like other OSes. For an upcoming change to test #2137. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/2460/head
parent
787939a60c
commit
87244eda3f
|
@ -51,7 +51,14 @@ flag is also used.
|
||||||
Exec: runUp,
|
Exec: runUp,
|
||||||
}
|
}
|
||||||
|
|
||||||
var upFlagSet = newUpFlagSet(runtime.GOOS, &upArgs)
|
func effectiveGOOS() string {
|
||||||
|
if v := os.Getenv("TS_DEBUG_UP_FLAG_GOOS"); v != "" {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return runtime.GOOS
|
||||||
|
}
|
||||||
|
|
||||||
|
var upFlagSet = newUpFlagSet(effectiveGOOS(), &upArgs)
|
||||||
|
|
||||||
func newUpFlagSet(goos string, upArgs *upArgsT) *flag.FlagSet {
|
func newUpFlagSet(goos string, upArgs *upArgsT) *flag.FlagSet {
|
||||||
upf := flag.NewFlagSet("up", flag.ExitOnError)
|
upf := flag.NewFlagSet("up", flag.ExitOnError)
|
||||||
|
@ -327,7 +334,7 @@ func runUp(ctx context.Context, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs, err := prefsFromUpArgs(upArgs, warnf, st, runtime.GOOS)
|
prefs, err := prefsFromUpArgs(upArgs, warnf, st, effectiveGOOS())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("%s", err)
|
fatalf("%s", err)
|
||||||
}
|
}
|
||||||
|
@ -344,7 +351,7 @@ func runUp(ctx context.Context, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
env := upCheckEnv{
|
env := upCheckEnv{
|
||||||
goos: runtime.GOOS,
|
goos: effectiveGOOS(),
|
||||||
user: os.Getenv("USER"),
|
user: os.Getenv("USER"),
|
||||||
flagSet: upFlagSet,
|
flagSet: upFlagSet,
|
||||||
upArgs: upArgs,
|
upArgs: upArgs,
|
||||||
|
@ -384,7 +391,7 @@ func runUp(ctx context.Context, args []string) error {
|
||||||
if n.ErrMessage != nil {
|
if n.ErrMessage != nil {
|
||||||
msg := *n.ErrMessage
|
msg := *n.ErrMessage
|
||||||
if msg == ipn.ErrMsgPermissionDenied {
|
if msg == ipn.ErrMsgPermissionDenied {
|
||||||
switch runtime.GOOS {
|
switch effectiveGOOS() {
|
||||||
case "windows":
|
case "windows":
|
||||||
msg += " (Tailscale service in use by other user?)"
|
msg += " (Tailscale service in use by other user?)"
|
||||||
default:
|
default:
|
||||||
|
@ -458,7 +465,7 @@ func runUp(ctx context.Context, args []string) error {
|
||||||
// Windows service (~tailscaled) is the one that computes the
|
// Windows service (~tailscaled) is the one that computes the
|
||||||
// StateKey based on the connection identity. So for now, just
|
// StateKey based on the connection identity. So for now, just
|
||||||
// do as the Windows GUI's always done:
|
// do as the Windows GUI's always done:
|
||||||
if runtime.GOOS == "windows" {
|
if effectiveGOOS() == "windows" {
|
||||||
// The Windows service will set this as needed based
|
// The Windows service will set this as needed based
|
||||||
// on our connection's identity.
|
// on our connection's identity.
|
||||||
opts.StateKey = ""
|
opts.StateKey = ""
|
||||||
|
|
Loading…
Reference in New Issue