treewide: fix %v in cases where we should use %w
We should always use %w when using fmt.Errorf as you can use error.Is to
compare the underlying error. When printing an error the use of %w is
wrong and should be replaced with %v.
Change-Id: I741111bd91dcee4099144d2ecaffa879fdbb34a2
Reviewed-on: https://review.monogon.dev/c/monogon/+/2993
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/cli/metroctl/cmd_install_ssh.go b/metropolis/cli/metroctl/cmd_install_ssh.go
index 15ced4a..56bab4c 100644
--- a/metropolis/cli/metroctl/cmd_install_ssh.go
+++ b/metropolis/cli/metroctl/cmd_install_ssh.go
@@ -147,13 +147,13 @@
ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
conn, err := cl.Dial(ctx, address, 5*time.Second)
if err != nil {
- return fmt.Errorf("error while establishing ssh connection: %v", err)
+ return fmt.Errorf("error while establishing ssh connection: %w", err)
}
params := makeNodeParams()
rawParams, err := proto.Marshal(params)
if err != nil {
- return fmt.Errorf("error while marshaling node params: %v", err)
+ return fmt.Errorf("error while marshaling node params: %w", err)
}
const takeoverTargetPath = "/root/takeover"
@@ -188,7 +188,7 @@
log.Printf("Agent stderr: %q", stderrStr)
}
if err != nil {
- return fmt.Errorf("while starting the takeover executable: %v", err)
+ return fmt.Errorf("while starting the takeover executable: %w", err)
}
return nil
diff --git a/metropolis/cli/metroctl/cmd_node_metrics.go b/metropolis/cli/metroctl/cmd_node_metrics.go
index f94f020..f3bde46 100644
--- a/metropolis/cli/metroctl/cmd_node_metrics.go
+++ b/metropolis/cli/metroctl/cmd_node_metrics.go
@@ -68,7 +68,7 @@
}
res, err := client.Get(fmt.Sprintf("https://%s/metrics/%s", net.JoinHostPort(n.Status.ExternalAddress, common.MetricsPort.PortString()), args[1]))
if err != nil {
- return fmt.Errorf("metrics HTTP request failed: %v", err)
+ return fmt.Errorf("metrics HTTP request failed: %w", err)
}
defer res.Body.Close()
_, err = io.Copy(os.Stdout, res.Body)