From c3b2997563106e11d39f66eec629fde25dce2bdd Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Thu, 16 Nov 2023 21:25:01 -0800 Subject: [PATCH] [chore][checkapi] Do not enforce that all packages must have exactly one function (#28886) If no functions are exposed, exit with no error. This change allows to remove `extension/encoding` from the allowlist. --- cmd/checkapi/allowlist.txt | 1 - cmd/checkapi/main.go | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/checkapi/allowlist.txt b/cmd/checkapi/allowlist.txt index b791c2c59028..f63baf5214a7 100644 --- a/cmd/checkapi/allowlist.txt +++ b/cmd/checkapi/allowlist.txt @@ -1,5 +1,4 @@ connector/servicegraphconnector -extension/encoding extension/observer processor/servicegraphprocessor receiver/kafkareceiver diff --git a/cmd/checkapi/main.go b/cmd/checkapi/main.go index 609d1fd55991..50d2bff18a71 100644 --- a/cmd/checkapi/main.go +++ b/cmd/checkapi/main.go @@ -172,12 +172,13 @@ func walkFolder(folder string, componentType string) error { return nil } + if len(result.Functions) == 0 { + return nil + } if len(result.Functions) > 1 { return fmt.Errorf("%s has more than one function: %q", folder, strings.Join(fnNames, ",")) } - if len(result.Functions) == 0 { - return fmt.Errorf("%s has no functions defined", folder) - } + newFactoryFn := result.Functions[0] if newFactoryFn.Name != "NewFactory" { return fmt.Errorf("%s does not define a NewFactory function", folder)