Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update export_dashboards.go #7101

Merged
merged 4 commits into from
May 16, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions dev-tools/cmd/dashboards/export_dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func ExtractIndexPattern(body []byte) ([]byte, error) {
if !ok {
return nil, fmt.Errorf("type key not found or not string")
}
if _type != "index-pattern" {
if _type != "index-pattern" || indexPattern == true {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not write || indexPattern instead of || indexPattern == true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, works too. IMHO I like to be explicit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked other parts of the code. Although, I find it weird, other parts of the code does include bool checking using == true, so I am ok with letting this go.

result = append(result, obj)
}
}
Expand All @@ -68,7 +68,7 @@ func Export(client *http.Client, conn string, dashboard string, out string) erro
params.Add("dashboard", dashboard)

fullURL := makeURL(conn, exportAPI, params)
fmt.Printf("Calling HTTP GET %v\n", fullURL)
if ! quiet { fmt.Printf("Calling HTTP GET %v\n", fullURL) }
Copy link
Contributor

@kvch kvch May 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add new lines after { and fullURL)? Please also remove the space between ! and quiet.

if !quiet {
    fmt.Printf("Calling HTTP GET %v\n", fullURL)
}

Most of the codebase does not use this format. So in order to keep the uniformity of the code, please change it.


req, err := http.NewRequest("GET", fullURL, nil)

Expand All @@ -95,7 +95,7 @@ func Export(client *http.Client, conn string, dashboard string, out string) erro

err = ioutil.WriteFile(out, body, 0666)

fmt.Printf("The dashboard %s was exported under the %s file\n", dashboard, out)
if ! quiet { fmt.Printf("The dashboard %s was exported under the %s file\n", dashboard, out) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with the newlines.

if !quiet {
    fmt.Printf("The dashboard %s was exported under the %s file\n", dashboard, out)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, point taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made changes to indents, removed explicit =='s and removed explict bool

return err
}

Expand All @@ -113,11 +113,16 @@ func ReadManifest(file string) ([]map[string]string, error) {
return manifest.Dashboards, nil
}

var indexPattern bool = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should omit type bool from declaration of var indexPattern; it will be inferred from the right-hand side

var quiet bool = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should omit type bool from declaration of var quiet; it will be inferred from the right-hand side


func main() {
kibanaURL := flag.String("kibana", "http://localhost:5601", "Kibana URL")
dashboard := flag.String("dashboard", "", "Dashboard ID")
fileOutput := flag.String("output", "output.json", "Output file")
ymlFile := flag.String("yml", "", "Path to the module.yml file containing the dashboards")
flag.BoolVar(&indexPattern, "indexPattern", false, "include index-pattern in output")
flag.BoolVar(&quiet, "quiet", false, "be quiet")

flag.Parse()

Expand Down