cmd/tailscale/cli: [serve] add reset flag
Usage: `tailscale serve reset` Fixes #8139 Signed-off-by: Sonia Appasamy <sonia@tailscale.com>pull/7493/merge
parent
4664318be2
commit
f0ee03dfaf
|
@ -40,6 +40,7 @@ serve https:<port> <mount-point> <source> [off]
|
||||||
serve tcp:<port> tcp://localhost:<local-port> [off]
|
serve tcp:<port> tcp://localhost:<local-port> [off]
|
||||||
serve tls-terminated-tcp:<port> tcp://localhost:<local-port> [off]
|
serve tls-terminated-tcp:<port> tcp://localhost:<local-port> [off]
|
||||||
serve status [--json]
|
serve status [--json]
|
||||||
|
serve reset
|
||||||
`),
|
`),
|
||||||
LongHelp: strings.TrimSpace(`
|
LongHelp: strings.TrimSpace(`
|
||||||
*** BETA; all of this is subject to change ***
|
*** BETA; all of this is subject to change ***
|
||||||
|
@ -87,6 +88,13 @@ EXAMPLES
|
||||||
}),
|
}),
|
||||||
UsageFunc: usageFunc,
|
UsageFunc: usageFunc,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "reset",
|
||||||
|
Exec: e.runServeReset,
|
||||||
|
ShortHelp: "reset current serve/funnel config",
|
||||||
|
FlagSet: e.newFlags("serve-reset", nil),
|
||||||
|
UsageFunc: usageFunc,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,3 +713,15 @@ func elipticallyTruncate(s string, max int) string {
|
||||||
}
|
}
|
||||||
return s[:max-3] + "..."
|
return s[:max-3] + "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runServeReset clears out the current serve config.
|
||||||
|
//
|
||||||
|
// Usage:
|
||||||
|
// - tailscale serve reset
|
||||||
|
func (e *serveEnv) runServeReset(ctx context.Context, args []string) error {
|
||||||
|
if len(args) != 0 {
|
||||||
|
return flag.ErrHelp
|
||||||
|
}
|
||||||
|
sc := new(ipn.ServeConfig)
|
||||||
|
return e.lc.SetServeConfig(ctx, sc)
|
||||||
|
}
|
||||||
|
|
|
@ -224,7 +224,10 @@ func TestServeConfigMutations(t *testing.T) {
|
||||||
command: cmd("https:443 bar https://127.0.0.1:8443"),
|
command: cmd("https:443 bar https://127.0.0.1:8443"),
|
||||||
want: nil, // nothing to save
|
want: nil, // nothing to save
|
||||||
})
|
})
|
||||||
add(step{reset: true})
|
add(step{ // try resetting using reset command
|
||||||
|
command: cmd("reset"),
|
||||||
|
want: &ipn.ServeConfig{},
|
||||||
|
})
|
||||||
add(step{
|
add(step{
|
||||||
command: cmd("https:443 / https+insecure://127.0.0.1:3001"),
|
command: cmd("https:443 / https+insecure://127.0.0.1:3001"),
|
||||||
want: &ipn.ServeConfig{
|
want: &ipn.ServeConfig{
|
||||||
|
|
Loading…
Reference in New Issue