Update vendored dependencies
This commit is contained in:
25
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
25
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
@@ -28,11 +28,12 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"k8s.io/gengo/types"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// This clarifies when a pkg path has been canonicalized.
|
||||
@@ -334,6 +335,12 @@ func (b *Builder) addDir(dir string, userRequested bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var regexErrPackageNotFound = regexp.MustCompile(`^unable to import ".*?": cannot find package ".*?" in any of:`)
|
||||
|
||||
func isErrPackageNotFound(err error) bool {
|
||||
return regexErrPackageNotFound.MatchString(err.Error())
|
||||
}
|
||||
|
||||
// importPackage is a function that will be called by the type check package when it
|
||||
// needs to import a go package. 'path' is the import path.
|
||||
func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, error) {
|
||||
@@ -356,6 +363,11 @@ func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, er
|
||||
|
||||
// Add it.
|
||||
if err := b.addDir(dir, userRequested); err != nil {
|
||||
if isErrPackageNotFound(err) {
|
||||
klog.V(6).Info(err)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -577,7 +589,7 @@ func (b *Builder) importWithMode(dir string, mode build.ImportMode) (*build.Pack
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to get current directory: %v", err)
|
||||
}
|
||||
buildPkg, err := b.context.Import(dir, cwd, mode)
|
||||
buildPkg, err := b.context.Import(filepath.ToSlash(dir), cwd, mode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -750,7 +762,11 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
|
||||
if out.Methods == nil {
|
||||
out.Methods = map[string]*types.Type{}
|
||||
}
|
||||
out.Methods[t.Method(i).Name()] = b.walkType(u, nil, t.Method(i).Type())
|
||||
method := t.Method(i)
|
||||
name := tcNameToName(method.String())
|
||||
mt := b.walkType(u, &name, method.Type())
|
||||
mt.CommentLines = splitLines(b.priorCommentLines(method.Pos(), 1).Text())
|
||||
out.Methods[method.Name()] = mt
|
||||
}
|
||||
return out
|
||||
case *tc.Named:
|
||||
@@ -783,7 +799,8 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
|
||||
out.Methods = map[string]*types.Type{}
|
||||
}
|
||||
method := t.Method(i)
|
||||
mt := b.walkType(u, nil, method.Type())
|
||||
name := tcNameToName(method.String())
|
||||
mt := b.walkType(u, &name, method.Type())
|
||||
mt.CommentLines = splitLines(b.priorCommentLines(method.Pos(), 1).Text())
|
||||
out.Methods[method.Name()] = mt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user