update ApiServer certificate expires check
Signed-off-by: Forest-L <lilin@yunify.com>
This commit is contained in:
parent
31b9cc63f4
commit
70167f6261
|
@ -1,15 +1,10 @@
|
||||||
name: CI
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ main ]
|
||||||
- 'master'
|
|
||||||
- 'release*'
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [ main ]
|
||||||
- 'master'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -58,18 +58,20 @@ func Cluster(configuration string, ctx context.Context, allInformation bool) err
|
||||||
output, _ := exec.Command("/bin/sh", "-c", cmd).CombinedOutput()
|
output, _ := exec.Command("/bin/sh", "-c", cmd).CombinedOutput()
|
||||||
if output != nil {
|
if output != nil {
|
||||||
certs, _ := certutil.ParseCertsPEM([]byte(output))
|
certs, _ := certutil.ParseCertsPEM([]byte(output))
|
||||||
certExpire := Certificate{
|
if len(certs) != 0 {
|
||||||
Name: "kube-apiserver",
|
certExpire := Certificate{
|
||||||
Expires: certs[0].NotAfter.Format("Jan 02, 2006 15:04 MST"),
|
Name: "kube-apiserver",
|
||||||
Residual: ResidualTime(certs[0].NotAfter),
|
Expires: certs[0].NotAfter.Format("Jan 02, 2006 15:04 MST"),
|
||||||
}
|
Residual: ResidualTime(certs[0].NotAfter),
|
||||||
if strings.Contains(certExpire.Residual, "d") {
|
}
|
||||||
tmpTime, _ := strconv.Atoi(strings.TrimRight(certExpire.Residual, "d"))
|
if strings.Contains(certExpire.Residual, "d") {
|
||||||
if tmpTime < 30 {
|
tmpTime, _ := strconv.Atoi(strings.TrimRight(certExpire.Residual, "d"))
|
||||||
|
if tmpTime < 30 {
|
||||||
|
certExpires = append(certExpires, certExpire)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
certExpires = append(certExpires, certExpire)
|
certExpires = append(certExpires, certExpire)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
certExpires = append(certExpires, certExpire)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue