Fix missing newlines in stderr error messages

I happened to run `podman run --config=/path/to/file` and got
an error without a trailing newline, which was a bit jarring.

Fix the instances I noticed.

Assisted-by: OpenCode (Claude Opus 4.5)
Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
Colin Walters
2025-12-16 11:16:46 -05:00
parent 23306d1efe
commit 9a2c8b615e
5 changed files with 8 additions and 7 deletions

View File

@@ -42,7 +42,7 @@ func init() {
func storeBefore() error {
defaultStoreOptions, err := storage.DefaultStoreOptions()
if err != nil {
fmt.Fprintf(os.Stderr, "selecting storage options: %v", err)
fmt.Fprintf(os.Stderr, "selecting storage options: %v\n", err)
return nil
}
globalStorageOptions = defaultStoreOptions

View File

@@ -443,16 +443,16 @@ func configHook() {
if err != nil && !errors.Is(err, fs.ErrNotExist) {
// Cases where the folder does not exist are allowed, BUT cases where some other Stat() error
// is returned should fail
fmt.Fprintf(os.Stderr, "Supplied --config folder (%s) exists but is not accessible: %s", dockerConfig, err.Error())
fmt.Fprintf(os.Stderr, "Supplied --config folder (%s) exists but is not accessible: %s\n", dockerConfig, err.Error())
os.Exit(1)
}
if err == nil && !statInfo.IsDir() {
// Cases where it does exist but is a file should fail
fmt.Fprintf(os.Stderr, "Supplied --config file (%s) is not a directory", dockerConfig)
fmt.Fprintf(os.Stderr, "Supplied --config file (%s) is not a directory\n", dockerConfig)
os.Exit(1)
}
if err := os.Setenv("DOCKER_CONFIG", dockerConfig); err != nil {
fmt.Fprintf(os.Stderr, "cannot set DOCKER_CONFIG=%s: %s", dockerConfig, err.Error())
fmt.Fprintf(os.Stderr, "cannot set DOCKER_CONFIG=%s: %s\n", dockerConfig, err.Error())
os.Exit(1)
}
}

View File

@@ -15,6 +15,6 @@ func syslogHook() {
return
}
fmt.Fprintf(os.Stderr, "Logging to Syslog is not supported on %s", runtime.GOOS)
fmt.Fprintf(os.Stderr, "Logging to Syslog is not supported on %s\n", runtime.GOOS)
os.Exit(1)
}

View File

@@ -351,7 +351,7 @@ func (f *Farm) Build(ctx context.Context, schedule Schedule, options entities.Bu
buildResults.Range(func(_, v any) bool {
result, ok := v.(buildResult)
if !ok {
fmt.Fprintf(os.Stderr, "report %v not a build result?", v)
fmt.Fprintf(os.Stderr, "report %v not a build result?\n", v)
return false
}
perArchBuilds[result.report] = result.builder

View File

@@ -101,7 +101,8 @@ var _ = Describe("Podman run", func() {
tempFileName := tempFile.Name()
session := podmanTest.Podman([]string{"--config", tempFileName, "run", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitWithError(1, fmt.Sprintf(`Supplied --config file (%s) is not a directory`, tempFileName)))
// Note: ErrorToString() uses strings.Fields() which normalizes whitespace, so we're not testing the trailing newline
Expect(session).Should(ExitWithError(1, fmt.Sprintf("Supplied --config file (%s) is not a directory", tempFileName)))
})
It("podman run from manifest list", func() {