mirror of
https://github.com/tailscale/tailscale.git
synced 2025-07-10 15:48:43 +00:00
cmd/tailscale/cli: update tailscale down to accept an optional --reason
If specified, the reason is sent via the LocalAPI for auditing purposes. Updates tailscale/corp#26146 Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
parent
496347c724
commit
17ca2b7721
@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/peterbourgon/ff/v3/ffcli"
|
||||
"tailscale.com/client/tailscale/apitype"
|
||||
"tailscale.com/ipn"
|
||||
)
|
||||
|
||||
@ -23,10 +24,12 @@ var downCmd = &ffcli.Command{
|
||||
|
||||
var downArgs struct {
|
||||
acceptedRisks string
|
||||
reason string
|
||||
}
|
||||
|
||||
func newDownFlagSet() *flag.FlagSet {
|
||||
downf := newFlagSet("down")
|
||||
downf.StringVar(&downArgs.reason, "reason", "", "reason for the disconnect, if required by a policy")
|
||||
registerAcceptRiskFlag(downf, &downArgs.acceptedRisks)
|
||||
return downf
|
||||
}
|
||||
@ -50,6 +53,7 @@ func runDown(ctx context.Context, args []string) error {
|
||||
fmt.Fprintf(Stderr, "Tailscale was already stopped.\n")
|
||||
return nil
|
||||
}
|
||||
ctx = apitype.RequestReasonKey.WithValue(ctx, downArgs.reason)
|
||||
_, err = localClient.EditPrefs(ctx, &ipn.MaskedPrefs{
|
||||
Prefs: ipn.Prefs{
|
||||
WantRunning: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user