@@ -9,14 +9,14 @@ import (
9
9
"net"
10
10
"os"
11
11
"path/filepath"
12
+ "time"
12
13
13
14
kapi "k8s.io/kubernetes/pkg/api"
14
15
kerrors "k8s.io/kubernetes/pkg/api/errors"
15
16
"k8s.io/kubernetes/pkg/api/unversioned"
16
17
"k8s.io/kubernetes/pkg/client/restclient"
17
18
kclientcmd "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
18
19
kclientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
19
- clientcmdutil "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/util"
20
20
"k8s.io/kubernetes/pkg/util/sets"
21
21
kterm "k8s.io/kubernetes/pkg/util/term"
22
22
@@ -66,8 +66,8 @@ type LoginOptions struct {
66
66
67
67
PathOptions * kclientcmd.PathOptions
68
68
69
- CommandName string
70
- Timeout string
69
+ CommandName string
70
+ RequestTimeout time. Duration
71
71
}
72
72
73
73
// Gather all required information in a comprehensive order.
@@ -101,6 +101,11 @@ func (o *LoginOptions) getClientConfig() (*restclient.Config, error) {
101
101
102
102
clientConfig := & restclient.Config {}
103
103
104
+ // ensure clientConfig has timeout option
105
+ if o .RequestTimeout > 0 {
106
+ clientConfig .Timeout = o .RequestTimeout
107
+ }
108
+
104
109
// normalize the provided server to a format expected by config
105
110
serverNormalized , err := config .NormalizeServerURL (o .Server )
106
111
if err != nil {
@@ -170,14 +175,6 @@ func (o *LoginOptions) gatherAuthInfo() error {
170
175
return err
171
176
}
172
177
173
- // ensure clientConfig has timeout option
174
- if len (o .Timeout ) > 0 {
175
- err := clientcmdutil .SetTimeout (o .Timeout , directClientConfig )
176
- if err != nil {
177
- return err
178
- }
179
- }
180
-
181
178
// make a copy and use it to avoid mutating the original
182
179
t := * directClientConfig
183
180
clientConfig := & t
0 commit comments