Skip to content

Commit 7029fef

Browse files
committed
refactor: replace interface{} to any
Signed-off-by: chlins <[email protected]>
1 parent 49df3b4 commit 7029fef

File tree

413 files changed

+1388
-1388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+1388
-1388
lines changed

src/common/api/base.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (b *BaseAPI) RenderError(code int, text string) {
7878
}
7979

8080
// DecodeJSONReq decodes a json request
81-
func (b *BaseAPI) DecodeJSONReq(v interface{}) error {
81+
func (b *BaseAPI) DecodeJSONReq(v any) error {
8282
err := json.Unmarshal(b.Ctx.Input.CopyBody(1<<35), v)
8383
if err != nil {
8484
log.Errorf("Error while decoding the json request, error: %v, %v",
@@ -89,7 +89,7 @@ func (b *BaseAPI) DecodeJSONReq(v interface{}) error {
8989
}
9090

9191
// Validate validates v if it implements interface validation.ValidFormer
92-
func (b *BaseAPI) Validate(v interface{}) (bool, error) {
92+
func (b *BaseAPI) Validate(v any) (bool, error) {
9393
validator := validation.Validation{}
9494
isValid, err := validator.Valid(v)
9595
if err != nil {
@@ -108,7 +108,7 @@ func (b *BaseAPI) Validate(v interface{}) (bool, error) {
108108
}
109109

110110
// DecodeJSONReqAndValidate does both decoding and validation
111-
func (b *BaseAPI) DecodeJSONReqAndValidate(v interface{}) (bool, error) {
111+
func (b *BaseAPI) DecodeJSONReqAndValidate(v any) (bool, error) {
112112
if err := b.DecodeJSONReq(v); err != nil {
113113
return false, err
114114
}

src/common/dao/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,6 @@ func (l *mLogger) Verbose() bool {
144144
}
145145

146146
// Printf ...
147-
func (l *mLogger) Printf(format string, v ...interface{}) {
147+
func (l *mLogger) Printf(format string, v ...any) {
148148
l.logger.Infof(format, v...)
149149
}

src/common/dao/dao_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
var testCtx context.Context
3131

32-
func execUpdate(o orm.TxOrmer, sql string, params ...interface{}) error {
32+
func execUpdate(o orm.TxOrmer, sql string, params ...any) error {
3333
p, err := o.Raw(sql).Prepare()
3434
if err != nil {
3535
return err

src/common/http/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {
6969
}
7070

7171
// Get ...
72-
func (c *Client) Get(url string, v ...interface{}) error {
72+
func (c *Client) Get(url string, v ...any) error {
7373
req, err := http.NewRequest(http.MethodGet, url, nil)
7474
if err != nil {
7575
return err
@@ -98,7 +98,7 @@ func (c *Client) Head(url string) error {
9898
}
9999

100100
// Post ...
101-
func (c *Client) Post(url string, v ...interface{}) error {
101+
func (c *Client) Post(url string, v ...any) error {
102102
var reader io.Reader
103103
if len(v) > 0 {
104104
if r, ok := v[0].(io.Reader); ok {
@@ -123,7 +123,7 @@ func (c *Client) Post(url string, v ...interface{}) error {
123123
}
124124

125125
// Put ...
126-
func (c *Client) Put(url string, v ...interface{}) error {
126+
func (c *Client) Put(url string, v ...any) error {
127127
var reader io.Reader
128128
if len(v) > 0 {
129129
data, err := json.Marshal(v[0])
@@ -176,7 +176,7 @@ func (c *Client) do(req *http.Request) ([]byte, error) {
176176

177177
// GetAndIteratePagination iterates the pagination header and returns all resources
178178
// The parameter "v" must be a pointer to a slice
179-
func (c *Client) GetAndIteratePagination(endpoint string, v interface{}) error {
179+
func (c *Client) GetAndIteratePagination(endpoint string, v any) error {
180180
url, err := url.Parse(endpoint)
181181
if err != nil {
182182
return err

src/common/job/models/models.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package models
1616

1717
// Parameters for job execution.
18-
type Parameters map[string]interface{}
18+
type Parameters map[string]any
1919

2020
// JobRequest is the request of launching a job.
2121
type JobRequest struct {
@@ -96,5 +96,5 @@ type JobStatusChange struct {
9696
// Message is designed for sub/pub messages
9797
type Message struct {
9898
Event string
99-
Data interface{} // generic format
99+
Data any // generic format
100100
}

src/common/rbac/project/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (ns *projectNamespace) Resource(subresources ...types.Resource) types.Resou
4343
return types.Resource(fmt.Sprintf("/project/%d", ns.projectID)).Subresource(subresources...)
4444
}
4545

46-
func (ns *projectNamespace) Identity() interface{} {
46+
func (ns *projectNamespace) Identity() any {
4747
return ns.projectID
4848
}
4949

src/common/rbac/system/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (ns *systemNamespace) Resource(subresources ...types.Resource) types.Resour
3838
return types.Resource("/system/").Subresource(subresources...)
3939
}
4040

41-
func (ns *systemNamespace) Identity() interface{} {
41+
func (ns *systemNamespace) Identity() any {
4242
return nil
4343
}
4444

src/common/security/v2token/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (t *tokenSecurityCtx) GetMyProjects() ([]*models.Project, error) {
6363
return []*models.Project{}, nil
6464
}
6565

66-
func (t *tokenSecurityCtx) GetProjectRoles(_ interface{}) []int {
66+
func (t *tokenSecurityCtx) GetProjectRoles(_ any) []int {
6767
return []int{}
6868
}
6969

src/common/utils/test/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/goharbor/harbor/src/common"
1919
)
2020

21-
var defaultConfig = map[string]interface{}{
21+
var defaultConfig = map[string]any{
2222
common.ExtEndpoint: "https://host01.com",
2323
common.AUTHMode: common.DBAuth,
2424
common.DatabaseType: "postgresql",
@@ -66,6 +66,6 @@ var defaultConfig = map[string]interface{}{
6666
}
6767

6868
// GetDefaultConfigMap returns the default config map for easier modification.
69-
func GetDefaultConfigMap() map[string]interface{} {
69+
func GetDefaultConfigMap() map[string]any {
7070
return defaultConfig
7171
}

src/common/utils/test/registryctl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type GCResult struct {
3030
}
3131

3232
// NewRegistryCtl returns a mock registry server
33-
func NewRegistryCtl(_ map[string]interface{}) (*httptest.Server, error) {
33+
func NewRegistryCtl(_ map[string]any) (*httptest.Server, error) {
3434
m := []*RequestHandlerMapping{}
3535

3636
gcr := GCResult{true, "hello-world", time.Now(), time.Now()}

0 commit comments

Comments
 (0)