From 97927b9486d9599deb5939c26ce17bc8add9ead5 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 27 Sep 2018 15:55:47 +0200 Subject: [PATCH] Remove line carriages on asset generation (#8464) On Windows, asset files can contain line carriages, what leads to different encoded assets. Remove these carriages between encoding the string. --- CHANGELOG-developer.asciidoc | 1 + dev-tools/cmd/asset/asset.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-developer.asciidoc b/CHANGELOG-developer.asciidoc index 1a4774a20874..febefc956e53 100644 --- a/CHANGELOG-developer.asciidoc +++ b/CHANGELOG-developer.asciidoc @@ -35,6 +35,7 @@ The list below covers the major changes between 6.3.0 and master only. - Fix permissions of generated Filebeat filesets. {pull}7140[7140] - Collect fields from _meta/fields.yml too. {pull}8397[8397] +- Fix issue on asset generation that could lead to different results in Windows. {pull}8464[8464] ==== Added diff --git a/dev-tools/cmd/asset/asset.go b/dev-tools/cmd/asset/asset.go index b412df3f91c4..1941752d3ca7 100644 --- a/dev-tools/cmd/asset/asset.go +++ b/dev-tools/cmd/asset/asset.go @@ -27,6 +27,7 @@ import ( "go/format" "io/ioutil" "os" + "strings" "github.com/elastic/beats/libbeat/asset" "github.com/elastic/beats/licenses" @@ -79,7 +80,9 @@ func main() { } } - encData, err := asset.EncodeData(string(data)) + // Depending on OS or tools configuration, files can contain carriages (\r), + // what leads to different results, remove them before encoding. + encData, err := asset.EncodeData(strings.Replace(string(data), "\r", "", -1)) if err != nil { fmt.Fprintf(os.Stderr, "Error encoding the data: %s\n", err) os.Exit(1)