-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fleet-server to elastic-agent inspect output (#243)
* Add fleet-server to elastic-agent inspect output Add the fleet-server input from the full filled config that is parsed for programs in elastic-agent inspect output. This will show the policy for fleet-server instead of the contents of fleet.yml * Add unit test * fix linter
- Loading branch information
1 parent
0696c10
commit 05d4ad7
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGetFleetInput(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input map[string]interface{} | ||
expect map[string]interface{} | ||
}{{ | ||
name: "fleet-server input found", | ||
input: map[string]interface{}{ | ||
"inputs": []map[string]interface{}{ | ||
map[string]interface{}{ | ||
"type": "fleet-server", | ||
}}, | ||
}, | ||
expect: map[string]interface{}{ | ||
"type": "fleet-server", | ||
}, | ||
}, { | ||
name: "no fleet-server input", | ||
input: map[string]interface{}{ | ||
"inputs": []map[string]interface{}{ | ||
map[string]interface{}{ | ||
"type": "test-server", | ||
}}, | ||
}, | ||
expect: nil, | ||
}, { | ||
name: "wrong input formant", | ||
input: map[string]interface{}{ | ||
"inputs": "example", | ||
}, | ||
expect: nil, | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
r := getFleetInput(tt.input) | ||
if tt.expect == nil && r != nil { | ||
t.Error("expected nil") | ||
} | ||
}) | ||
} | ||
} |