Skip to content

Commit 25e76b0

Browse files
mergify[bot]faec
andauthored
Remove last remaining NewRegistry method call (#18154) (#18182)
(cherry picked from commit 013ef6f) Co-authored-by: Fae Charlton <fae.charlton@elastic.co>
1 parent 75ec134 commit 25e76b0

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
@@ -966,9 +966,12 @@ func queryClusterUUID(ctx context.Context, esClient *elasticsearch.Client, state
966966
// Running under elastic-agent, the callback linked above is not
967967
// registered until later, meaning we need to check and instantiate the
968968
// registries if they don't exist.
969-
elasticsearchRegistry := stateRegistry.GetRegistry(outputES)
969+
elasticsearchRegistry := stateRegistry.GetOrCreateRegistry(outputES)
970970
if elasticsearchRegistry == nil {
971-
elasticsearchRegistry = stateRegistry.NewRegistry(outputES)
971+
// This can only happen if "outputs.elasticsearch" was already created as
972+
// a non-registry (scalar) value, but in that unlikely chance, let's still
973+
// report a comprehensible error.
974+
return fmt.Errorf("couldn't create registry: %v", outputES)
972975
}
973976

974977
var (

0 commit comments

Comments
 (0)