@@ -190,8 +190,18 @@ func parseAPIPackages(dir string) ([]*types.Package, error) {
190
190
}
191
191
var pkgNames []string
192
192
for p := range scan {
193
- klog .V (3 ).Infof ("trying package=%v groupName=%s" , p , groupName (scan [p ]))
194
- if groupName (scan [p ]) != "" && len (scan [p ].Types ) > 0 {
193
+ pkg := scan [p ]
194
+ klog .V (3 ).Infof ("trying package=%v groupName=%s" , p , groupName (pkg ))
195
+
196
+ // Do not pick up packages that are in vendor/ as API packages. (This
197
+ // happened in knative/eventing-sources/vendor/..., where a package
198
+ // matched the pattern, but it didn't have a compatible import path).
199
+ if isVendorPackage (pkg ) {
200
+ klog .V (3 ).Infof ("package=%v coming from vendor/, ignoring." , p )
201
+ continue
202
+ }
203
+
204
+ if groupName (pkg ) != "" && len (pkg .Types ) > 0 {
195
205
klog .V (3 ).Infof ("package=%v has groupName and has types" , p )
196
206
pkgNames = append (pkgNames , p )
197
207
}
@@ -205,6 +215,12 @@ func parseAPIPackages(dir string) ([]*types.Package, error) {
205
215
return pkgs , nil
206
216
}
207
217
218
+ // isVendorPackage determines if package is coming from vendor/ dir.
219
+ func isVendorPackage (pkg * types.Package ) bool {
220
+ vendorPattern := string (os .PathSeparator ) + "vendor" + string (os .PathSeparator )
221
+ return strings .Contains (pkg .SourcePath , vendorPattern )
222
+ }
223
+
208
224
func findTypeReferences (pkgs []* types.Package ) map [* types.Type ][]* types.Type {
209
225
m := make (map [* types.Type ][]* types.Type )
210
226
for _ , pkg := range pkgs {
0 commit comments