mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
add copyreport utility
useful for codec and report structure experiments
This commit is contained in:
19
extras/copyreport/Makefile
Normal file
19
extras/copyreport/Makefile
Normal 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
26
extras/copyreport/main.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user