diff --git a/agent/rpc/auth_interceptor.go b/agent/rpc/auth_interceptor.go index 8f13f4c1b..d15e195b1 100644 --- a/agent/rpc/auth_interceptor.go +++ b/agent/rpc/auth_interceptor.go @@ -51,7 +51,7 @@ func (interceptor *AuthInterceptor) Unary() grpc.UnaryClientInterceptor { return func( ctx context.Context, method string, - req, reply interface{}, + req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, diff --git a/pipeline/backend/kubernetes/kubernetes.go b/pipeline/backend/kubernetes/kubernetes.go index ff394c0e1..2fcb1a760 100644 --- a/pipeline/backend/kubernetes/kubernetes.go +++ b/pipeline/backend/kubernetes/kubernetes.go @@ -213,7 +213,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string) finished := make(chan bool) - podUpdated := func(old, new interface{}) { + podUpdated := func(old, new any) { pod := new.(*v1.Pod) if pod.Name == podName { if isImagePullBackOffState(pod) { @@ -273,7 +273,7 @@ func (e *kube) TailStep(ctx context.Context, step *types.Step, taskUUID string) up := make(chan bool) - podUpdated := func(old, new interface{}) { + podUpdated := func(old, new any) { pod := new.(*v1.Pod) if pod.Name == podName { switch pod.Status.Phase { diff --git a/pipeline/errors/error.go b/pipeline/errors/error.go index 991c83f8d..3de242205 100644 --- a/pipeline/errors/error.go +++ b/pipeline/errors/error.go @@ -20,7 +20,7 @@ type PipelineError struct { Type PipelineErrorType `json:"type"` Message string `json:"message"` IsWarning bool `json:"is_warning"` - Data interface{} `json:"data"` + Data any `json:"data"` } type LinterErrorData struct { diff --git a/pipeline/frontend/yaml/compiler/cacher.go b/pipeline/frontend/yaml/compiler/cacher.go index 638c02a5d..db56a613a 100644 --- a/pipeline/frontend/yaml/compiler/cacher.go +++ b/pipeline/frontend/yaml/compiler/cacher.go @@ -36,7 +36,7 @@ func (c *volumeCacher) Restore(repo, branch string, mounts []string) *yaml_types return &yaml_types.Container{ Name: "rebuild_cache", Image: "plugins/volume-cache:1.0.0", - Settings: map[string]interface{}{ + Settings: map[string]any{ "mount": mounts, "path": "/cache", "restore": true, @@ -59,7 +59,7 @@ func (c *volumeCacher) Rebuild(repo, branch string, mounts []string) *yaml_types return &yaml_types.Container{ Name: "rebuild_cache", Image: "plugins/volume-cache:1.0.0", - Settings: map[string]interface{}{ + Settings: map[string]any{ "mount": mounts, "path": "/cache", "rebuild": true, @@ -89,7 +89,7 @@ func (c *s3Cacher) Restore(_, _ string, mounts []string) *yaml_types.Container { return &yaml_types.Container{ Name: "rebuild_cache", Image: "plugins/s3-cache:latest", - Settings: map[string]interface{}{ + Settings: map[string]any{ "mount": mounts, "access_key": c.access, "secret_key": c.secret, @@ -104,7 +104,7 @@ func (c *s3Cacher) Rebuild(_, _ string, mounts []string) *yaml_types.Container { return &yaml_types.Container{ Name: "rebuild_cache", Image: "plugins/s3-cache:latest", - Settings: map[string]interface{}{ + Settings: map[string]any{ "mount": mounts, "access_key": c.access, "secret_key": c.secret, diff --git a/pipeline/frontend/yaml/compiler/compiler.go b/pipeline/frontend/yaml/compiler/compiler.go index 938b3a26f..0652f0fd4 100644 --- a/pipeline/frontend/yaml/compiler/compiler.go +++ b/pipeline/frontend/yaml/compiler/compiler.go @@ -151,7 +151,7 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er // add default clone step if !c.local && len(conf.Clone.ContainerList) == 0 && !conf.SkipClone { - cloneSettings := map[string]interface{}{"depth": "0"} + cloneSettings := map[string]any{"depth": "0"} if c.metadata.Curr.Event == metadata.EventTag { cloneSettings["tags"] = "true" } diff --git a/pipeline/frontend/yaml/compiler/settings/params.go b/pipeline/frontend/yaml/compiler/settings/params.go index a021d3daa..55b3c7995 100644 --- a/pipeline/frontend/yaml/compiler/settings/params.go +++ b/pipeline/frontend/yaml/compiler/settings/params.go @@ -26,7 +26,7 @@ import ( // ParamsToEnv uses reflection to convert a map[string]interface to a list // of environment variables. -func ParamsToEnv(from map[string]interface{}, to, secrets map[string]string) (err error) { +func ParamsToEnv(from map[string]any, to, secrets map[string]string) (err error) { if to == nil { return fmt.Errorf("no map to write to") } @@ -62,7 +62,7 @@ func isComplex(t reflect.Kind) bool { } // sanitizeParamValue returns the value of a setting as string prepared to be injected as environment variable -func sanitizeParamValue(v interface{}, secrets map[string]string) (string, error) { +func sanitizeParamValue(v any, secrets map[string]string) (string, error) { t := reflect.TypeOf(v) vv := reflect.ValueOf(v) @@ -82,7 +82,7 @@ func sanitizeParamValue(v interface{}, secrets map[string]string) (string, error case reflect.Map: switch v := v.(type) { // gopkg.in/yaml.v3 only emits this map interface - case map[string]interface{}: + case map[string]any: // check if it's a secret and return value if it's the case value, isSecret, err := injectSecret(v, secrets) if err != nil { @@ -139,7 +139,7 @@ func sanitizeParamValue(v interface{}, secrets map[string]string) (string, error } // handleComplex uses yaml2json to get json strings as values for environment variables -func handleComplex(v interface{}, secrets map[string]string) (string, error) { +func handleComplex(v any, secrets map[string]string) (string, error) { v, err := injectSecretRecursive(v, secrets) if err != nil { return "", err @@ -159,7 +159,7 @@ func handleComplex(v interface{}, secrets map[string]string) (string, error) { // injectSecret probes if a map is a from_secret request. // If it's a from_secret request it either returns the secret value or an error if the secret was not found // else it just indicates to progress normally using the provided map as is -func injectSecret(v map[string]interface{}, secrets map[string]string) (string, bool, error) { +func injectSecret(v map[string]any, secrets map[string]string) (string, bool, error) { if secretNameI, ok := v["from_secret"]; ok { if secretName, ok := secretNameI.(string); ok { if secret, ok := secrets[strings.ToLower(secretName)]; ok { @@ -174,7 +174,7 @@ func injectSecret(v map[string]interface{}, secrets map[string]string) (string, // injectSecretRecursive iterates over all types and if they contain elements // it iterates recursively over them too, using injectSecret internally -func injectSecretRecursive(v interface{}, secrets map[string]string) (interface{}, error) { +func injectSecretRecursive(v any, secrets map[string]string) (any, error) { t := reflect.TypeOf(v) if !isComplex(t.Kind()) { @@ -185,7 +185,7 @@ func injectSecretRecursive(v interface{}, secrets map[string]string) (interface{ case reflect.Map: switch v := v.(type) { // gopkg.in/yaml.v3 only emits this map interface - case map[string]interface{}: + case map[string]any: // handle secrets value, isSecret, err := injectSecret(v, secrets) if err != nil { @@ -207,7 +207,7 @@ func injectSecretRecursive(v interface{}, secrets map[string]string) (interface{ case reflect.Array, reflect.Slice: vv := reflect.ValueOf(v) - vl := make([]interface{}, vv.Len()) + vl := make([]any, vv.Len()) for i := 0; i < vv.Len(); i++ { v, err := injectSecretRecursive(vv.Index(i).Interface(), secrets) diff --git a/pipeline/frontend/yaml/compiler/settings/params_test.go b/pipeline/frontend/yaml/compiler/settings/params_test.go index 37ec227ae..85fbfd729 100644 --- a/pipeline/frontend/yaml/compiler/settings/params_test.go +++ b/pipeline/frontend/yaml/compiler/settings/params_test.go @@ -22,21 +22,21 @@ import ( ) func TestParamsToEnv(t *testing.T) { - from := map[string]interface{}{ + from := map[string]any{ "skip": nil, "string": "stringz", "int": 1, "float": 1.2, "bool": true, "slice": []int{1, 2, 3}, - "map": map[string]interface{}{"hello": "world"}, + "map": map[string]any{"hello": "world"}, "complex": []struct{ Name string }{{"Jack"}, {"Jill"}}, "complex2": struct{ Name string }{"Jack"}, "from.address": "noreply@example.com", "tags": stringsToInterface("next", "latest"), "tag": stringsToInterface("next"), - "my_secret": map[string]interface{}{"from_secret": "secret_token"}, - "UPPERCASE_SECRET": map[string]interface{}{"from_secret": "SECRET_TOKEN"}, + "my_secret": map[string]any{"from_secret": "secret_token"}, + "UPPERCASE_SECRET": map[string]any{"from_secret": "SECRET_TOKEN"}, } want := map[string]string{ "PLUGIN_STRING": "stringz", @@ -62,7 +62,7 @@ func TestParamsToEnv(t *testing.T) { // handle edge cases (#1609) got = map[string]string{} - assert.NoError(t, ParamsToEnv(map[string]interface{}{"a": []interface{}{"a", nil}}, got, nil)) + assert.NoError(t, ParamsToEnv(map[string]any{"a": []any{"a", nil}}, got, nil)) assert.EqualValues(t, map[string]string{"PLUGIN_A": "a,"}, got) } @@ -95,7 +95,7 @@ list.map: password: from_secret: cb_password `) - var from map[string]interface{} + var from map[string]any err := yaml.Unmarshal(fromYAML, &from) assert.NoError(t, err) @@ -122,7 +122,7 @@ func TestYAMLToParamsToEnvError(t *testing.T) { fromYAML := []byte(`my_secret: from_secret: not_a_secret `) - var from map[string]interface{} + var from map[string]any err := yaml.Unmarshal(fromYAML, &from) assert.NoError(t, err) secrets := map[string]string{ @@ -131,8 +131,8 @@ func TestYAMLToParamsToEnvError(t *testing.T) { assert.Error(t, ParamsToEnv(from, make(map[string]string), secrets)) } -func stringsToInterface(val ...string) []interface{} { - res := make([]interface{}, len(val)) +func stringsToInterface(val ...string) []any { + res := make([]any, len(val)) for i := range val { res[i] = val[i] } diff --git a/pipeline/frontend/yaml/constraint/constraint.go b/pipeline/frontend/yaml/constraint/constraint.go index 19a0779dc..f72beae69 100644 --- a/pipeline/frontend/yaml/constraint/constraint.go +++ b/pipeline/frontend/yaml/constraint/constraint.go @@ -298,7 +298,7 @@ func (c *Map) Match(params map[string]string) bool { } // UnmarshalYAML unmarshal the constraint map. -func (c *Map) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (c *Map) UnmarshalYAML(unmarshal func(any) error) error { out1 := struct { Include map[string]string Exclude map[string]string diff --git a/pipeline/frontend/yaml/types/base/int.go b/pipeline/frontend/yaml/types/base/int.go index a1d2ce58e..e4ff93b79 100644 --- a/pipeline/frontend/yaml/types/base/int.go +++ b/pipeline/frontend/yaml/types/base/int.go @@ -25,7 +25,7 @@ import ( type StringOrInt int64 // UnmarshalYAML implements the Unmarshaler interface. -func (s *StringOrInt) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (s *StringOrInt) UnmarshalYAML(unmarshal func(any) error) error { var intType int64 if err := unmarshal(&intType); err == nil { *s = StringOrInt(intType) @@ -50,7 +50,7 @@ func (s *StringOrInt) UnmarshalYAML(unmarshal func(interface{}) error) error { type MemStringOrInt int64 // UnmarshalYAML implements the Unmarshaler interface. -func (s *MemStringOrInt) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (s *MemStringOrInt) UnmarshalYAML(unmarshal func(any) error) error { var intType int64 if err := unmarshal(&intType); err == nil { *s = MemStringOrInt(intType) diff --git a/pipeline/frontend/yaml/types/base/map.go b/pipeline/frontend/yaml/types/base/map.go index d9777c5a6..3102ef1b3 100644 --- a/pipeline/frontend/yaml/types/base/map.go +++ b/pipeline/frontend/yaml/types/base/map.go @@ -24,8 +24,8 @@ import ( type SliceOrMap map[string]string // UnmarshalYAML implements the Unmarshaler interface. -func (s *SliceOrMap) UnmarshalYAML(unmarshal func(interface{}) error) error { - var sliceType []interface{} +func (s *SliceOrMap) UnmarshalYAML(unmarshal func(any) error) error { + var sliceType []any if err := unmarshal(&sliceType); err == nil { parts := map[string]string{} for _, s := range sliceType { @@ -47,7 +47,7 @@ func (s *SliceOrMap) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } - var mapType map[interface{}]interface{} + var mapType map[any]any if err := unmarshal(&mapType); err == nil { parts := map[string]string{} for k, v := range mapType { diff --git a/pipeline/frontend/yaml/types/base/slice.go b/pipeline/frontend/yaml/types/base/slice.go index df5a6856f..7c964ace6 100644 --- a/pipeline/frontend/yaml/types/base/slice.go +++ b/pipeline/frontend/yaml/types/base/slice.go @@ -24,14 +24,14 @@ import ( type StringOrSlice []string // UnmarshalYAML implements the Unmarshaler interface. -func (s *StringOrSlice) UnmarshalYAML(unmarshal func(interface{}) error) error { +func (s *StringOrSlice) UnmarshalYAML(unmarshal func(any) error) error { var stringType string if err := unmarshal(&stringType); err == nil { *s = []string{stringType} return nil } - var sliceType []interface{} + var sliceType []any if err := unmarshal(&sliceType); err == nil { parts, err := toStrings(sliceType) if err != nil { @@ -44,7 +44,7 @@ func (s *StringOrSlice) UnmarshalYAML(unmarshal func(interface{}) error) error { return errors.New("Failed to unmarshal StringOrSlice") } -func toStrings(s []interface{}) ([]string, error) { +func toStrings(s []any) ([]string, error) { if len(s) == 0 { return nil, nil } diff --git a/pipeline/frontend/yaml/types/container.go b/pipeline/frontend/yaml/types/container.go index 1b8d530c7..7088261a0 100644 --- a/pipeline/frontend/yaml/types/container.go +++ b/pipeline/frontend/yaml/types/container.go @@ -33,21 +33,21 @@ type ( // Container defines a container. Container struct { - BackendOptions BackendOptions `yaml:"backend_options,omitempty"` - Commands base.StringOrSlice `yaml:"commands,omitempty"` - Detached bool `yaml:"detach,omitempty"` - Directory string `yaml:"directory,omitempty"` - Environment base.SliceOrMap `yaml:"environment,omitempty"` - Failure string `yaml:"failure,omitempty"` - Group string `yaml:"group,omitempty"` - Image string `yaml:"image,omitempty"` - Name string `yaml:"name,omitempty"` - Pull bool `yaml:"pull,omitempty"` - Secrets Secrets `yaml:"secrets,omitempty"` - Settings map[string]interface{} `yaml:"settings"` - Volumes Volumes `yaml:"volumes,omitempty"` - When constraint.When `yaml:"when,omitempty"` - Ports []base.StringOrInt `yaml:"ports,omitempty"` + BackendOptions BackendOptions `yaml:"backend_options,omitempty"` + Commands base.StringOrSlice `yaml:"commands,omitempty"` + Detached bool `yaml:"detach,omitempty"` + Directory string `yaml:"directory,omitempty"` + Environment base.SliceOrMap `yaml:"environment,omitempty"` + Failure string `yaml:"failure,omitempty"` + Group string `yaml:"group,omitempty"` + Image string `yaml:"image,omitempty"` + Name string `yaml:"name,omitempty"` + Pull bool `yaml:"pull,omitempty"` + Secrets Secrets `yaml:"secrets,omitempty"` + Settings map[string]any `yaml:"settings"` + Volumes Volumes `yaml:"volumes,omitempty"` + When constraint.When `yaml:"when,omitempty"` + Ports []base.StringOrInt `yaml:"ports,omitempty"` // Docker Specific Privileged bool `yaml:"privileged,omitempty"` diff --git a/pipeline/frontend/yaml/types/container_test.go b/pipeline/frontend/yaml/types/container_test.go index fa1931d50..0adb0ae5a 100644 --- a/pipeline/frontend/yaml/types/container_test.go +++ b/pipeline/frontend/yaml/types/container_test.go @@ -124,7 +124,7 @@ func TestUnmarshalContainer(t *testing.T) { }, }, }, - Settings: map[string]interface{}{ + Settings: map[string]any{ "foo": "bar", "baz": false, }, @@ -159,7 +159,7 @@ func TestUnmarshalContainers(t *testing.T) { { Name: "unit_test", Image: "node", - Settings: map[string]interface{}{ + Settings: map[string]any{ "normal_setting": true, }, }, @@ -190,7 +190,7 @@ func TestUnmarshalContainers(t *testing.T) { Source: "docker_password", Target: "docker_password", }}}, - Settings: map[string]interface{}{ + Settings: map[string]any{ "repo": "woodpeckerci/woodpecker-agent", "dockerfile": "docker/Dockerfile.agent", "tag": stringsToInterface("next", "latest"), @@ -223,7 +223,7 @@ func TestUnmarshalContainers(t *testing.T) { Name: "publish-cli", Image: "print/env", Group: "docker", - Settings: map[string]interface{}{ + Settings: map[string]any{ "repo": "woodpeckerci/woodpecker-cli", "dockerfile": "docker/Dockerfile.cli", "tag": stringsToInterface("next"), @@ -289,8 +289,8 @@ func TestUnmarshalContainersErr(t *testing.T) { } } -func stringsToInterface(val ...string) []interface{} { - res := make([]interface{}, len(val)) +func stringsToInterface(val ...string) []any { + res := make([]any, len(val)) for i := range val { res[i] = val[i] } diff --git a/pipeline/frontend/yaml/types/network.go b/pipeline/frontend/yaml/types/network.go index d659c1110..fe2798f99 100644 --- a/pipeline/frontend/yaml/types/network.go +++ b/pipeline/frontend/yaml/types/network.go @@ -34,7 +34,7 @@ type Network struct { } // MarshalYAML implements the Marshaller interface. -func (n Networks) MarshalYAML() (interface{}, error) { +func (n Networks) MarshalYAML() (any, error) { m := map[string]*Network{} for _, network := range n.Networks { m[network.Name] = network @@ -43,8 +43,8 @@ func (n Networks) MarshalYAML() (interface{}, error) { } // UnmarshalYAML implements the Unmarshaler interface. -func (n *Networks) UnmarshalYAML(unmarshal func(interface{}) error) error { - var sliceType []interface{} +func (n *Networks) UnmarshalYAML(unmarshal func(any) error) error { + var sliceType []any if err := unmarshal(&sliceType); err == nil { n.Networks = []*Network{} for _, network := range sliceType { @@ -59,7 +59,7 @@ func (n *Networks) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } - var mapType map[interface{}]interface{} + var mapType map[any]any if err := unmarshal(&mapType); err == nil { n.Networks = []*Network{} for mapKey, mapValue := range mapType { @@ -79,21 +79,21 @@ func (n *Networks) UnmarshalYAML(unmarshal func(interface{}) error) error { return errors.New("Failed to unmarshal Networks") } -func handleNetwork(name string, value interface{}) (*Network, error) { +func handleNetwork(name string, value any) (*Network, error) { if value == nil { return &Network{ Name: name, }, nil } switch v := value.(type) { - case map[string]interface{}: + case map[string]any: network := &Network{ Name: name, } for mapKey, mapValue := range v { switch mapKey { case "aliases": - aliases, ok := mapValue.([]interface{}) + aliases, ok := mapValue.([]any) if !ok { return &Network{}, fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", aliases, aliases) } diff --git a/pipeline/frontend/yaml/types/volume.go b/pipeline/frontend/yaml/types/volume.go index b8afa57b6..7dc7ec232 100644 --- a/pipeline/frontend/yaml/types/volume.go +++ b/pipeline/frontend/yaml/types/volume.go @@ -48,7 +48,7 @@ func (v *Volume) String() string { } // MarshalYAML implements the Marshaller interface. -func (v Volumes) MarshalYAML() (interface{}, error) { +func (v Volumes) MarshalYAML() (any, error) { vs := []string{} for _, volume := range v.Volumes { vs = append(vs, volume.String()) @@ -57,8 +57,8 @@ func (v Volumes) MarshalYAML() (interface{}, error) { } // UnmarshalYAML implements the Unmarshaler interface. -func (v *Volumes) UnmarshalYAML(unmarshal func(interface{}) error) error { - var sliceType []interface{} +func (v *Volumes) UnmarshalYAML(unmarshal func(any) error) error { + var sliceType []any if err := unmarshal(&sliceType); err == nil { v.Volumes = []*Volume{} for _, volume := range sliceType { diff --git a/pipeline/rpc/proto/woodpecker.pb.go b/pipeline/rpc/proto/woodpecker.pb.go index 85464b5dc..eb8dd2083 100644 --- a/pipeline/rpc/proto/woodpecker.pb.go +++ b/pipeline/rpc/proto/woodpecker.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.24.4 // source: woodpecker.proto diff --git a/server/forge/bitbucket/internal/client.go b/server/forge/bitbucket/internal/client.go index df001dfee..1e6deb282 100644 --- a/server/forge/bitbucket/internal/client.go +++ b/server/forge/bitbucket/internal/client.go @@ -238,7 +238,7 @@ func (c *Client) GetRepoFiles(owner, name, revision, path string, page *string) return out, err } -func (c *Client) do(rawurl, method string, in, out interface{}) (*string, error) { +func (c *Client) do(rawurl, method string, in, out any) (*string, error) { uri, err := url.Parse(rawurl) if err != nil { return nil, err diff --git a/server/forge/common/status.go b/server/forge/common/status.go index a5b69fbf0..40efd7db6 100644 --- a/server/forge/common/status.go +++ b/server/forge/common/status.go @@ -38,7 +38,7 @@ func GetPipelineStatusContext(repo *model.Repo, pipeline *model.Pipeline, workfl return "" } var ctx bytes.Buffer - err = tmpl.Execute(&ctx, map[string]interface{}{ + err = tmpl.Execute(&ctx, map[string]any{ "context": server.Config.Server.StatusContext, "event": event, "workflow": workflow.Name, diff --git a/server/forge/gitea/fixtures/handler.go b/server/forge/gitea/fixtures/handler.go index 6f0dbeb14..d6ff48fa1 100644 --- a/server/forge/gitea/fixtures/handler.go +++ b/server/forge/gitea/fixtures/handler.go @@ -125,7 +125,7 @@ func getUserRepos(c *gin.Context) { } func getVersion(c *gin.Context) { - c.JSON(200, map[string]interface{}{"version": "1.18.0"}) + c.JSON(200, map[string]any{"version": "1.18.0"}) } func getPRFiles(c *gin.Context) { diff --git a/server/forge/github/github.go b/server/forge/github/github.go index 54f1dbeeb..bddbe8cf9 100644 --- a/server/forge/github/github.go +++ b/server/forge/github/github.go @@ -525,7 +525,7 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin "pull_request", "deployment", }, - Config: map[string]interface{}{ + Config: map[string]any{ "url": link, "content_type": "form", }, diff --git a/server/forge/mocks/forge.go b/server/forge/mocks/forge.go index e15f9fbe7..ad75c64a1 100644 --- a/server/forge/mocks/forge.go +++ b/server/forge/mocks/forge.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.36.0. DO NOT EDIT. +// Code generated by mockery v2.36.1. DO NOT EDIT. package mocks diff --git a/server/grpc/authorizer.go b/server/grpc/authorizer.go index 3a67461c2..545e8e98e 100644 --- a/server/grpc/authorizer.go +++ b/server/grpc/authorizer.go @@ -58,7 +58,7 @@ func NewAuthorizer(jwtManager *JWTManager) *Authorizer { return &Authorizer{jwtManager: jwtManager} } -func (a *Authorizer) StreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { +func (a *Authorizer) StreamInterceptor(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { _stream := newStreamContextWrapper(stream) newCtx, err := a.authorize(stream.Context(), info.FullMethod) @@ -71,7 +71,7 @@ func (a *Authorizer) StreamInterceptor(srv interface{}, stream grpc.ServerStream return handler(srv, _stream) } -func (a *Authorizer) UnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { +func (a *Authorizer) UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { newCtx, err := a.authorize(ctx, info.FullMethod) if err != nil { return nil, err diff --git a/server/grpc/jwt_manager.go b/server/grpc/jwt_manager.go index 1218f1822..82aa73dda 100644 --- a/server/grpc/jwt_manager.go +++ b/server/grpc/jwt_manager.go @@ -65,7 +65,7 @@ func (manager *JWTManager) Verify(accessToken string) (*AgentTokenClaims, error) token, err := jwt.ParseWithClaims( accessToken, &AgentTokenClaims{}, - func(token *jwt.Token) (interface{}, error) { + func(token *jwt.Token) (any, error) { _, ok := token.Method.(*jwt.SigningMethodHMAC) if !ok { return nil, errors.New("unexpected token signing method") diff --git a/server/plugins/utils/http.go b/server/plugins/utils/http.go index 434b27591..95e504a54 100644 --- a/server/plugins/utils/http.go +++ b/server/plugins/utils/http.go @@ -29,7 +29,7 @@ import ( // Send makes an http request to the given endpoint, writing the input // to the request body and un-marshaling the output from the response body. -func Send(ctx context.Context, method, path string, privateKey crypto.PrivateKey, in, out interface{}) (int, error) { +func Send(ctx context.Context, method, path string, privateKey crypto.PrivateKey, in, out any) (int, error) { uri, err := url.Parse(path) if err != nil { return 0, err diff --git a/server/router/middleware/logger.go b/server/router/middleware/logger.go index 3fefb64f9..5f40a68d8 100644 --- a/server/router/middleware/logger.go +++ b/server/router/middleware/logger.go @@ -42,7 +42,7 @@ func Logger(timeFormat string, utc bool) gin.HandlerFunc { end = end.UTC() } - entry := map[string]interface{}{ + entry := map[string]any{ "status": c.Writer.Status(), "method": c.Request.Method, "path": path, diff --git a/server/store/context.go b/server/store/context.go index 2e63c6e15..02381e513 100644 --- a/server/store/context.go +++ b/server/store/context.go @@ -22,7 +22,7 @@ const key = "store" // Setter defines a context that enables setting values. type Setter interface { - Set(string, interface{}) + Set(string, any) } // FromContext returns the Store associated with this context. diff --git a/server/store/datastore/engine_test.go b/server/store/datastore/engine_test.go index 3f595c93e..a9f422224 100644 --- a/server/store/datastore/engine_test.go +++ b/server/store/datastore/engine_test.go @@ -39,7 +39,7 @@ func testDriverConfig() (driver, config string) { // newTestStore creates a new database connection for testing purposes. // The database driver and connection string are provided by // environment variables, with fallback to in-memory sqlite. -func newTestStore(t *testing.T, tables ...interface{}) (*storage, func()) { +func newTestStore(t *testing.T, tables ...any) (*storage, func()) { engine, err := xorm.NewEngine(testDriverConfig()) if !assert.NoError(t, err) { t.FailNow() diff --git a/server/store/datastore/migration/026_convert_to_new_pipeline_errors_format.go b/server/store/datastore/migration/026_convert_to_new_pipeline_errors_format.go index b55a2f3d8..c52000101 100644 --- a/server/store/datastore/migration/026_convert_to_new_pipeline_errors_format.go +++ b/server/store/datastore/migration/026_convert_to_new_pipeline_errors_format.go @@ -34,10 +34,10 @@ func (pipeline026) TableName() string { } type PipelineError026 struct { - Type string `json:"type"` - Message string `json:"message"` - IsWarning bool `json:"is_warning"` - Data interface{} `json:"data"` + Type string `json:"type"` + Message string `json:"message"` + IsWarning bool `json:"is_warning"` + Data any `json:"data"` } var convertToNewPipelineErrorFormat = task{ diff --git a/server/store/datastore/migration/migration.go b/server/store/datastore/migration/migration.go index 737c4a0a2..e963469e5 100644 --- a/server/store/datastore/migration/migration.go +++ b/server/store/datastore/migration/migration.go @@ -61,7 +61,7 @@ var migrationTasks = []*task{ &convertToNewPipelineErrorFormat, } -var allBeans = []interface{}{ +var allBeans = []any{ new(model.Agent), new(model.Pipeline), new(model.PipelineConfig), @@ -220,7 +220,7 @@ func runTasks(e *xorm.Engine, tasks []*task) error { } type syncEngine interface { - Sync(beans ...interface{}) error + Sync(beans ...any) error } func syncAll(sess syncEngine) error { diff --git a/server/store/datastore/xorm.go b/server/store/datastore/xorm.go index 8e3536901..70e215fc8 100644 --- a/server/store/datastore/xorm.go +++ b/server/store/datastore/xorm.go @@ -37,56 +37,56 @@ type xormLogger struct { } // Error implement ILogger -func (x *xormLogger) Error(v ...interface{}) { +func (x *xormLogger) Error(v ...any) { if x.level <= xlog.LOG_ERR { x.logger.Error().Msg(fmt.Sprintln(v...)) } } // Errorf implement ILogger -func (x *xormLogger) Errorf(format string, v ...interface{}) { +func (x *xormLogger) Errorf(format string, v ...any) { if x.level <= xlog.LOG_ERR { x.logger.Error().Msg(fmt.Sprintf(format, v...)) } } // Debug implement ILogger -func (x *xormLogger) Debug(v ...interface{}) { +func (x *xormLogger) Debug(v ...any) { if x.level <= xlog.LOG_DEBUG { x.logger.Debug().Msg(fmt.Sprintln(v...)) } } // Debugf implement ILogger -func (x *xormLogger) Debugf(format string, v ...interface{}) { +func (x *xormLogger) Debugf(format string, v ...any) { if x.level <= xlog.LOG_DEBUG { x.logger.Debug().Msg(fmt.Sprintf(format, v...)) } } // Info implement ILogger -func (x *xormLogger) Info(v ...interface{}) { +func (x *xormLogger) Info(v ...any) { if x.level <= xlog.LOG_INFO { x.logger.Info().Msg(fmt.Sprintln(v...)) } } // Infof implement ILogger -func (x *xormLogger) Infof(format string, v ...interface{}) { +func (x *xormLogger) Infof(format string, v ...any) { if x.level <= xlog.LOG_INFO { x.logger.Info().Msg(fmt.Sprintf(format, v...)) } } // Warn implement ILogger -func (x *xormLogger) Warn(v ...interface{}) { +func (x *xormLogger) Warn(v ...any) { if x.level <= xlog.LOG_WARNING { x.logger.Warn().Msg(fmt.Sprintln(v...)) } } // Warnf implement ILogger -func (x *xormLogger) Warnf(format string, v ...interface{}) { +func (x *xormLogger) Warnf(format string, v ...any) { if x.level <= xlog.LOG_WARNING { x.logger.Warn().Msg(fmt.Sprintf(format, v...)) } diff --git a/server/store/mocks/store.go b/server/store/mocks/store.go index a5c3e1d20..77a826676 100644 --- a/server/store/mocks/store.go +++ b/server/store/mocks/store.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.36.0. DO NOT EDIT. +// Code generated by mockery v2.36.1. DO NOT EDIT. package mocks diff --git a/server/web/config.go b/server/web/config.go index d95e64bba..dfa2628cb 100644 --- a/server/web/config.go +++ b/server/web/config.go @@ -39,7 +39,7 @@ func Config(c *gin.Context) { ).Sign(user.Hash) } - configData := map[string]interface{}{ + configData := map[string]any{ "user": user, "csrf": csrf, "version": version.String(), @@ -50,7 +50,7 @@ func Config(c *gin.Context) { // default func map with json parser. funcMap := template.FuncMap{ - "json": func(v interface{}) string { + "json": func(v any) string { a, _ := json.Marshal(v) return string(a) }, diff --git a/shared/token/token.go b/shared/token/token.go index f00e7b047..fd0f574c8 100644 --- a/shared/token/token.go +++ b/shared/token/token.go @@ -126,7 +126,7 @@ func (t *Token) SignExpires(secret string, exp int64) (string, error) { } func keyFunc(token *Token, fn SecretFunc) jwt.Keyfunc { - return func(t *jwt.Token) (interface{}, error) { + return func(t *jwt.Token) (any, error) { claims, ok := t.Claims.(jwt.MapClaims) if !ok { return nil, fmt.Errorf("token claim is not a MapClaims") diff --git a/woodpecker-go/woodpecker/client.go b/woodpecker-go/woodpecker/client.go index 133df11b8..e95a3e61d 100644 --- a/woodpecker-go/woodpecker/client.go +++ b/woodpecker-go/woodpecker/client.go @@ -586,17 +586,17 @@ func (c *client) AgentTasksList(agentID int64) ([]*Task, error) { // // helper function for making an http GET request. -func (c *client) get(rawurl string, out interface{}) error { +func (c *client) get(rawurl string, out any) error { return c.do(rawurl, http.MethodGet, nil, out) } // helper function for making an http POST request. -func (c *client) post(rawurl string, in, out interface{}) error { +func (c *client) post(rawurl string, in, out any) error { return c.do(rawurl, http.MethodPost, in, out) } // helper function for making an http PATCH request. -func (c *client) patch(rawurl string, in, out interface{}) error { +func (c *client) patch(rawurl string, in, out any) error { return c.do(rawurl, http.MethodPatch, in, out) } @@ -606,7 +606,7 @@ func (c *client) delete(rawurl string) error { } // helper function to make an http request -func (c *client) do(rawurl, method string, in, out interface{}) error { +func (c *client) do(rawurl, method string, in, out any) error { body, err := c.open(rawurl, method, in) if err != nil { return err @@ -619,7 +619,7 @@ func (c *client) do(rawurl, method string, in, out interface{}) error { } // helper function to open an http request -func (c *client) open(rawurl, method string, in interface{}) (io.ReadCloser, error) { +func (c *client) open(rawurl, method string, in any) (io.ReadCloser, error) { uri, err := url.Parse(rawurl) if err != nil { return nil, err diff --git a/woodpecker-go/woodpecker/types.go b/woodpecker-go/woodpecker/types.go index 6117a0814..be3aa4145 100644 --- a/woodpecker-go/woodpecker/types.go +++ b/woodpecker-go/woodpecker/types.go @@ -61,10 +61,10 @@ type ( } PipelineError struct { - Type string `json:"type"` - Message string `json:"message"` - IsWarning bool `json:"is_warning"` - Data interface{} `json:"data"` + Type string `json:"type"` + Message string `json:"message"` + IsWarning bool `json:"is_warning"` + Data any `json:"data"` } // Pipeline defines a pipeline object.