mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #56568 from zouyee/sync
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. sync code from copy destination **What this PR does / why we need it**: sync code from copy destination **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: **Special notes for your reviewer**: **Release note**: ``` NONE ```
This commit is contained in:
commit
2716de27b1
@ -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,7 +182,9 @@ 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 is a compiled regular expression of TokenRegexpString
|
||||||
tokenRegexp = regexp.MustCompile(tokenRegexpString)
|
tokenRegexp = regexp.MustCompile(tokenRegexpString)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user