forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streaming_writer.go
39 lines (28 loc) · 966 Bytes
/
streaming_writer.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
package ssh
import (
"fmt"
"io"
boshui "github.com/cloudfoundry/bosh-cli/ui"
)
type StreamingWriter struct {
comboWriter *boshui.ComboWriter
}
func NewStreamingWriter(comboWriter *boshui.ComboWriter) *StreamingWriter {
return &StreamingWriter{comboWriter: comboWriter}
}
func (w StreamingWriter) ForInstance(jobName, indexOrID string) InstanceWriter {
return streamingInstanceWriter{jobName: jobName, indexOrID: indexOrID, comboWriter: w.comboWriter}
}
func (w StreamingWriter) Flush() {}
type streamingInstanceWriter struct {
jobName string
indexOrID string
comboWriter *boshui.ComboWriter
}
func (w streamingInstanceWriter) Stdout() io.Writer {
return w.comboWriter.Writer(fmt.Sprintf("%s/%s: stdout | ", w.jobName, w.indexOrID))
}
func (w streamingInstanceWriter) Stderr() io.Writer {
return w.comboWriter.Writer(fmt.Sprintf("%s/%s: stderr | ", w.jobName, w.indexOrID))
}
func (w streamingInstanceWriter) End(exitStatus int, err error) {}