Skip to content

Commit

Permalink
[Ingest Manager] Use shorter hash for application differentiator (ela…
Browse files Browse the repository at this point in the history
…stic#18770)

[Ingest Manager] Use shorter hash for application differentiator (elastic#18770)
  • Loading branch information
michalpristas authored May 27, 2020
1 parent 80130af commit 0b17200
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@
- Use nested objects so fleet can handle metadata correctly {pull}18234[18234]
- More clear output of inspect command {pull}18405[18405]
- Pick up version from libbeat {pull}18350[18350]
- Use shorter hash for application differentiator {pull}18770[18770]
7 changes: 7 additions & 0 deletions x-pack/elastic-agent/pkg/core/plugin/app/execution_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"fmt"
)

const (
hashLen = 16
)

// ExecutionContext describes runnable binary
type ExecutionContext struct {
BinaryName string
Expand All @@ -22,6 +26,9 @@ func NewExecutionContext(binaryName, version string, tags map[Tag]string) Execut
id := fmt.Sprintf("%s--%s", binaryName, version)
if len(tags) > 0 {
hash := fmt.Sprintf("%x", sha256.New().Sum([]byte(fmt.Sprint(tags))))
if len(hash) > hashLen {
hash = hash[:hashLen]
}
id += fmt.Sprintf("--%x", hash)
}

Expand Down

0 comments on commit 0b17200

Please sign in to comment.