mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-25 10:07:43 +01:00
fix(log): change log level from warning to debug when unescape path params (#11359)
Closes #11186 Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
parent
fdb82ae4fa
commit
86d446ce81
@ -80,12 +80,12 @@ func unescapePathParams(params interface{}, fieldNames ...string) error {
|
||||
for _, name := range fieldNames {
|
||||
field := val.FieldByName(name)
|
||||
if !field.IsValid() {
|
||||
log.Warningf("field %s not found in params %v", name, params)
|
||||
log.Debugf("field %s not found in %s", name, val.Type().Name())
|
||||
continue
|
||||
}
|
||||
|
||||
if !field.CanSet() {
|
||||
log.Warningf("field %s can not be changed in params %v", name, params)
|
||||
log.Debugf("field %s can not be changed in %s", name, val.Type().Name())
|
||||
continue
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ func unescapePathParams(params interface{}, fieldNames ...string) error {
|
||||
}
|
||||
field.SetString(v)
|
||||
default:
|
||||
log.Warningf("field %s can not be unescaped in params %v", name, params)
|
||||
log.Debugf("field %s can not be unescaped in %s", name, val.Type().Name())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
|
||||
func Test_unescapePathParams(t *testing.T) {
|
||||
type Params struct {
|
||||
ProjectID int64
|
||||
ProjectName string
|
||||
RepositoryName string
|
||||
}
|
||||
@ -38,6 +39,8 @@ func Test_unescapePathParams(t *testing.T) {
|
||||
{"non ptr", args{str, []string{"RepositoryName"}}, true},
|
||||
{"non struct", args{&str, []string{"RepositoryName"}}, true},
|
||||
{"ptr of struct", args{&Params{}, []string{"RepositoryName"}}, false},
|
||||
{"non string filed", args{&Params{}, []string{"ProjectID"}}, false},
|
||||
{"filed not found", args{&Params{}, []string{"Name"}}, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user