secrets: more verbose errors

This commit is contained in:
Mikaël Cluseau 2023-01-27 06:13:05 +01:00
parent 4ff85eaeb3
commit 153c37b591

View File

@ -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
}