mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-22 16:46:53 +01:00
caddypki: Minor tweak, don't use context pointer
This commit is contained in:
parent
ecac03cdcb
commit
a1c41210d3
3 changed files with 5 additions and 9 deletions
|
@ -102,7 +102,7 @@ func (ash *Handler) Provision(ctx caddy.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pkiApp := appModule.(*caddypki.PKI)
|
pkiApp := appModule.(*caddypki.PKI)
|
||||||
ca, err := pkiApp.GetCA(ash.CA, &ctx)
|
ca, err := pkiApp.GetCA(ctx, ash.CA)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,9 +121,8 @@ func (p *PKI) Stop() error {
|
||||||
|
|
||||||
// GetCA retrieves a CA by ID. If the ID is the default
|
// GetCA retrieves a CA by ID. If the ID is the default
|
||||||
// CA ID, and it hasn't been provisioned yet, it will
|
// CA ID, and it hasn't been provisioned yet, it will
|
||||||
// be provisioned. The context must be passed if this
|
// be provisioned.
|
||||||
// is called from a module's Provision().
|
func (p *PKI) GetCA(ctx caddy.Context, id string) (*CA, error) {
|
||||||
func (p *PKI) GetCA(id string, ctx *caddy.Context) (*CA, error) {
|
|
||||||
ca, ok := p.CAs[id]
|
ca, ok := p.CAs[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
// for anything other than the default CA ID, error out if it wasn't configured
|
// for anything other than the default CA ID, error out if it wasn't configured
|
||||||
|
@ -132,10 +131,7 @@ func (p *PKI) GetCA(id string, ctx *caddy.Context) (*CA, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for the default CA ID, provision it, because we want it to "just work"
|
// for the default CA ID, provision it, because we want it to "just work"
|
||||||
if ctx == nil {
|
err := p.ProvisionDefaultCA(ctx)
|
||||||
return nil, fmt.Errorf("cannot provision default CA without the context")
|
|
||||||
}
|
|
||||||
err := p.ProvisionDefaultCA(*ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to provision default CA: %s", err)
|
return nil, fmt.Errorf("failed to provision default CA: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (iss *InternalIssuer) Provision(ctx caddy.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pkiApp := appModule.(*caddypki.PKI)
|
pkiApp := appModule.(*caddypki.PKI)
|
||||||
ca, err := pkiApp.GetCA(iss.CA, &ctx)
|
ca, err := pkiApp.GetCA(ctx, iss.CA)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue