Skip to content

Commit

Permalink
Create directories automatically in export_dashboards (elastic#6031)
Browse files Browse the repository at this point in the history
When called with the `-yml` option, the `dev-tools/export_dashboards.go`
program now creates the tree structure for you (i.e. `_meta/kibana/6/dashboard`).
It used to exit with an error if the directory didn't yet exist, which caused
a small annoyance when creating a FB module.
  • Loading branch information
tsg authored and exekias committed Jan 10, 2018
1 parent 49f6a19 commit 586ae32
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dev-tools/cmd/dashboards/export_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ func main() {

for _, dashboard := range dashboards {
fmt.Printf("id=%s, name=%s\n", dashboard["id"], dashboard["file"])
err := Export(client, *kibanaURL, dashboard["id"], path.Join(path.Dir(*ymlFile),
"_meta/kibana/6/dashboard", dashboard["file"]))
directory := path.Join(path.Dir(*ymlFile), "_meta/kibana/6/dashboard")
err := os.MkdirAll(directory, 0755)
if err != nil {
fmt.Printf("ERROR: fail to create directory %s: %v", directory, err)
}
err = Export(client, *kibanaURL, dashboard["id"], path.Join(directory, dashboard["file"]))
if err != nil {
fmt.Printf("ERROR: fail to export the dashboards: %s\n", err)
}
Expand Down

0 comments on commit 586ae32

Please sign in to comment.