-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
result = append(result, obj) | ||
} | ||
} | ||
|
@@ -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) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add new lines after
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) | ||
|
||
|
@@ -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) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here with the newlines.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, point taken. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
} | ||
|
||
|
@@ -113,11 +113,16 @@ func ReadManifest(file string) ([]map[string]string, error) { | |
return manifest.Dashboards, nil | ||
} | ||
|
||
var indexPattern bool = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
||
|
There was a problem hiding this comment.
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
?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.