forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noop_reporters.go
47 lines (37 loc) · 1.13 KB
/
noop_reporters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package director
import (
"github.com/cloudfoundry/bosh-cli/ui"
"io"
)
type NoopFileReporter struct{}
type NoopReadSeekCloser struct {
Reader io.ReadCloser
}
func (nrsc NoopReadSeekCloser) Close() error {
return nrsc.Reader.Close()
}
func (nrsc NoopReadSeekCloser) Read(p []byte) (n int, err error) {
return nrsc.Reader.Read(p)
}
func (nrsc NoopReadSeekCloser) Seek(offset int64, whence int) (int64, error) {
switch reader := nrsc.Reader.(type) {
case io.Seeker:
return reader.Seek(offset, whence)
default:
return 0, nil
}
}
func NewNoopFileReporter() NoopFileReporter {
return NoopFileReporter{}
}
func (r NoopFileReporter) TrackUpload(size int64, reader io.ReadCloser) ui.ReadSeekCloser {
return NoopReadSeekCloser{reader}
}
func (r NoopFileReporter) TrackDownload(size int64, writer io.Writer) io.Writer { return writer }
type NoopTaskReporter struct{}
func NewNoopTaskReporter() NoopTaskReporter {
return NoopTaskReporter{}
}
func (r NoopTaskReporter) TaskStarted(id int) {}
func (r NoopTaskReporter) TaskFinished(id int, state string) {}
func (r NoopTaskReporter) TaskOutputChunk(id int, chunk []byte) {}