forked from tsuru/tsuru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.go
44 lines (38 loc) · 950 Bytes
/
token.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
41
42
43
44
// Copyright 2014 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"github.com/tsuru/config"
"github.com/tsuru/tsuru/app"
"github.com/tsuru/tsuru/auth"
_ "github.com/tsuru/tsuru/auth/native"
_ "github.com/tsuru/tsuru/auth/oauth"
"github.com/tsuru/tsuru/cmd"
)
type tokenCmd struct{}
func (tokenCmd) Run(context *cmd.Context, client *cmd.Client) error {
scheme, err := config.GetString("auth:scheme")
if err != nil {
scheme = "native"
}
app.AuthScheme, err = auth.GetScheme(scheme)
if err != nil {
return err
}
t, err := app.AuthScheme.AppLogin(app.InternalAppName)
if err != nil {
return err
}
fmt.Fprintf(context.Stdout, t.GetValue())
return nil
}
func (tokenCmd) Info() *cmd.Info {
return &cmd.Info{
Name: "token",
Usage: "token",
Desc: "Generates a tsuru token.",
MinArgs: 0,
}
}