Add ability for fixprobe to send the report from test/fixture

This commit is contained in:
Tom Wilkie
2016-04-22 10:24:30 +01:00
parent 22e8418e7a
commit 087be057f2

View File

@@ -13,6 +13,7 @@ import (
"github.com/weaveworks/scope/common/xfer"
"github.com/weaveworks/scope/probe/appclient"
"github.com/weaveworks/scope/report"
"github.com/weaveworks/scope/test/fixture"
)
func main() {
@@ -21,22 +22,27 @@ func main() {
publishInterval = flag.Duration("publish.interval", 1*time.Second, "publish (output) interval")
publishToken = flag.String("publish.token", "fixprobe", "publish token, for if we are talking to the service")
publishID = flag.String("publish.id", "fixprobe", "publisher ID used to identify publishers")
useFixture = flag.Bool("fixture", false, "Use the embedded fixture report.")
)
flag.Parse()
if len(flag.Args()) != 1 {
if len(flag.Args()) != 1 && !*useFixture {
log.Fatal("usage: fixprobe [--args] report.json")
}
b, err := ioutil.ReadFile(flag.Arg(0))
if err != nil {
log.Fatal(err)
}
var fixedReport report.Report
decoder := codec.NewDecoderBytes(b, &codec.JsonHandle{})
if err := decoder.Decode(&fixedReport); err != nil {
log.Fatal(err)
if *useFixture {
fixedReport = fixture.Report
} else {
b, err := ioutil.ReadFile(flag.Arg(0))
if err != nil {
log.Fatal(err)
}
decoder := codec.NewDecoderBytes(b, &codec.JsonHandle{})
if err := decoder.Decode(&fixedReport); err != nil {
log.Fatal(err)
}
}
client, err := appclient.NewAppClient(appclient.ProbeConfig{