Beispiel #1
0
func CmdExport(c *cli.Context) {
	export := api.ExportCreate()
	json, err := export.All(api.Create(c.String("uri")))

	if err != nil {
		fmt.Println(err.Error())
		return
	}

	var file string
	if file = c.String("file"); file == "" {
		fmt.Println(json)
		return
	}

	os.Remove(file)
	logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE, 0666)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	logFile.WriteString(json)
	fmt.Println("Export successful...")
}
Beispiel #2
0
func TestExportAll(t *testing.T) {
	export := api.ExportCreate()
	json, err := export.All(api.Create(api.DefaultKibanaUri))

	if err != nil {
		t.Error(err)
	}

	if len(json) <= 0 {
		t.Error("Expected a non-zero result")
	}
}