hack/verify fixes
This commit is contained in:
@@ -188,7 +188,7 @@ func (c *metricDecoder) decodeOpts(expr ast.Expr) (metric, error) {
|
|||||||
return m, newDecodeErrorf(expr, errExprNotIdent, v.X)
|
return m, newDecodeErrorf(expr, errExprNotIdent, v.X)
|
||||||
}
|
}
|
||||||
|
|
||||||
variableExpr, found := c.variables[strings.Join([]string{s.Name,v.Sel.Name}, ".")]
|
variableExpr, found := c.variables[strings.Join([]string{s.Name, v.Sel.Name}, ".")]
|
||||||
if !found {
|
if !found {
|
||||||
return m, newDecodeErrorf(expr, errBadImportedVariableAttribute)
|
return m, newDecodeErrorf(expr, errBadImportedVariableAttribute)
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ const (
|
|||||||
errInvalidNewMetricCall = "Invalid new metric call, please ensure code compiles"
|
errInvalidNewMetricCall = "Invalid new metric call, please ensure code compiles"
|
||||||
errNonStringAttribute = "Non string attribute is not supported"
|
errNonStringAttribute = "Non string attribute is not supported"
|
||||||
errBadVariableAttribute = "Metric attribute was not correctly set. Please use only global consts in same file"
|
errBadVariableAttribute = "Metric attribute was not correctly set. Please use only global consts in same file"
|
||||||
errBadImportedVariableAttribute = "Metric attribute was not correctly set. Please use only global consts in correclty impoprted same file"
|
errBadImportedVariableAttribute = "Metric attribute was not correctly set. Please use only global consts in correctly impoprted same file"
|
||||||
errFieldNotSupported = "Field %s is not supported"
|
errFieldNotSupported = "Field %s is not supported"
|
||||||
errBuckets = "Buckets should be set to list of floats, result from function call of prometheus.LinearBuckets or prometheus.ExponentialBuckets"
|
errBuckets = "Buckets should be set to list of floats, result from function call of prometheus.LinearBuckets or prometheus.ExponentialBuckets"
|
||||||
errLabels = "Labels were not set to list of strings"
|
errLabels = "Labels were not set to list of strings"
|
||||||
|
@@ -191,7 +191,7 @@ func globalVariableDeclarations(tree *ast.File) map[string]ast.Expr {
|
|||||||
|
|
||||||
func localImportPath(importExpr string) (string, error) {
|
func localImportPath(importExpr string) (string, error) {
|
||||||
// parse directory path
|
// parse directory path
|
||||||
pathPrefix := "unknown"
|
var pathPrefix string
|
||||||
if strings.Contains(importExpr, kubeURLRoot) {
|
if strings.Contains(importExpr, kubeURLRoot) {
|
||||||
// search k/k local checkout
|
// search k/k local checkout
|
||||||
pathPrefix = KUBE_ROOT
|
pathPrefix = KUBE_ROOT
|
||||||
@@ -212,7 +212,7 @@ func localImportPath(importExpr string) (string, error) {
|
|||||||
pathPrefix = strings.Join([]string{GOROOT, "src"}, string(os.PathSeparator))
|
pathPrefix = strings.Join([]string{GOROOT, "src"}, string(os.PathSeparator))
|
||||||
} // ToDo: support non go mod
|
} // ToDo: support non go mod
|
||||||
|
|
||||||
crossPlatformImportExpr := strings.Replace(importExpr, "/", string(os.PathSeparator), 0)
|
crossPlatformImportExpr := strings.Replace(importExpr, "/", string(os.PathSeparator), -1)
|
||||||
importDirectory := strings.Join([]string{pathPrefix, strings.Trim(crossPlatformImportExpr, "\"")}, string(os.PathSeparator))
|
importDirectory := strings.Join([]string{pathPrefix, strings.Trim(crossPlatformImportExpr, "\"")}, string(os.PathSeparator))
|
||||||
|
|
||||||
return importDirectory, nil
|
return importDirectory, nil
|
||||||
@@ -221,7 +221,7 @@ func localImportPath(importExpr string) (string, error) {
|
|||||||
func importedGlobalVariableDeclaration(localVariables map[string]ast.Expr, imports []*ast.ImportSpec) (map[string]ast.Expr, error) {
|
func importedGlobalVariableDeclaration(localVariables map[string]ast.Expr, imports []*ast.ImportSpec) (map[string]ast.Expr, error) {
|
||||||
for _, im := range imports {
|
for _, im := range imports {
|
||||||
// get imported label
|
// get imported label
|
||||||
importAlias := "unknown"
|
var importAlias string
|
||||||
if im.Name == nil {
|
if im.Name == nil {
|
||||||
pathSegments := strings.Split(im.Path.Value, "/")
|
pathSegments := strings.Split(im.Path.Value, "/")
|
||||||
importAlias = strings.Trim(pathSegments[len(pathSegments)-1], "\"")
|
importAlias = strings.Trim(pathSegments[len(pathSegments)-1], "\"")
|
||||||
|
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package metrics
|
package metrics
|
||||||
|
|
||||||
const OKGO = "ThisIsNotTheSoundOfTheTrain"
|
const OKGO = "ThisIsNotTheSoundOfTheTrain"
|
||||||
|
Reference in New Issue
Block a user