From df1b765368a23d8fabe51a4515bd83000f4b4970 Mon Sep 17 00:00:00 2001 From: Stephen Levine Date: Tue, 26 Nov 2024 17:27:41 -0500 Subject: [PATCH] feedback --- lib/autoupdate/agent/config.go | 9 +++++---- lib/autoupdate/agent/updater.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/autoupdate/agent/config.go b/lib/autoupdate/agent/config.go index ff48d9fc0dc8a..7bfdfcee3e0e2 100644 --- a/lib/autoupdate/agent/config.go +++ b/lib/autoupdate/agent/config.go @@ -88,7 +88,8 @@ type Revision struct { } // NewRevision create a Revision. -// A revision with no version must not have flags. +// If version is not set, no flags are returned. +// This ensures that all Revisions without versions are zero-valued. func NewRevision(version string, flags InstallFlags) Revision { if version != "" { return Revision{ @@ -104,11 +105,11 @@ func NewRevisionFromDir(dir string) (Revision, error) { parts := strings.Split(dir, "_") var out Revision if len(parts) == 0 { - return out, fmt.Errorf("dir name empty") + return out, trace.Errorf("dir name empty") } out.Version = parts[0] if out.Version == "" { - return out, fmt.Errorf("version missing in dir %q", dir) + return out, trace.Errorf("version missing in dir %s", dir) } switch flags := parts[1:]; len(flags) { case 2: @@ -126,7 +127,7 @@ func NewRevisionFromDir(dir string) (Revision, error) { case 0: return out, nil } - return out, fmt.Errorf("invalid flag in %q", dir) + return out, trace.Errorf("invalid flag in %s", dir) } // Dir returns the directory path name of a Revision. diff --git a/lib/autoupdate/agent/updater.go b/lib/autoupdate/agent/updater.go index 06fc5383229c0..a84e376bafe81 100644 --- a/lib/autoupdate/agent/updater.go +++ b/lib/autoupdate/agent/updater.go @@ -700,7 +700,7 @@ func (u *Updater) update(ctx context.Context, cfg *UpdateConfig, target Revision if ok := revertConfig(ctx); ok { u.Log.WarnContext(ctx, "Teleport updater encountered a configuration error and successfully reverted the installation.") } - return trace.Errorf("failed to validate configuration for new version %q of Teleport: %w", target, err) + return trace.Errorf("failed to validate configuration for new version %s of Teleport: %w", target, err) } // Restart Teleport if necessary.