treewide: cleanup error string formatting
Change-Id: I9012ba58dded916984468219b214200144a439b9
Reviewed-on: https://review.monogon.dev/c/monogon/+/3023
Reviewed-by: Serge Bazanski <serge@monogon.tech>
Vouch-Run-CI: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/cloud/agent/agent.go b/cloud/agent/agent.go
index 2805f42..8efafd0 100644
--- a/cloud/agent/agent.go
+++ b/cloud/agent/agent.go
@@ -58,7 +58,7 @@
}
agentInitRaw, err := os.ReadFile("/init.pb")
if err != nil {
- return fmt.Errorf("Unable to read spec file from takeover: %w", err)
+ return fmt.Errorf("unable to read spec file from takeover: %w", err)
}
var agentInit apb.AgentInit
diff --git a/cloud/agent/install.go b/cloud/agent/install.go
index f209ce3..5b0c209 100644
--- a/cloud/agent/install.go
+++ b/cloud/agent/install.go
@@ -52,6 +52,7 @@
func installMetropolis(req *bpb.MetropolisInstallationRequest, netConfig *npb.Net, l logtree.LeveledLogger, isEFIBoot bool) error {
if !isEFIBoot {
+ //nolint:ST1005
return errors.New("Monogon OS can only be installed on EFI-booted machines, this one is not")
}
diff --git a/cloud/shepherd/manager/initializer.go b/cloud/shepherd/manager/initializer.go
index 2c04c43..a380a8f 100644
--- a/cloud/shepherd/manager/initializer.go
+++ b/cloud/shepherd/manager/initializer.go
@@ -263,10 +263,10 @@
return nil, fmt.Errorf("agent returned unknown result of type %T", arsp.Result)
}
if !proto.Equal(&imsg, successResp.InitMessage) {
- return nil, fmt.Errorf("agent did not send back the init message.")
+ return nil, fmt.Errorf("agent did not send back the init message")
}
if len(successResp.Key) != ed25519.PublicKeySize {
- return nil, fmt.Errorf("agent key length mismatch.")
+ return nil, fmt.Errorf("agent key length mismatch")
}
klog.Infof("Started the agent (machine ID: %s, key: %s).", mid, hex.EncodeToString(successResp.Key))
return successResp.Key, nil
diff --git a/metropolis/cli/metroctl/core/install.go b/metropolis/cli/metroctl/core/install.go
index 31b7328..223e773 100644
--- a/metropolis/cli/metroctl/core/install.go
+++ b/metropolis/cli/metroctl/core/install.go
@@ -34,7 +34,7 @@
// with a bundle and/or Node Parameters.
func MakeInstallerImage(args MakeInstallerImageArgs) error {
if args.Installer == nil {
- return errors.New("Installer is mandatory")
+ return errors.New("installer is mandatory")
}
espRoot := fat32.Inode{Attrs: fat32.AttrDirectory}
diff --git a/metropolis/node/build/mkverity/mkverity.go b/metropolis/node/build/mkverity/mkverity.go
index 7300f49..f44b601 100644
--- a/metropolis/node/build/mkverity/mkverity.go
+++ b/metropolis/node/build/mkverity/mkverity.go
@@ -58,7 +58,7 @@
return nil, fmt.Errorf("the data image must be a regular file")
}
if ds.Size()%int64(bs) != 0 {
- return nil, fmt.Errorf("the data image must end on a %d-byte block boundary.", bs)
+ return nil, fmt.Errorf("the data image must end on a %d-byte block boundary", bs)
}
// Create an empty hash image file.
diff --git a/metropolis/node/core/cluster/cluster_join.go b/metropolis/node/core/cluster/cluster_join.go
index 53ca815..cdbf0b3 100644
--- a/metropolis/node/core/cluster/cluster_join.go
+++ b/metropolis/node/core/cluster/cluster_join.go
@@ -28,7 +28,7 @@
// Get Cluster CA from Sealed Configuration.
ca, err := x509.ParseCertificate(sc.ClusterCa)
if err != nil {
- return fmt.Errorf("Cluster CA certificate present in Sealed Configuration could not be parsed: %w", err)
+ return fmt.Errorf("cluster CA certificate present in Sealed Configuration could not be parsed: %w", err)
}
// Tell the user what we're doing.
diff --git a/metropolis/node/core/metrics/metrics.go b/metropolis/node/core/metrics/metrics.go
index ffae970..bd229fa 100644
--- a/metropolis/node/core/metrics/metrics.go
+++ b/metropolis/node/core/metrics/metrics.go
@@ -140,5 +140,5 @@
if err != nil && ctx.Err() != nil {
return ctx.Err()
}
- return fmt.Errorf("Serve: %w", err)
+ return fmt.Errorf("Serve(): %w", err)
}
diff --git a/metropolis/node/core/network/static.go b/metropolis/node/core/network/static.go
index 6c72be5..abe9aca 100644
--- a/metropolis/node/core/network/static.go
+++ b/metropolis/node/core/network/static.go
@@ -44,7 +44,7 @@
return err
}
if loopbackLink == nil {
- return errors.New("No loopback interface present, weird/broken kernel?")
+ return errors.New("no loopback interface present, weird/broken kernel?")
}
if err := netlink.LinkSetUp(loopbackLink); err != nil {
l.Error("Failed to enable loopback interface: %w", err)
diff --git a/metropolis/node/core/roleserve/worker_heartbeat.go b/metropolis/node/core/roleserve/worker_heartbeat.go
index c11c5d0..6ba07c5 100644
--- a/metropolis/node/core/roleserve/worker_heartbeat.go
+++ b/metropolis/node/core/roleserve/worker_heartbeat.go
@@ -49,7 +49,7 @@
_, err := stream.Recv()
if err == io.EOF {
- return fmt.Errorf("stream closed by the server. Restarting worker...")
+ return fmt.Errorf("stream closed by the server, restarting worker... ")
}
if err != nil {
return fmt.Errorf("while receiving a heartbeat reply: %v", err)
diff --git a/metropolis/pkg/fat32/fat32.go b/metropolis/pkg/fat32/fat32.go
index 5d26694..7a45aa4 100644
--- a/metropolis/pkg/fat32/fat32.go
+++ b/metropolis/pkg/fat32/fat32.go
@@ -431,7 +431,7 @@
allocClusters := len(p.fat)
if allocClusters >= fatMask&math.MaxUint32 {
- return fmt.Errorf("filesystem contains more than 2^28 FAT entries, this is unsupported. Note that this package currently always creates minimal clusters.")
+ return fmt.Errorf("filesystem contains more than 2^28 FAT entries, this is unsupported. Note that this package currently always creates minimal clusters")
}
// Fill out FAT to minimum size for FAT32
diff --git a/metropolis/pkg/verity/encoder.go b/metropolis/pkg/verity/encoder.go
index 871cec0..b28e01d 100644
--- a/metropolis/pkg/verity/encoder.go
+++ b/metropolis/pkg/verity/encoder.go
@@ -532,9 +532,9 @@
func (e *encoder) MappingTable(dataDevicePath, hashDevicePath string, hashStart int64) (*MappingTable, error) {
if e.rootHash == nil {
if e.bottom.Len() != 0 {
- return nil, fmt.Errorf("encoder wasn't closed.")
+ return nil, fmt.Errorf("encoder wasn't closed")
}
- return nil, fmt.Errorf("encoder is empty.")
+ return nil, fmt.Errorf("encoder is empty")
}
if e.writeSb {
diff --git a/metropolis/test/launch/cluster/cluster.go b/metropolis/test/launch/cluster/cluster.go
index ca9becd..32c351f 100644
--- a/metropolis/test/launch/cluster/cluster.go
+++ b/metropolis/test/launch/cluster/cluster.go
@@ -495,7 +495,7 @@
}
return n, nil
}
- return nil, fmt.Errorf("no such node.")
+ return nil, fmt.Errorf("no such node")
}
// Gets a random EUI-48 Ethernet MAC address
diff --git a/third_party/sandboxroot/mirror/external.go b/third_party/sandboxroot/mirror/external.go
index 2c8bcdf..7596843 100644
--- a/third_party/sandboxroot/mirror/external.go
+++ b/third_party/sandboxroot/mirror/external.go
@@ -186,10 +186,10 @@
log.Printf(" Uploading to %s...", objName)
wr := obj.NewWriter(ctx)
if _, err := wr.Write(data); err != nil {
- return fmt.Errorf("Write failed: %w", err)
+ return fmt.Errorf("Write() failed: %w", err)
}
if err := wr.Close(); err != nil {
- return fmt.Errorf("Close failed: %w", err)
+ return fmt.Errorf("Close() failed: %w", err)
}
return nil
}