From 153c37b591fd260162be21895883b6657645d6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Fri, 27 Jan 2023 06:13:05 +0100 Subject: [PATCH] secrets: more verbose errors --- cmd/dkl-local-server/secrets.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/dkl-local-server/secrets.go b/cmd/dkl-local-server/secrets.go index f8afcef..490ea5e 100644 --- a/cmd/dkl-local-server/secrets.go +++ b/cmd/dkl-local-server/secrets.go @@ -248,6 +248,13 @@ func (sd *SecretData) RenewCACert(cluster, name string) (err error) { } func (sd *SecretData) CA(cluster, name string) (ca *CA, err error) { + + defer func() { + if err != nil { + err = fmt.Errorf("cluster %s CA %s: %w", cluster, name, err) + } + }() + cs := sd.cluster(cluster) ca, ok := cs.CAs[name] @@ -257,6 +264,9 @@ func (sd *SecretData) CA(cluster, name string) (ca *CA, err error) { log.Infof("secret-data cluster %s: CA %s: regenerating certificate: %v", cluster, name, checkErr) err = sd.RenewCACert(cluster, name) + if err != nil { + err = fmt.Errorf("renew: %w", err) + } } return @@ -283,6 +293,7 @@ func (sd *SecretData) CA(cluster, name string) (ca *CA, err error) { cert, _, key, err := initca.New(req) if err != nil { + err = fmt.Errorf("initca: %w", err) return }