Skip to content

Commit f90262d

Browse files
committed
fix: do not wrap nil provisioners
1 parent c2c7dc4 commit f90262d

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

authority/authority.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -968,16 +968,20 @@ func (a *Authority) startCRLGenerator() error {
968968
func (a *Authority) incrProvisionerCounter(prov *provisioner.Interface, err *error, count func(Meter, string, bool)) {
969969
var name string
970970
if p := *prov; p != nil {
971-
// TODO(@azazeal): ???
971+
name = p.GetName()
972972

973-
switch x := p.(type) {
974-
case *wrappedProvisioner:
975-
if x.Interface != nil {
973+
/*
974+
// TODO(@azazeal): ???
975+
976+
switch x := p.(type) {
977+
case *wrappedProvisioner:
978+
if x.Interface != nil {
979+
name = x.GetName()
980+
}
981+
default:
976982
name = x.GetName()
977983
}
978-
default:
979-
name = x.GetName()
980-
}
984+
*/
981985
}
982986

983987
count(a.meter, name, *err == nil)
@@ -986,16 +990,20 @@ func (a *Authority) incrProvisionerCounter(prov *provisioner.Interface, err *err
986990
func (a *Authority) incrWebhookCounter(prov provisioner.Interface, err error, count func(Meter, string, bool)) {
987991
var name string
988992
if prov != nil {
989-
// TODO(@azazeal): ???
993+
name = prov.GetName()
990994

991-
switch x := prov.(type) {
992-
case *wrappedProvisioner:
993-
if x.Interface != nil {
995+
/*
996+
// TODO(@azazeal): ???
997+
998+
switch x := prov.(type) {
999+
case *wrappedProvisioner:
1000+
if x.Interface != nil {
1001+
name = x.GetName()
1002+
}
1003+
default:
9941004
name = x.GetName()
9951005
}
996-
default:
997-
name = x.GetName()
998-
}
1006+
*/
9991007
}
10001008

10011009
count(a.meter, name, err == nil)

authority/tls.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,10 @@ func (a *Authority) Sign(csr *x509.CertificateRequest, signOpts provisioner.Sign
310310

311311
cert = append([]*x509.Certificate{resp.Certificate}, resp.CertificateChain...)
312312

313-
// Wrap provisioner with extra information.
314-
prov = wrapProvisioner(prov, attData)
313+
// Wrap provisioner with extra information, if not nil
314+
if prov != nil {
315+
prov = wrapProvisioner(prov, attData)
316+
}
315317

316318
// Store certificate in the db.
317319
if err = a.storeCertificate(prov, cert); err != nil {

0 commit comments

Comments
 (0)