-
-
Notifications
You must be signed in to change notification settings - Fork 517
/
cmds_auth.go
40 lines (34 loc) · 912 Bytes
/
cmds_auth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cli
import (
"github.com/spf13/cobra"
"github.com/telepresenceio/telepresence/v2/pkg/client/cli/cliutil"
)
func LoginCommand() *cobra.Command {
var args struct {
apikey string
}
cmd := &cobra.Command{
Use: "login",
Args: cobra.NoArgs,
Short: "Authenticate to Ambassador Cloud",
Long: "Authenticate to Ambassador Cloud",
RunE: func(cmd *cobra.Command, _ []string) error {
_, err := cliutil.EnsureLoggedIn(cmd.Context(), args.apikey)
return err
},
}
cmd.Flags().StringVar(&args.apikey, "apikey", "",
"Static API key to use instead of performing an interactive login")
return cmd
}
func LogoutCommand() *cobra.Command {
return &cobra.Command{
Use: "logout",
Args: cobra.NoArgs,
Short: "Logout from Ambassador Cloud",
Long: "Logout from Ambassador Cloud",
RunE: func(cmd *cobra.Command, _ []string) error {
return cliutil.Logout(cmd.Context())
},
}
}