Skip to content

Commit 667d6b2

Browse files
committed
add expiration seconds
1 parent fa3ec70 commit 667d6b2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11

22
dist/
3+
test.config

main.go

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func main() {
9393
defaultkubeconfig := homedir + "/.kube/config"
9494
kubeconfig := flag.String("kubeconfig", defaultkubeconfig, "Kubeconfig file")
9595
outputFile := flag.String("output-file", "", "File to output Kubeconfig to")
96+
expirationSeconds := flag.Int("expiration-seconds", 0, "Seconds till the certificate expires")
9697
flag.Parse()
9798
if *commonName == "" {
9899
fmt.Println("ERROR - Username is required")
@@ -144,6 +145,10 @@ func main() {
144145
Request: pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE REQUEST", Bytes: bytes}),
145146
},
146147
}
148+
var expire int32 = int32(*expirationSeconds)
149+
if expire != 0 {
150+
csr.Spec.ExpirationSeconds = &expire
151+
}
147152
_, err = clientset.CertificatesV1().CertificateSigningRequests().Create(context.TODO(), csr, v1.CreateOptions{})
148153
if err != nil {
149154
log.Fatal(fmt.Printf("Error %s", err))

0 commit comments

Comments
 (0)