Skip to content

Commit

Permalink
bugfix: only set signer name when not nil in order to preventing panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch committed Jun 9, 2022
1 parent 8df9c26 commit 8e7ab32
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/controller/certificates/csrapprover.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,18 +359,24 @@ func v1Csr2v1beta1Csr(csr *certificatesv1.CertificateSigningRequest) *certificat
}

func v1beta1Csr2v1Csr(csr *certificatesv1beta1.CertificateSigningRequest) *certificatesv1.CertificateSigningRequest {
if csr == nil {
return nil
}
v1Csr := &certificatesv1.CertificateSigningRequest{
ObjectMeta: csr.ObjectMeta,
Spec: certificatesv1.CertificateSigningRequestSpec{
Request: csr.Spec.Request,
SignerName: *csr.Spec.SignerName,
Usages: make([]certificatesv1.KeyUsage, 0),
Request: csr.Spec.Request,
Usages: make([]certificatesv1.KeyUsage, 0),
},
Status: certificatesv1.CertificateSigningRequestStatus{
Conditions: make([]certificatesv1.CertificateSigningRequestCondition, 0),
},
}

if csr.Spec.SignerName != nil {
v1Csr.Spec.SignerName = *csr.Spec.SignerName
}

for _, usage := range csr.Spec.Usages {
v1Csr.Spec.Usages = append(v1Csr.Spec.Usages, certificatesv1.KeyUsage(usage))
}
Expand Down

0 comments on commit 8e7ab32

Please sign in to comment.