Browse code

Make base filename configurable for create-api-client-config

Jordan Liggitt authored on 2015/06/16 06:47:50
Showing 1 changed files
... ...
@@ -20,6 +20,7 @@ type CreateClientOptions struct {
20 20
 	GetSignerCertOptions *GetSignerCertOptions
21 21
 
22 22
 	ClientDir string
23
+	BaseName  string
23 24
 
24 25
 	User   string
25 26
 	Groups util.StringList
... ...
@@ -61,6 +62,7 @@ func NewCommandCreateClient(commandName string, fullName string, out io.Writer)
61 61
 	BindGetSignerCertOptions(options.GetSignerCertOptions, flags, "")
62 62
 
63 63
 	flags.StringVar(&options.ClientDir, "client-dir", "", "The client data directory.")
64
+	flags.StringVar(&options.BaseName, "basename", "", "The base filename to use for the .crt, .key, and .kubeconfig files. Defaults to the username.")
64 65
 
65 66
 	flags.StringVar(&options.User, "user", "", "The scope qualified username.")
66 67
 	flags.Var(&options.Groups, "groups", "The list of groups this user belongs to. Comma delimited list")
... ...
@@ -102,10 +104,14 @@ func (o CreateClientOptions) Validate(args []string) error {
102 102
 func (o CreateClientOptions) CreateClientFolder() error {
103 103
 	glog.V(4).Infof("creating a .kubeconfig with: %#v", o)
104 104
 
105
-	clientCertFile := DefaultCertFilename(o.ClientDir, o.User)
106
-	clientKeyFile := DefaultKeyFilename(o.ClientDir, o.User)
105
+	baseName := o.BaseName
106
+	if len(baseName) == 0 {
107
+		baseName = o.User
108
+	}
109
+	clientCertFile := DefaultCertFilename(o.ClientDir, baseName)
110
+	clientKeyFile := DefaultKeyFilename(o.ClientDir, baseName)
107 111
 	clientCopyOfCAFile := DefaultCAFilename(o.ClientDir, "ca")
108
-	kubeConfigFile := DefaultKubeConfigFilename(o.ClientDir, o.User)
112
+	kubeConfigFile := DefaultKubeConfigFilename(o.ClientDir, baseName)
109 113
 
110 114
 	createClientCertOptions := CreateClientCertOptions{
111 115
 		GetSignerCertOptions: o.GetSignerCertOptions,