@@ -107,7 +107,6 @@ import (
107107 "github.com/falcosecurity/plugin-sdk-go/pkg/sdk"
108108 "github.com/falcosecurity/plugin-sdk-go/pkg/sdk/plugins"
109109 "github.com/xeipuuv/gojsonschema"
110- "go.uber.org/multierr"
111110)
112111
113112// todo(jasondellaluce,therealbobo): the loader must support the new features of
@@ -136,6 +135,16 @@ type Plugin struct {
136135 capBrokenErr error
137136}
138137
138+ func errAppend (left , right error ) error {
139+ if left == nil {
140+ return right
141+ }
142+ if right == nil {
143+ return left
144+ }
145+ return fmt .Errorf ("%s, %s" , left .Error (), right .Error ())
146+ }
147+
139148// NewValidPlugin is the same as NewPlugin(), but returns an error if
140149// the loaded plugin is not valid. It is equivalent to invoking NewPlugin()
141150// and Plugin.Validate() in sequence.
@@ -211,14 +220,14 @@ func NewPlugin(path string) (*Plugin, error) {
211220 if err := json .Unmarshal (([]byte )(str ), & p .info .ExtractEventSources ); err != nil {
212221 p .caps &= ^ C .CAP_EXTRACTION
213222 p .caps |= C .CAP_BROKEN
214- p .capBrokenErr = multierr . Append (p .capBrokenErr , errors .New ("get_extract_event_sources does not return a well-formed json array" ))
223+ p .capBrokenErr = errAppend (p .capBrokenErr , errors .New ("get_extract_event_sources does not return a well-formed json array" ))
215224 }
216225 }
217226 str := C .GoString (C .__get_info_str (p .handle .api .anon1 .get_fields ))
218227 if err := json .Unmarshal (([]byte )(str ), & p .fields ); err != nil {
219228 p .caps &= ^ C .CAP_EXTRACTION
220229 p .caps |= C .CAP_BROKEN
221- p .capBrokenErr = multierr . Append (p .capBrokenErr , errors .New ("get_fields does not return a well-formed json array" ))
230+ p .capBrokenErr = errAppend (p .capBrokenErr , errors .New ("get_fields does not return a well-formed json array" ))
222231 }
223232
224233 }
@@ -251,7 +260,7 @@ func (p *Plugin) validate() error {
251260 }
252261 if (p .caps & ^ C .CAP_BROKEN ) == C .CAP_NONE {
253262 p .validErr = errors .New ("plugin supports no capability" )
254- return multierr . Append (p .validErr , p .capBrokenErr )
263+ return errAppend (p .validErr , p .capBrokenErr )
255264 }
256265 p .validated = true
257266 }
0 commit comments