Skip to content

Commit 303f18f

Browse files
mergify[bot]faec
andauthored
Remove last remaining NewRegistry method call (#18154) (#18181)
(cherry picked from commit 013ef6f) Co-authored-by: Fae Charlton <[email protected]>
1 parent 3eb521d commit 303f18f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/beater/beater.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,12 @@ func queryClusterUUID(ctx context.Context, esClient *elasticsearch.Client, state
956956
// Running under elastic-agent, the callback linked above is not
957957
// registered until later, meaning we need to check and instantiate the
958958
// registries if they don't exist.
959-
elasticsearchRegistry := stateRegistry.GetRegistry(outputES)
959+
elasticsearchRegistry := stateRegistry.GetOrCreateRegistry(outputES)
960960
if elasticsearchRegistry == nil {
961-
elasticsearchRegistry = stateRegistry.NewRegistry(outputES)
961+
// This can only happen if "outputs.elasticsearch" was already created as
962+
// a non-registry (scalar) value, but in that unlikely chance, let's still
963+
// report a comprehensible error.
964+
return fmt.Errorf("couldn't create registry: %v", outputES)
962965
}
963966

964967
var (

0 commit comments

Comments
 (0)