Skip to content

Commit

Permalink
bugfix: only set signer name when not nil in order to preventing pani…
Browse files Browse the repository at this point in the history
…c. (#975)

(cherry picked from commit 8e7ab32)

Co-authored-by: rambohe-ch <[email protected]>
  • Loading branch information
github-actions[bot] and rambohe-ch authored Aug 30, 2022
1 parent 65ead46 commit 33fd649
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 @@ -358,18 +358,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 33fd649

Please sign in to comment.