mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
minor cleanups
This commit is contained in:
parent
b09bbd808a
commit
4549573a44
@ -196,6 +196,8 @@ func localImportPath(importExpr string) (string, error) {
|
|||||||
// search k/k local checkout
|
// search k/k local checkout
|
||||||
pathPrefix = KUBE_ROOT
|
pathPrefix = KUBE_ROOT
|
||||||
importExpr = strings.Replace(importExpr, kubeURLRoot, "", 1)
|
importExpr = strings.Replace(importExpr, kubeURLRoot, "", 1)
|
||||||
|
} else if strings.Contains(importExpr, "k8s.io/klog/v2") || strings.Contains(importExpr, "k8s.io/util") {
|
||||||
|
pathPrefix = strings.Join([]string{KUBE_ROOT, "vendor"}, string(os.PathSeparator))
|
||||||
} else if strings.Contains(importExpr, "k8s.io/") {
|
} else if strings.Contains(importExpr, "k8s.io/") {
|
||||||
// search k/k/staging local checkout
|
// search k/k/staging local checkout
|
||||||
pathPrefix = strings.Join([]string{KUBE_ROOT, "staging", "src"}, string(os.PathSeparator))
|
pathPrefix = strings.Join([]string{KUBE_ROOT, "staging", "src"}, string(os.PathSeparator))
|
||||||
@ -204,7 +206,7 @@ func localImportPath(importExpr string) (string, error) {
|
|||||||
// pathPrefix = strings.Join([]string{KUBE_ROOT, "vendor"}, string(os.PathSeparator))
|
// pathPrefix = strings.Join([]string{KUBE_ROOT, "vendor"}, string(os.PathSeparator))
|
||||||
|
|
||||||
// this requires implementing SIV, skip for now
|
// this requires implementing SIV, skip for now
|
||||||
return "", fmt.Errorf("unable to handle general, non STL imports for metric analysis")
|
return "", fmt.Errorf("unable to handle general, non STL imports for metric analysis. import path: %s", importExpr)
|
||||||
} else {
|
} else {
|
||||||
// stdlib -> prefix with GOROOT
|
// stdlib -> prefix with GOROOT
|
||||||
pathPrefix = strings.Join([]string{GOROOT, "src"}, string(os.PathSeparator))
|
pathPrefix = strings.Join([]string{GOROOT, "src"}, string(os.PathSeparator))
|
||||||
@ -230,13 +232,14 @@ func importedGlobalVariableDeclaration(localVariables map[string]ast.Expr, impor
|
|||||||
// find local path on disk for listed import
|
// find local path on disk for listed import
|
||||||
importDirectory, err := localImportPath(im.Path.Value)
|
importDirectory, err := localImportPath(im.Path.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprint(os.Stderr, err.Error())
|
// uncomment the below log line if you want to start using non k8s/non stl libs for resolving const/var in metric definitions
|
||||||
|
// fmt.Fprint(os.Stderr, err.Error() + "\n")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
files, err := ioutil.ReadDir(importDirectory)
|
files, err := ioutil.ReadDir(importDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//fmt.Fprintf(os.Stderr, "failed to read import path directory %s with error %w, skipping\n", importDirectory, err)
|
fmt.Fprintf(os.Stderr, "failed to read import path directory %s with error %s, skipping\n", importDirectory, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user