Skip to content

Commit

Permalink
Fix migration log messages (#5907)
Browse files Browse the repository at this point in the history
Fix some log messages that included bare %q in the text (the log library doesn't support %q directly, that requires wrapping in a fmt.Sprintf).
  • Loading branch information
faec authored Nov 4, 2024
1 parent f891fb0 commit 3eedba2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/pkg/agent/migration/migrate_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func MigrateToEncryptedConfig(ctx context.Context, l *logp.Logger, unencryptedCo

unencStat, unencFileErr := os.Stat(unencryptedConfigPath)

l.Debugf("checking stat of enc config %q: %+v, err: %v", encryptedConfigPath, encStat, encFileErr)
l.Debugf("checking stat of unenc config %q: %+v, err: %v", unencryptedConfigPath, unencStat, unencFileErr)
l.Debugf(fmt.Sprintf("checking stat of enc config %q: %+v, err: %v", encryptedConfigPath, encStat, encFileErr))
l.Debugf(fmt.Sprintf("checking stat of unenc config %q: %+v, err: %v", unencryptedConfigPath, unencStat, unencFileErr))

isEncryptedConfigEmpty := errors.Is(encFileErr, fs.ErrNotExist) || encStat.Size() == 0
isUnencryptedConfigPresent := unencFileErr == nil && unencStat.Size() > 0
Expand All @@ -42,7 +42,7 @@ func MigrateToEncryptedConfig(ctx context.Context, l *logp.Logger, unencryptedCo
return nil
}

l.Info("Initiating migration of %q to %q", unencryptedConfigPath, encryptedConfigPath)
l.Info(fmt.Sprintf("Initiating migration of %q to %q", unencryptedConfigPath, encryptedConfigPath))
legacyStore, err := storage.NewDiskStore(unencryptedConfigPath)
if err != nil {
return fmt.Errorf("error instantiating disk store: %w", err)
Expand All @@ -54,7 +54,7 @@ func MigrateToEncryptedConfig(ctx context.Context, l *logp.Logger, unencryptedCo
defer func() {
err = reader.Close()
if err != nil {
l.Errorf("Error closing unencrypted store reader for %q: %v", unencryptedConfigPath, err)
l.Errorf(fmt.Sprintf("Error closing unencrypted store reader for %q: %v", unencryptedConfigPath, err))
}
}()
store, err := storage.NewEncryptedDiskStore(ctx, encryptedConfigPath, storageOpts...)
Expand All @@ -65,7 +65,7 @@ func MigrateToEncryptedConfig(ctx context.Context, l *logp.Logger, unencryptedCo
if err != nil {
return errors.New(err, fmt.Sprintf("error writing encrypted config from file %q to file %q", unencryptedConfigPath, encryptedConfigPath))
}
l.Info("Migration of %q to %q complete", unencryptedConfigPath, encryptedConfigPath)
l.Info(fmt.Sprintf("Migration of %q to %q complete", unencryptedConfigPath, encryptedConfigPath))

return nil
}

0 comments on commit 3eedba2

Please sign in to comment.