add copyreport utility

useful for codec and report structure experiments
This commit is contained in:
Matthias Radestock
2017-05-26 14:57:26 +01:00
parent eb8695965a
commit fa0f4a4d59
3 changed files with 102 additions and 16 deletions

View File

@@ -0,0 +1,19 @@
.PHONY: all vet lint build test clean
all: build test vet lint
vet:
go vet ./...
lint:
golint .
build:
go build
test:
go test
clean:
go clean

26
extras/copyreport/main.go Normal file
View File

@@ -0,0 +1,26 @@
// Copy a report, decoding and re-encoding it.
package main
import (
"compress/gzip"
"flag"
"log"
"github.com/weaveworks/scope/report"
)
func main() {
flag.Parse()
if len(flag.Args()) != 2 {
log.Fatal("usage: copyreport src.(json|msgpack)[.gz] dst.(json|msgpack)[.gz]")
}
rpt, err := report.MakeFromFile(flag.Arg(0))
if err != nil {
log.Fatal(err)
}
if err = rpt.WriteToFile(flag.Arg(1), gzip.DefaultCompression); err != nil {
log.Fatal(err)
}
}