-
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
Update export_dashboards.go #7101
Conversation
Added support to include index-pattern in output JSON. Also added -quiet option to make it silent.
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
@@ -113,11 +113,16 @@ func ReadManifest(file string) ([]map[string]string, error) { | |||
return manifest.Dashboards, nil | |||
} | |||
|
|||
var indexPattern bool = false | |||
var quiet bool = false |
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.
should omit type bool from declaration of var quiet; it will be inferred from the right-hand side
@@ -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 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
@@ -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 { |
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.
@@ -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 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.
@@ -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 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)
}
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.
ok, point taken.
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.
made changes to indents, removed explicit =='s and removed explict bool
jenkins test this |
changes after review inputs
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.
Great! Thanks for the contribution. After the CIs turn green, it can be merged.
jenkins. test this, please |
Could you please add your change to |
Thanks. |
* Update export_dashboards.go Added support to include index-pattern in output JSON. Also added -quiet option to make it silent. * Update export_dashboards.go changes after review inputs * Update CHANGELOG.asciidoc
* Update export_dashboards.go Added support to include index-pattern in output JSON. Also added -quiet option to make it silent. * Update export_dashboards.go changes after review inputs * Update CHANGELOG.asciidoc
Added support to include index-pattern in output JSON. Also added -quiet option to make it silent.