Skip to content

Commit 4198f28

Browse files
committed
BoundServiceAccountTokenVolume: fix InClusterConfig
1 parent 23fb942 commit 4198f28

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

staging/src/k8s.io/apiserver/pkg/util/webhook/authentication.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func restConfigFromKubeconfig(configAuthInfo *clientcmdapi.AuthInfo) (*rest.Conf
171171
// blindly overwrite existing values based on precedence
172172
if len(configAuthInfo.Token) > 0 {
173173
config.BearerToken = configAuthInfo.Token
174+
config.BearerTokenFile = configAuthInfo.TokenFile
174175
} else if len(configAuthInfo.TokenFile) > 0 {
175176
tokenBytes, err := ioutil.ReadFile(configAuthInfo.TokenFile)
176177
if err != nil {

staging/src/k8s.io/client-go/rest/transport.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ func (c *Config) TransportConfig() (*transport.Config, error) {
7474
KeyFile: c.KeyFile,
7575
KeyData: c.KeyData,
7676
},
77-
Username: c.Username,
78-
Password: c.Password,
79-
BearerToken: c.BearerToken,
77+
Username: c.Username,
78+
Password: c.Password,
79+
BearerToken: c.BearerToken,
80+
BearerTokenFile: c.BearerTokenFile,
8081
Impersonate: transport.ImpersonationConfig{
8182
UserName: c.Impersonate.UserName,
8283
Groups: c.Impersonate.Groups,

staging/src/k8s.io/client-go/tools/clientcmd/client_config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthI
228228
// blindly overwrite existing values based on precedence
229229
if len(configAuthInfo.Token) > 0 {
230230
mergedConfig.BearerToken = configAuthInfo.Token
231+
mergedConfig.BearerTokenFile = configAuthInfo.TokenFile
231232
} else if len(configAuthInfo.TokenFile) > 0 {
232233
tokenBytes, err := ioutil.ReadFile(configAuthInfo.TokenFile)
233234
if err != nil {
@@ -491,6 +492,7 @@ func (config *inClusterClientConfig) ClientConfig() (*restclient.Config, error)
491492
}
492493
if token := config.overrides.AuthInfo.Token; len(token) > 0 {
493494
icc.BearerToken = token
495+
icc.BearerTokenFile = ""
494496
}
495497
if certificateAuthorityFile := config.overrides.ClusterInfo.CertificateAuthority; len(certificateAuthorityFile) > 0 {
496498
icc.TLSClientConfig.CAFile = certificateAuthorityFile

0 commit comments

Comments
 (0)