~bigbes/ci-cacher

ref: d041811523ea4e4dc5aeb636ab3c252c19a3b5b8 ci-cacher/cmd/util.go -rw-r--r-- 416 bytes
d0418115 — Eugene Blikh cacher: add 'docker download --pull' and silence cobra usage on errors a day ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package cmd

import (
	"fmt"
	"io"
	"os"
)

// newWarnWriter forwards everything written to it to stderr, prefixed
// with a tag. Used to surface docker subcommand stderr in CI logs.
func newWarnWriter(tag string) io.Writer {
	return &warnWriter{tag: tag}
}

type warnWriter struct{ tag string }

func (w *warnWriter) Write(p []byte) (int, error) {
	fmt.Fprintf(os.Stderr, "[%s] %s", w.tag, p)
	return len(p), nil
}