forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokens.go
50 lines (41 loc) · 1.25 KB
/
tokens.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
45
46
47
48
49
50
package tokens
import (
"io"
"os"
"path"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/golang/glog"
"github.com/spf13/cobra"
"github.com/openshift/origin/pkg/auth/server/tokenrequest"
"github.com/openshift/origin/pkg/cmd/server/origin"
osclientcmd "github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
const (
TokenRecommendedCommandName = "tokens"
TOKEN_FILE_PARAM = "token-file"
)
func NewCmdTokens(name, fullName string, f *osclientcmd.Factory, out io.Writer) *cobra.Command {
// Parent command to which all subcommands are added.
cmds := &cobra.Command{
Use: name,
Short: "Manage authentication tokens",
Long: `Manage authentication tokens`,
Run: func(c *cobra.Command, args []string) {
c.SetOutput(os.Stdout)
c.Help()
},
}
cmds.AddCommand(NewCmdValidateToken(f))
cmds.AddCommand(NewCmdRequestToken(f))
return cmds
}
func getFlagString(cmd *cobra.Command, flag string) string {
f := cmd.Flags().Lookup(flag)
if f == nil {
glog.Fatalf("Flag accessed but not defined for command %s: %s", cmd.Name(), flag)
}
return f.Value.String()
}
func getRequestTokenURL(clientCfg *client.Config) string {
return clientCfg.Host + path.Join(origin.OpenShiftOAuthAPIPrefix, tokenrequest.RequestTokenEndpoint)
}