Skip to content

Commit a268b1d

Browse files
committed
Remove last remaining nested NewRegistry call
1 parent 9a1ce2a commit a268b1d

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

973976
var (

0 commit comments

Comments
 (0)