~bigbes/ci-cacher

ref: e1b71b2fe9f2df0fd94378351a68d97a01879922 ci-cacher/cmd/util.go -rw-r--r-- 416 bytes
e1b71b2f — Eugene Blikh test.yml: build cacher from source, cache go.mod, use 'docker download --pull' 2 days 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
}