[lxc-devel] [lxd/master] Decode error

SimonRichardson on Github lxc-bot at linuxcontainers.org
Thu Jul 9 21:06:14 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 650 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200709/d558437e/attachment.bin>
-------------- next part --------------
From 03e52a3772fce056ef2cd7d98649c67a79d4237c Mon Sep 17 00:00:00 2001
From: Simon Richardson <stickupkid at gmail.com>
Date: Thu, 9 Jul 2020 22:01:24 +0100
Subject: [PATCH] Decode error

When attempting invoke setup trust, if the passed in cert fails to
decode there isn't any error to return and will just return nil.

Considering this will always be nil, then the error message will never
be displayed. Change to always return the error and will work as
expected.

Signed-off-by: Simon Richardson simon.richardson at canonical.com
---
 lxd/cluster/connect.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/cluster/connect.go b/lxd/cluster/connect.go
index 8fdb8a8390..b6ca6995fb 100644
--- a/lxd/cluster/connect.go
+++ b/lxd/cluster/connect.go
@@ -143,7 +143,7 @@ func SetupTrust(cert, targetAddress, targetCert, targetPassword string) error {
 
 	block, _ := pem.Decode([]byte(cert))
 	if block == nil {
-		return errors.Wrap(err, "failed to decode certificate")
+		return errors.Errorf("failed to decode certificate")
 	}
 
 	certificate := base64.StdEncoding.EncodeToString(block.Bytes)


More information about the lxc-devel mailing list