mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
sync code from copy destination
This commit is contained in:
parent
f9bb978ad6
commit
eedf638072
@ -152,13 +152,12 @@ func (t *TokenAuthenticator) AuthenticateToken(token string) (user.Info, bool, e
|
|||||||
|
|
||||||
// Copied from k8s.io/client-go/tools/bootstrap/token/api
|
// Copied from k8s.io/client-go/tools/bootstrap/token/api
|
||||||
func getSecretString(secret *api.Secret, key string) string {
|
func getSecretString(secret *api.Secret, key string) string {
|
||||||
if secret.Data == nil {
|
data, ok := secret.Data[key]
|
||||||
|
if !ok {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if val, ok := secret.Data[key]; ok {
|
|
||||||
return string(val)
|
return string(data)
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied from k8s.io/client-go/tools/bootstrap/token/api
|
// Copied from k8s.io/client-go/tools/bootstrap/token/api
|
||||||
@ -167,11 +166,13 @@ func isSecretExpired(secret *api.Secret) bool {
|
|||||||
if len(expiration) > 0 {
|
if len(expiration) > 0 {
|
||||||
expTime, err2 := time.Parse(time.RFC3339, expiration)
|
expTime, err2 := time.Parse(time.RFC3339, expiration)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
tokenErrorf(secret, "has unparsable expiration time (%s). Treating as expired.", expiration)
|
glog.V(3).Infof("Unparseable expiration time (%s) in %s/%s Secret: %v. Treating as expired.",
|
||||||
|
expiration, secret.Namespace, secret.Name, err2)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if time.Now().After(expTime) {
|
if time.Now().After(expTime) {
|
||||||
tokenErrorf(secret, "has expired.", expiration)
|
glog.V(3).Infof("Expired bootstrap token in %s/%s Secret: %v",
|
||||||
|
secret.Namespace, secret.Name, expiration)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,8 +182,10 @@ func isSecretExpired(secret *api.Secret) bool {
|
|||||||
// Copied from kubernetes/cmd/kubeadm/app/util/token
|
// Copied from kubernetes/cmd/kubeadm/app/util/token
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// tokenRegexpString defines id.secret regular expression pattern
|
||||||
tokenRegexpString = "^([a-z0-9]{6})\\.([a-z0-9]{16})$"
|
tokenRegexpString = "^([a-z0-9]{6})\\.([a-z0-9]{16})$"
|
||||||
tokenRegexp = regexp.MustCompile(tokenRegexpString)
|
// tokenRegexp is a compiled regular expression of TokenRegexpString
|
||||||
|
tokenRegexp = regexp.MustCompile(tokenRegexpString)
|
||||||
)
|
)
|
||||||
|
|
||||||
// parseToken tries and parse a valid token from a string.
|
// parseToken tries and parse a valid token from a string.
|
||||||
|
Loading…
Reference in New Issue
Block a user