mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
chore: add unconvert linter (#3867)
Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
parent
97e5e64fd4
commit
f508e9a0b8
7 changed files with 9 additions and 8 deletions
|
@ -10,6 +10,7 @@ linters:
|
|||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
||||
|
|
|
@ -118,7 +118,7 @@ func Command() *cobra.Command {
|
|||
func printFunctionList() {
|
||||
functions := []string{}
|
||||
for _, function := range jmespath.GetFunctions() {
|
||||
functions = append(functions, string(function.String()))
|
||||
functions = append(functions, function.String())
|
||||
}
|
||||
sort.Strings(functions)
|
||||
fmt.Println(strings.Join(functions, "\n"))
|
||||
|
|
|
@ -340,7 +340,7 @@ func testCommandExecute(dirPath []string, fileName string, gitBranch string, tes
|
|||
if err != nil {
|
||||
return rc, fmt.Errorf("unable to create open api controller, %w", err)
|
||||
}
|
||||
if strings.Contains(string(dirPath[0]), "https://") {
|
||||
if strings.Contains(dirPath[0], "https://") {
|
||||
gitURL, err := url.Parse(dirPath[0])
|
||||
if err != nil {
|
||||
return rc, sanitizederror.NewWithError("failed to parse URL", err)
|
||||
|
|
|
@ -90,7 +90,7 @@ func VerifySignature(opts Options) (digest string, err error) {
|
|||
// load cert and optionally a cert chain as a verifier
|
||||
cert, err := loadCert([]byte(opts.Cert))
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "failed to load certificate from %s", string(opts.Cert))
|
||||
return "", errors.Wrapf(err, "failed to load certificate from %s", opts.Cert)
|
||||
}
|
||||
|
||||
if opts.CertChain == "" {
|
||||
|
|
|
@ -12,7 +12,7 @@ func convertNumberToString(value interface{}) (string, error) {
|
|||
}
|
||||
switch typed := value.(type) {
|
||||
case string:
|
||||
return string(typed), nil
|
||||
return typed, nil
|
||||
case float64:
|
||||
return fmt.Sprintf("%f", typed), nil
|
||||
case int64:
|
||||
|
|
|
@ -87,7 +87,7 @@ func (noh NumericOperatorHandler) validateValueWithIntPattern(key int64, value i
|
|||
case string:
|
||||
durationKey, durationValue, err := parseDuration(key, value)
|
||||
if err == nil {
|
||||
return compareByCondition(float64(durationKey.Seconds()), float64(durationValue.Seconds()), noh.condition, noh.log)
|
||||
return compareByCondition(durationKey.Seconds(), durationValue.Seconds(), noh.condition, noh.log)
|
||||
}
|
||||
// extract float64 and (if that fails) then, int64 from the string
|
||||
float64val, err := strconv.ParseFloat(typedValue, 64)
|
||||
|
@ -117,7 +117,7 @@ func (noh NumericOperatorHandler) validateValueWithFloatPattern(key float64, val
|
|||
case string:
|
||||
durationKey, durationValue, err := parseDuration(key, value)
|
||||
if err == nil {
|
||||
return compareByCondition(float64(durationKey.Seconds()), float64(durationValue.Seconds()), noh.condition, noh.log)
|
||||
return compareByCondition(durationKey.Seconds(), durationValue.Seconds(), noh.condition, noh.log)
|
||||
}
|
||||
float64val, err := strconv.ParseFloat(typedValue, 64)
|
||||
if err == nil {
|
||||
|
@ -154,7 +154,7 @@ func (noh NumericOperatorHandler) validateValueWithStringPattern(key string, val
|
|||
// We need to check duration first as it's the only type that can be compared to a different type
|
||||
durationKey, durationValue, err := parseDuration(key, value)
|
||||
if err == nil {
|
||||
return compareByCondition(float64(durationKey.Seconds()), float64(durationValue.Seconds()), noh.condition, noh.log)
|
||||
return compareByCondition(durationKey.Seconds(), durationValue.Seconds(), noh.condition, noh.log)
|
||||
}
|
||||
// attempt to extract resource quantity from string before parsing floats/ints as resources can also be ints/floats represented as string type
|
||||
resourceKey, resourceValue, err := parseQuantity(key, value)
|
||||
|
|
|
@ -220,7 +220,7 @@ func CallAPI(request APIRequest) (*http.Response, error) {
|
|||
}
|
||||
response = resp
|
||||
case "POST", "PUT", "DELETE", "PATCH":
|
||||
req, err := http.NewRequest(string(request.Type), request.URL, request.Body)
|
||||
req, err := http.NewRequest(request.Type, request.URL, request.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error occurred while calling %s: %w", request.URL, err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue