Image copier: make sure ReportWriter is not nil before accessing

When running in Quiet mode, the ReportWriter can be nil causing a crash

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
This commit is contained in:
Ygal Blum 2023-12-04 14:32:14 +02:00
parent b89e527ab7
commit a525f15fc3
1 changed files with 7 additions and 5 deletions

View File

@ -364,11 +364,13 @@ func (c *copier) copy(ctx context.Context, source, destination types.ImageRefere
defer cancel()
defer timer.Stop()
fmt.Fprintf(c.imageCopyOptions.ReportWriter,
"Pulling image %s inside systemd: setting pull timeout to %s\n",
source.StringWithinTransport(),
time.Duration(numExtensions)*extension,
)
if c.imageCopyOptions.ReportWriter != nil {
fmt.Fprintf(c.imageCopyOptions.ReportWriter,
"Pulling image %s inside systemd: setting pull timeout to %s\n",
source.StringWithinTransport(),
time.Duration(numExtensions)*extension,
)
}
// From `man systemd.service(5)`:
//