From bc1eba8fdcefb1b760d78b6df75420c71ca9263a Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 3 Oct 2024 11:27:19 -0500 Subject: [PATCH 01/11] fix(metadata): add missing field to http binding (#3560) Signed-off-by: Samantha Coyle Signed-off-by: Elena Kolevska --- bindings/http/metadata.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/http/metadata.yaml b/bindings/http/metadata.yaml index 229da21e67..f6b77cb68e 100644 --- a/bindings/http/metadata.yaml +++ b/bindings/http/metadata.yaml @@ -75,3 +75,7 @@ metadata: required: false description: "The header name on an outgoing HTTP request for a security token" example: '"X-Security-Token"' + - name: errorIfNot2XX + required: false + default: 'true' + description: "Create an error if a non-2XX status code is returned" From 106b1083620c8dc038b7ce2dbb6deb18f864af94 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 8 Oct 2024 12:30:57 -0500 Subject: [PATCH 02/11] fix(metadata): make access/secret keys optional (#3562) Signed-off-by: Samantha Coyle Signed-off-by: Elena Kolevska --- common/authentication/postgresql/metadata.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/common/authentication/postgresql/metadata.go b/common/authentication/postgresql/metadata.go index 708b70b62b..ce86ca2eee 100644 --- a/common/authentication/postgresql/metadata.go +++ b/common/authentication/postgresql/metadata.go @@ -91,14 +91,10 @@ func (m *PostgresAuthMetadata) ValidateAwsIamFields() (string, string, string, e if awsRegion == "" { return "", "", "", errors.New("metadata property AWSRegion is missing") } + // Note: access key and secret keys can be optional + // in the event users are leveraging the credential files for an access token. awsAccessKey, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "AWSAccessKey") - if awsAccessKey == "" { - return "", "", "", errors.New("metadata property AWSAccessKey is missing") - } awsSecretKey, _ := metadata.GetMetadataProperty(m.awsEnv.Metadata, "AWSSecretKey") - if awsSecretKey == "" { - return "", "", "", errors.New("metadata property AWSSecretKey is missing") - } return awsRegion, awsAccessKey, awsSecretKey, nil } From a6824ab678a70d702149164fb01d651b8a9e1f5e Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Thu, 10 Oct 2024 06:50:37 -0700 Subject: [PATCH 03/11] Add AWS Bedrock support (#3563) Signed-off-by: yaron2 Signed-off-by: Artur Souza Co-authored-by: yaron2 Signed-off-by: Elena Kolevska --- .build-tools/go.mod | 2 +- common/authentication/aws/aws.go | 24 ++ conversation/aws/bedrock/bedrock.go | 147 ++++++++++++ conversation/aws/bedrock/bedrock_test.go | 25 ++ conversation/aws/bedrock/metadata.yaml | 26 +++ conversation/converse.go | 17 +- conversation/echo/echo.go | 4 +- conversation/echo/echo_test.go | 28 +++ conversation/openai/metadata.yaml | 29 +++ conversation/openai/openai.go | 57 ++++- conversation/openai/openai_test.go | 26 +++ go.mod | 104 +++++---- go.sum | 217 ++++++++++-------- metadata/utils.go | 1 + tests/certification/go.mod | 64 +++--- tests/certification/go.sum | 140 +++++------ tests/config/conversation/echo/echo.yml | 9 + tests/config/conversation/tests.yml | 4 + .../conformance/conversation/conversation.go | 73 ++++++ tests/conformance/conversation_test.go | 61 +++++ tests/e2e/pubsub/jetstream/go.mod | 4 +- tests/e2e/pubsub/jetstream/go.sum | 4 +- 22 files changed, 805 insertions(+), 261 deletions(-) create mode 100644 conversation/aws/bedrock/bedrock.go create mode 100644 conversation/aws/bedrock/bedrock_test.go create mode 100644 conversation/aws/bedrock/metadata.yaml create mode 100644 conversation/echo/echo_test.go create mode 100644 conversation/openai/metadata.yaml create mode 100644 conversation/openai/openai_test.go create mode 100644 tests/config/conversation/echo/echo.yml create mode 100644 tests/config/conversation/tests.yml create mode 100644 tests/conformance/conversation/conversation.go create mode 100644 tests/conformance/conversation_test.go diff --git a/.build-tools/go.mod b/.build-tools/go.mod index 407efb8ad5..2e2638a83f 100644 --- a/.build-tools/go.mod +++ b/.build-tools/go.mod @@ -1,6 +1,6 @@ module github.com/dapr/components-contrib/build-tools -go 1.23 +go 1.23.0 require ( github.com/dapr/components-contrib v0.0.0 diff --git a/common/authentication/aws/aws.go b/common/authentication/aws/aws.go index 2d08648ea1..26d4c9fe63 100644 --- a/common/authentication/aws/aws.go +++ b/common/authentication/aws/aws.go @@ -20,6 +20,7 @@ import ( "strconv" "time" + awsv2 "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" v2creds "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/feature/rds/auth" @@ -37,6 +38,29 @@ type EnvironmentSettings struct { Metadata map[string]string } +func GetConfigV2(accessKey string, secretKey string, sessionToken string, region string, endpoint string) (awsv2.Config, error) { + optFns := []func(*config.LoadOptions) error{} + if region != "" { + optFns = append(optFns, config.WithRegion(region)) + } + + if accessKey != "" && secretKey != "" { + provider := v2creds.NewStaticCredentialsProvider(accessKey, secretKey, sessionToken) + optFns = append(optFns, config.WithCredentialsProvider(provider)) + } + + awsCfg, err := config.LoadDefaultConfig(context.Background(), optFns...) + if err != nil { + return awsv2.Config{}, err + } + + if endpoint != "" { + awsCfg.BaseEndpoint = &endpoint + } + + return awsCfg, nil +} + func GetClient(accessKey string, secretKey string, sessionToken string, region string, endpoint string) (*session.Session, error) { awsConfig := aws.NewConfig() diff --git a/conversation/aws/bedrock/bedrock.go b/conversation/aws/bedrock/bedrock.go new file mode 100644 index 0000000000..9fbf805d5f --- /dev/null +++ b/conversation/aws/bedrock/bedrock.go @@ -0,0 +1,147 @@ +/* +Copyright 2024 The Dapr 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 bedrock + +import ( + "context" + "reflect" + + awsAuth "github.com/dapr/components-contrib/common/authentication/aws" + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/components-contrib/metadata" + "github.com/dapr/kit/logger" + kmeta "github.com/dapr/kit/metadata" + + "github.com/aws/aws-sdk-go-v2/service/bedrockruntime" + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/bedrock" +) + +type AWSBedrock struct { + model string + llm *bedrock.LLM + + logger logger.Logger +} + +type AWSBedrockMetadata struct { + Region string `json:"region"` + Endpoint string `json:"endpoint"` + AccessKey string `json:"accessKey"` + SecretKey string `json:"secretKey"` + SessionToken string `json:"sessionToken"` + Model string `json:"model"` +} + +func NewAWSBedrock(logger logger.Logger) conversation.Conversation { + b := &AWSBedrock{ + logger: logger, + } + + return b +} + +func convertRole(role conversation.Role) llms.ChatMessageType { + switch role { + case conversation.RoleSystem: + return llms.ChatMessageTypeSystem + case conversation.RoleUser: + return llms.ChatMessageTypeHuman + case conversation.RoleAssistant: + return llms.ChatMessageTypeAI + case conversation.RoleTool: + return llms.ChatMessageTypeTool + case conversation.RoleFunction: + return llms.ChatMessageTypeFunction + default: + return llms.ChatMessageTypeHuman + } +} + +func (b *AWSBedrock) Init(ctx context.Context, meta conversation.Metadata) error { + m := AWSBedrockMetadata{} + err := kmeta.DecodeMetadata(meta.Properties, &m) + if err != nil { + return err + } + + awsConfig, err := awsAuth.GetConfigV2(m.AccessKey, m.SecretKey, m.SessionToken, m.Region, m.Endpoint) + if err != nil { + return err + } + + bedrockClient := bedrockruntime.NewFromConfig(awsConfig) + + opts := []bedrock.Option{bedrock.WithClient(bedrockClient)} + if m.Model != "" { + opts = append(opts, bedrock.WithModel(m.Model)) + } + b.model = m.Model + + llm, err := bedrock.New( + opts..., + ) + if err != nil { + return err + } + + b.llm = llm + return nil +} + +func (b *AWSBedrock) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { + metadataStruct := AWSBedrockMetadata{} + metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) + return +} + +func (b *AWSBedrock) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) { + messages := make([]llms.MessageContent, 0, len(r.Inputs)) + + for _, input := range r.Inputs { + role := convertRole(input.Role) + + messages = append(messages, llms.MessageContent{ + Role: role, + Parts: []llms.ContentPart{ + llms.TextPart(input.Message), + }, + }) + } + + resp, err := b.llm.GenerateContent(ctx, messages) + if err != nil { + return nil, err + } + + outputs := make([]conversation.ConversationResult, 0, len(resp.Choices)) + + for i := range resp.Choices { + outputs = append(outputs, conversation.ConversationResult{ + Result: resp.Choices[i].Content, + Parameters: r.Parameters, + }) + } + + res = &conversation.ConversationResponse{ + Outputs: outputs, + } + + return res, nil +} + +func (b *AWSBedrock) Close() error { + return nil +} diff --git a/conversation/aws/bedrock/bedrock_test.go b/conversation/aws/bedrock/bedrock_test.go new file mode 100644 index 0000000000..63bda0187f --- /dev/null +++ b/conversation/aws/bedrock/bedrock_test.go @@ -0,0 +1,25 @@ +package bedrock + +import ( + "testing" + + "github.com/dapr/components-contrib/conversation" + + "github.com/stretchr/testify/assert" + "github.com/tmc/langchaingo/llms" +) + +func TestConvertRole(t *testing.T) { + roles := map[string]string{ + conversation.RoleSystem: string(llms.ChatMessageTypeSystem), + conversation.RoleAssistant: string(llms.ChatMessageTypeAI), + conversation.RoleFunction: string(llms.ChatMessageTypeFunction), + conversation.RoleUser: string(llms.ChatMessageTypeHuman), + conversation.RoleTool: string(llms.ChatMessageTypeTool), + } + + for k, v := range roles { + r := convertRole(conversation.Role(k)) + assert.Equal(t, v, string(r)) + } +} diff --git a/conversation/aws/bedrock/metadata.yaml b/conversation/aws/bedrock/metadata.yaml new file mode 100644 index 0000000000..56c764845b --- /dev/null +++ b/conversation/aws/bedrock/metadata.yaml @@ -0,0 +1,26 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: conversation +name: aws.bedrock +version: v1 +status: alpha +title: "AWS Bedrock" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-conversation/setup-aws-bedrock/ +builtinAuthenticationProfiles: + - name: "aws" +metadata: + - name: endpoint + required: false + description: | + AWS endpoint for the component to use, to connect to emulators. + Do not use this when running against production AWS. + example: '"http://localhost:4566"' + type: string + - name: model + required: false + description: | + The LLM to use. Defaults to Bedrock's default provider model from Amazon. + type: string + example: 'amazon.titan-text-express-v1' diff --git a/conversation/converse.go b/conversation/converse.go index df03453437..16fce9f6d6 100644 --- a/conversation/converse.go +++ b/conversation/converse.go @@ -33,8 +33,13 @@ type Conversation interface { io.Closer } +type ConversationInput struct { + Message string `json:"string"` + Role Role `json:"role"` +} + type ConversationRequest struct { - Inputs []string `json:"inputs"` + Inputs []ConversationInput `json:"inputs"` Parameters map[string]*anypb.Any `json:"parameters"` ConversationContext string `json:"conversationContext"` @@ -54,3 +59,13 @@ type ConversationResponse struct { ConversationContext string `json:"conversationContext"` Outputs []ConversationResult `json:"outputs"` } + +type Role string + +const ( + RoleSystem = "system" + RoleUser = "user" + RoleAssistant = "assistant" + RoleFunction = "function" + RoleTool = "tool" +) diff --git a/conversation/echo/echo.go b/conversation/echo/echo.go index fae148e3e3..f9131a09f0 100644 --- a/conversation/echo/echo.go +++ b/conversation/echo/echo.go @@ -40,7 +40,7 @@ func NewEcho(logger logger.Logger) conversation.Conversation { func (e *Echo) Init(ctx context.Context, meta conversation.Metadata) error { r := &conversation.ConversationRequest{} - err := kmeta.DecodeMetadata(meta.Properties, &r) + err := kmeta.DecodeMetadata(meta.Properties, r) if err != nil { return err } @@ -62,7 +62,7 @@ func (e *Echo) Converse(ctx context.Context, r *conversation.ConversationRequest for _, input := range r.Inputs { outputs = append(outputs, conversation.ConversationResult{ - Result: input, + Result: input.Message, Parameters: r.Parameters, }) } diff --git a/conversation/echo/echo_test.go b/conversation/echo/echo_test.go new file mode 100644 index 0000000000..77d8cc57c4 --- /dev/null +++ b/conversation/echo/echo_test.go @@ -0,0 +1,28 @@ +package echo + +import ( + "context" + "testing" + + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/kit/logger" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestConverse(t *testing.T) { + e := NewEcho(logger.NewLogger("echo test")) + e.Init(context.Background(), conversation.Metadata{}) + + r, err := e.Converse(context.Background(), &conversation.ConversationRequest{ + Inputs: []conversation.ConversationInput{ + { + Message: "hello", + }, + }, + }) + require.NoError(t, err) + assert.Len(t, r.Outputs, 1) + assert.Equal(t, "hello", r.Outputs[0].Result) +} diff --git a/conversation/openai/metadata.yaml b/conversation/openai/metadata.yaml new file mode 100644 index 0000000000..dfe1abbeb0 --- /dev/null +++ b/conversation/openai/metadata.yaml @@ -0,0 +1,29 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: conversation +name: openai +version: v1 +status: alpha +title: "OpenAI" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-conversation/setup-openai/ +authenticationProfiles: + - title: "API Key" + description: "Authenticate using an API key" + metadata: + - name: key + type: string + required: true + sensitive: true + description: | + API key for OpenAI. + example: "**********" + default: "" +metadata: + - name: model + required: false + description: | + The OpenAI LLM to use. Defaults to gpt-4o + type: string + example: 'gpt-4-turbo' diff --git a/conversation/openai/openai.go b/conversation/openai/openai.go index e967f2c6e2..02606aca28 100644 --- a/conversation/openai/openai.go +++ b/conversation/openai/openai.go @@ -26,8 +26,10 @@ import ( openai "github.com/sashabaranov/go-openai" ) +const defaultModel = "gpt-4o" + type OpenAI struct { - cilent *openai.Client + client *openai.Client model string logger logger.Logger @@ -43,32 +45,68 @@ func NewOpenAI(logger logger.Logger) conversation.Conversation { func (o *OpenAI) Init(ctx context.Context, meta conversation.Metadata) error { r := &conversation.ConversationRequest{} - err := kmeta.DecodeMetadata(meta.Properties, &r) + err := kmeta.DecodeMetadata(meta.Properties, r) if err != nil { return err } - o.cilent = openai.NewClient(r.Key) + o.client = openai.NewClient(r.Key) o.model = r.Model + if o.model == "" { + o.model = defaultModel + } + return nil } func (o *OpenAI) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { metadataStruct := conversation.ConversationRequest{} - metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.StateStoreType) + metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) return } +func convertRole(role conversation.Role) string { + switch role { + case conversation.RoleSystem: + return string(openai.ChatMessageRoleSystem) + case conversation.RoleUser: + return string(openai.ChatMessageRoleUser) + case conversation.RoleAssistant: + return string(openai.ChatMessageRoleAssistant) + case conversation.RoleTool: + return string(openai.ChatMessageRoleTool) + case conversation.RoleFunction: + return string(openai.ChatMessageRoleFunction) + default: + return string(openai.ChatMessageRoleUser) + } +} + func (o *OpenAI) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) { // Note: OPENAI does not support load balance - messages := make([]openai.ChatCompletionMessage, 0, len(r.Inputs)) + var systemPrompt string + for _, input := range r.Inputs { + role := convertRole(input.Role) + if role == openai.ChatMessageRoleSystem { + systemPrompt = input.Message + continue + } + messages = append(messages, openai.ChatCompletionMessage{ - Role: openai.ChatMessageRoleUser, - Content: input, + Role: role, + Content: input.Message, + }) + } + + // OpenAI needs system prompts to be added last in the array to function properly + if systemPrompt != "" { + messages = append(messages, openai.ChatCompletionMessage{ + Role: openai.ChatMessageRoleSystem, + Content: systemPrompt, }) } @@ -78,15 +116,12 @@ func (o *OpenAI) Converse(ctx context.Context, r *conversation.ConversationReque } // TODO: support ConversationContext - - resp, err := o.cilent.CreateChatCompletion(ctx, req) + resp, err := o.client.CreateChatCompletion(ctx, req) if err != nil { o.logger.Error(err) return nil, err } - o.logger.Debug(resp) - outputs := make([]conversation.ConversationResult, 0, len(resp.Choices)) for i := range resp.Choices { diff --git a/conversation/openai/openai_test.go b/conversation/openai/openai_test.go new file mode 100644 index 0000000000..19b0ab085b --- /dev/null +++ b/conversation/openai/openai_test.go @@ -0,0 +1,26 @@ +package openai + +import ( + "testing" + + "github.com/dapr/components-contrib/conversation" + + "github.com/stretchr/testify/assert" + + openai "github.com/sashabaranov/go-openai" +) + +func TestConvertRole(t *testing.T) { + roles := map[string]string{ + conversation.RoleSystem: string(openai.ChatMessageRoleSystem), + conversation.RoleAssistant: string(openai.ChatMessageRoleAssistant), + conversation.RoleFunction: string(openai.ChatMessageRoleFunction), + conversation.RoleUser: string(openai.ChatMessageRoleUser), + conversation.RoleTool: string(openai.ChatMessageRoleTool), + } + + for k, v := range roles { + r := convertRole(conversation.Role(k)) + assert.Equal(t, v, r) + } +} diff --git a/go.mod b/go.mod index 7b46ad4873..037e257b23 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/dapr/components-contrib -go 1.23 +go 1.23.0 require ( cloud.google.com/go/datastore v1.15.0 - cloud.google.com/go/pubsub v1.36.1 - cloud.google.com/go/secretmanager v1.11.5 - cloud.google.com/go/storage v1.38.0 + cloud.google.com/go/pubsub v1.37.0 + cloud.google.com/go/secretmanager v1.12.0 + cloud.google.com/go/storage v1.40.0 dubbo.apache.org/dubbo-go/v3 v3.0.3-0.20230118042253-4f159a2b38f3 github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai v0.6.0 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 @@ -41,10 +41,11 @@ require ( github.com/apache/thrift v0.13.0 github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 github.com/aws/aws-sdk-go v1.50.19 - github.com/aws/aws-sdk-go-v2 v1.25.0 - github.com/aws/aws-sdk-go-v2/config v1.18.28 - github.com/aws/aws-sdk-go-v2/credentials v1.13.27 + github.com/aws/aws-sdk-go-v2 v1.31.0 + github.com/aws/aws-sdk-go-v2/config v1.27.39 + github.com/aws/aws-sdk-go-v2/credentials v1.17.37 github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.3.10 + github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.17.3 github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 github.com/camunda/zeebe/clients/go/v8 v8.2.12 github.com/cenkalti/backoff/v4 v4.2.1 @@ -66,7 +67,7 @@ require ( github.com/gocql/gocql v1.5.2 github.com/golang/mock v1.6.0 github.com/google/uuid v1.6.0 - github.com/googleapis/gax-go/v2 v2.12.2 + github.com/googleapis/gax-go/v2 v2.12.4 github.com/gorilla/mux v1.8.1 github.com/grandcat/zeroconf v1.0.0 github.com/hamba/avro/v2 v2.20.1 @@ -111,11 +112,12 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.732 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssm v1.0.732 github.com/tetratelabs/wazero v1.7.0 + github.com/tmc/langchaingo v0.1.12 github.com/valyala/fasthttp v1.49.0 github.com/vmware/vmware-go-kcl v1.5.1 github.com/xdg-go/scram v1.1.2 go.etcd.io/etcd/client/v3 v3.5.9 - go.mongodb.org/mongo-driver v1.12.1 + go.mongodb.org/mongo-driver v1.14.0 go.uber.org/goleak v1.2.1 go.uber.org/multierr v1.11.0 go.uber.org/ratelimit v0.3.0 @@ -123,10 +125,10 @@ require ( golang.org/x/exp v0.0.0-20240119083558-1b970713d09a golang.org/x/mod v0.17.0 golang.org/x/net v0.26.0 - golang.org/x/oauth2 v0.18.0 - google.golang.org/api v0.169.0 + golang.org/x/oauth2 v0.20.0 + google.golang.org/api v0.180.0 google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.34.1 gopkg.in/couchbase/gocb.v1 v1.6.7 gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/yaml.v3 v3.0.1 @@ -140,10 +142,11 @@ require ( ) require ( - cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute v1.25.1 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.6 // indirect + cloud.google.com/go v0.113.0 // indirect + cloud.google.com/go/auth v0.4.1 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect + cloud.google.com/go/iam v1.1.7 // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -172,16 +175,18 @@ require ( github.com/apache/rocketmq-client-go v1.2.5 // indirect github.com/ardielle/ardielle-go v1.5.2 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 // indirect - github.com/aws/smithy-go v1.20.0 // indirect + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 // indirect + github.com/aws/smithy-go v1.21.0 // indirect github.com/awslabs/kinesis-aggregation/go v0.0.0-20210630091500-54e17340d32f // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -206,6 +211,7 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/deepmap/oapi-codegen v1.11.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/dlclark/regexp2 v1.10.0 // indirect github.com/dubbogo/gost v1.13.1 // indirect github.com/dubbogo/triple v1.1.8 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -215,7 +221,7 @@ require ( github.com/eapache/queue v1.1.0 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/emirpasic/gods v1.12.0 // indirect - github.com/fatih/color v1.15.0 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gavv/httpexpect v2.0.0+incompatible // indirect @@ -227,9 +233,9 @@ require ( github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect - github.com/go-openapi/swag v0.21.1 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect github.com/go-pkgz/expirable-cache v0.1.0 // indirect github.com/go-playground/locales v0.14.0 // indirect @@ -251,10 +257,9 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/flatbuffers v2.0.8+incompatible // indirect + github.com/google/flatbuffers v23.5.26+incompatible // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 // indirect github.com/google/s2a-go v0.1.7 // indirect @@ -300,13 +305,12 @@ require ( github.com/lestrrat-go/iter v1.0.2 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect - github.com/magiconair/properties v1.8.6 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/matryer/is v1.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/microcosm-cc/bluemonday v1.0.21 // indirect github.com/miekg/dns v1.1.43 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -325,11 +329,11 @@ require ( github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/panjf2000/ants/v2 v2.8.1 // indirect github.com/pelletier/go-toml v1.9.5 // indirect - github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/pierrec/lz4 v2.6.0+incompatible // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pkoukk/tiktoken-go v0.1.6 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/prometheus/client_golang v1.16.0 // indirect @@ -339,13 +343,14 @@ require ( github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/rs/zerolog v1.28.0 // indirect + github.com/rs/zerolog v1.31.0 // indirect github.com/russross/blackfriday v1.6.0 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect github.com/segmentio/asm v1.2.0 // indirect github.com/sendgrid/rest v2.6.9+incompatible // indirect github.com/sergi/go-diff v1.2.0 // indirect - github.com/shirou/gopsutil/v3 v3.22.2 // indirect + github.com/shirou/gopsutil/v3 v3.23.12 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sony/gobreaker v0.5.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -353,12 +358,12 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/tchap/go-patricia/v2 v2.3.1 // indirect - github.com/tidwall/gjson v1.13.0 // indirect + github.com/tidwall/gjson v1.14.4 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tjfoc/gmsm v1.3.2 // indirect - github.com/tklauser/go-sysconf v0.3.10 // indirect - github.com/tklauser/numcpus v0.4.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect @@ -370,18 +375,18 @@ require ( github.com/yudai/gojsondiff v1.0.0 // indirect github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yuin/gopher-lua v1.1.0 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect go.etcd.io/etcd/api/v3 v3.5.9 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect + go.opentelemetry.io/otel v1.26.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/sdk v1.22.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.26.0 // indirect + go.opentelemetry.io/otel/sdk v1.26.0 // indirect + go.opentelemetry.io/otel/trace v1.26.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/arch v0.10.0 // indirect @@ -391,10 +396,9 @@ require ( golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434 // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/couchbase/gocbcore.v7 v7.1.18 // indirect gopkg.in/couchbaselabs/gocbconnstr.v1 v1.0.4 // indirect diff --git a/go.sum b/go.sum index c2604ff6ec..e33df61840 100644 --- a/go.sum +++ b/go.sum @@ -13,42 +13,44 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= -cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= +cloud.google.com/go v0.113.0 h1:g3C70mn3lWfckKBiCVsAshabrDg01pQ0pnX1MNtnMkA= +cloud.google.com/go v0.113.0/go.mod h1:glEqlogERKYeePz6ZdkcLJ28Q2I6aERgDDErBg9GzO8= +cloud.google.com/go/auth v0.4.1 h1:Z7YNIhlWRtrnKlZke7z3GMqzvuYzdc2z98F9D1NV5Hg= +cloud.google.com/go/auth v0.4.1/go.mod h1:QVBuVEKpCn4Zp58hzRGvL0tjRGU0YqdRTdCHM1IHnro= +cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= +cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU= -cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/datastore v1.15.0 h1:0P9WcsQeTWjuD1H14JIY7XQscIPQ4Laje8ti96IC5vg= cloud.google.com/go/datastore v1.15.0/go.mod h1:GAeStMBIt9bPS7jMJA85kgkpsMkvseWWXiaHya9Jes8= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc= -cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= -cloud.google.com/go/kms v1.15.7 h1:7caV9K3yIxvlQPAcaFffhlT7d1qpxjB1wHBtjWa13SM= -cloud.google.com/go/kms v1.15.7/go.mod h1:ub54lbsa6tDkUwnu4W7Yt1aAIFLnspgh0kPGToDukeI= +cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM= +cloud.google.com/go/iam v1.1.7/go.mod h1:J4PMPg8TtyurAUvSmPj8FF3EDgY1SPRZxcUGrn7WXGA= +cloud.google.com/go/kms v1.15.8 h1:szIeDCowID8th2i8XE4uRev5PMxQFqW+JjwYxL9h6xs= +cloud.google.com/go/kms v1.15.8/go.mod h1:WoUHcDjD9pluCg7pNds131awnH429QGvRM3N/4MyoVs= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.36.1 h1:dfEPuGCHGbWUhaMCTHUFjfroILEkx55iUmKBZTP5f+Y= -cloud.google.com/go/pubsub v1.36.1/go.mod h1:iYjCa9EzWOoBiTdd4ps7QoMtMln5NwaZQpK1hbRfBDE= -cloud.google.com/go/secretmanager v1.11.5 h1:82fpF5vBBvu9XW4qj0FU2C6qVMtj1RM/XHwKXUEAfYY= -cloud.google.com/go/secretmanager v1.11.5/go.mod h1:eAGv+DaCHkeVyQi0BeXgAHOU0RdrMeZIASKc+S7VqH4= +cloud.google.com/go/pubsub v1.37.0 h1:0uEEfaB1VIJzabPpwpZf44zWAKAme3zwKKxHk7vJQxQ= +cloud.google.com/go/pubsub v1.37.0/go.mod h1:YQOQr1uiUM092EXwKs56OPT650nwnawc+8/IjoUeGzQ= +cloud.google.com/go/secretmanager v1.12.0 h1:e5pIo/QEgiFiHPVJPxM5jbtUr4O/u5h2zLHYtkFQr24= +cloud.google.com/go/secretmanager v1.12.0/go.mod h1:Y1Gne3Ag+fZ2TDTiJc8ZJCMFbi7k1rYT4Rw30GXfvlk= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.38.0 h1:Az68ZRGlnNTpIBbLjSMIV2BDcwwXYlRlQzis0llkpJg= -cloud.google.com/go/storage v1.38.0/go.mod h1:tlUADB0mAb9BgYls9lq+8MGkfzOXuLrnHXlpHmvFJoY= +cloud.google.com/go/storage v1.40.0 h1:VEpDQV5CJxFmJ6ueWNsKxcr1QAYOXEgxDa+sBbJahPw= +cloud.google.com/go/storage v1.40.0/go.mod h1:Rrj7/hKlG87BLqDJYtwR0fbPld8uJPbQ2ucUMY7Ir0g= contrib.go.opencensus.io/exporter/prometheus v0.4.1/go.mod h1:t9wvfitlUjGXG2IXAZsuFq26mDGid/JwCEXp+gTG/9U= contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ= @@ -234,8 +236,9 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= +github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 h1:UyjtGmO0Uwl/K+zpzPwLoXzMhcN9xmnR2nrqJoBrg3c= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0/go.mod h1:TJAXuFs2HcMib3sN5L0gUC+Q01Qvy3DemvA55WuC+iA= @@ -246,43 +249,47 @@ github.com/aws/aws-sdk-go v1.50.19 h1:YSIDKRSkh/TW0RPWoocdLqtC/T5W6IGBVhFs6P7Qca github.com/aws/aws-sdk-go v1.50.19/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= -github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.25.0 h1:sv7+1JVJxOu/dD/sz/csHX7jFqmP001TIY7aytBWDSQ= -github.com/aws/aws-sdk-go-v2 v1.25.0/go.mod h1:G104G1Aho5WqF+SR3mDIobTABQzpYV0WxMsKxlMggOA= +github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72QmG5U= +github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5 h1:xDAuZTn4IMm8o1LnBZvmrL8JA1io4o3YWNXgohbf20g= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.5/go.mod h1:wYSv6iDS621sEFLfKvpPE2ugjTuGlAG7iROg0hLOkfc= github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= -github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= -github.com/aws/aws-sdk-go-v2/config v1.18.28/go.mod h1:nIL+4/8JdAuNHEjn/gPEXqtnS02Q3NXB/9Z7o5xE4+A= +github.com/aws/aws-sdk-go-v2/config v1.27.39 h1:FCylu78eTGzW1ynHcongXK9YHtoXD5AiiUqq3YfJYjU= +github.com/aws/aws-sdk-go-v2/config v1.27.39/go.mod h1:wczj2hbyskP4LjMKBEZwPRO1shXY+GsQleab+ZXT2ik= github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= -github.com/aws/aws-sdk-go-v2/credentials v1.13.27 h1:dz0yr/yR1jweAnsCx+BmjerUILVPQ6FS5AwF/OyG1kA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.27/go.mod h1:syOqAek45ZXZp29HlnRS/BNgMIW6uiRmeuQsz4Qh2UE= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37 h1:G2aOH01yW8X373JK419THj5QVqu9vKEwxSEsGxihoW0= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37/go.mod h1:0ecCjlb7htYCptRD45lXJ6aJDQac6D2NlKGpZqyTG6A= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 h1:kP3Me6Fy3vdi+9uHd7YLr6ewPxRL+PU6y15urfTaamU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5/go.mod h1:Gj7tm95r+QsDoN2Fhuz/3npQvcZbkEf5mL70n3Xfluc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 h1:C/d03NAmh8C4BZXhuRNboF/DqhBkBCeDiJDcaqIT5pA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14/go.mod h1:7I0Ju7p9mCIdlrfS+JCgqcYD0VXz/N4yozsox+0o078= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.3.10 h1:z6fAXB4HSuYjrE/P8RU3NdCaN+EPaeq/+80aisCjuF8= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.3.10/go.mod h1:PoPjOi7j+/DtKIGC58HRfcdWKBPYYXwdKnRG+po+hzo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 h1:hMUCiE3Zi5AHrRNGf5j985u0WyqI6r2NULhUfo0N/No= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35/go.mod h1:ipR5PvpSPqIqL5Mi82BxLnfMkHVbmco8kUwO2xrCi0M= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 h1:yOpYx+FTBdpk/g+sBU6Cb1H0U/TLEcYYp66mYqsPpcc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29/go.mod h1:M/eUABlDbw2uVrdAn+UsI6M727qp2fxkp8K0ejcBDUY= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 h1:kYQ3H1u0ANr9KEKlGs/jTLrBFPo8P8NaH/w7A01NeeM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18/go.mod h1:r506HmK5JDUh9+Mw4CfGJGSSoqIiLCndAuqXuhbv67Y= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 h1:Z7IdFUONvTcvS7YuhtVxN99v2cCoHRXOS4mTr0B/pUc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18/go.mod h1:DkKMmksZVVyat+Y+r1dEOgJEfUeA7UngIHWeKsi0yNc= github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 h1:8r5m1BoAWkn0TDC34lUculryf7nUF25EgIMdjvGCkgo= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36/go.mod h1:Rmw2M1hMVTwiUhjwMoIBFWFJMhvJbct06sSidxInkhY= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= github.com/aws/aws-sdk-go-v2/service/appconfig v1.4.2/go.mod h1:FZ3HkCe+b10uFZZkFdvf98LHW21k49W8o8J366lqVKY= +github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.17.3 h1:PtP2Zzf3uy94EsVOW+tB7gNt63fFZEHuS9IRWg5q250= +github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.17.3/go.mod h1:4zuvYEUJm0Vq8tb3gcb2sl04A9I1AA5DKAefbYPA4VM= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 h1:QFASJGfT8wMXtuP3D5CRmMjARHv9ZmzFUMJznHDOY3w= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5/go.mod h1:QdZ3OmoIjSX+8D1OPAzPxDfjXASbBMDsz9qvtyIhtik= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 h1:IiDolu/eLmuB18DRZibj77n1hHQT7z12jnGO7Ze3pLc= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29/go.mod h1:fDbkK4o7fpPXWn8YAPmTieAMuB9mk/VgvW64uaUqxd4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 h1:Xbwbmk44URTiHNx6PNo0ujDE6ERlsCKJD3u1zfnzAPg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20/go.mod h1:oAfOFzUB14ltPZj1rWwRc3d/6OgD76R8KlvU3EqM9Fg= github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 h1:sWDv7cMITPcZ21QdreULwxOOAmE05JjEsT6fCDtDA9k= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.13/go.mod h1:DfX0sWuT46KpcqbMhJ9QWtxAIP1VozkDWf8VAkByjYY= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 h1:BFubHS/xN5bjl818QaroN6mQdjneYQ+AOx44KNXlyH4= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13/go.mod h1:BzqsVVFduubEmzrVtUFQQIQdFqvUItF8XUq2EnS8Wog= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 h1:rs4JCczF805+FDv2tRhZ1NU0RB2H6ryAvsWPanAr72Y= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3/go.mod h1:XRlMvmad0ZNL+75C5FYdMvbbLkd6qiqz6foR1nA1PXY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3 h1:S7EPdMVZod8BGKQQPTBK+FcX9g7bKR7c4+HxWqHP7Vg= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3/go.mod h1:FnvDM4sfa+isJ3kDXIzAB9GAwVSzFzSy97uZ3IsHo4E= github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 h1:e5mnydVdCVWxP+5rPAGi2PYxC7u2OZgH1ypC114H04U= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.3/go.mod h1:yVGZA1CPkmUhBdA039jXNJJG7/6t+G+EBWmFq23xqnY= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 h1:VzudTFrDCIDakXtemR7l6Qzt2+JYsVqo2MxBPt5k8T8= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3/go.mod h1:yMWe0F+XG0DkRZK5ODZhG7BEFYhLXi2dqGsv6tX0cgI= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.20.0 h1:6+kZsCXZwKxZS9RfISnPc4EXlHoyAkm2hPuM8X2BrrQ= -github.com/aws/smithy-go v1.20.0/go.mod h1:uo5RKksAl4PzhqaAbjd4rLgFoq5koTsQKYuGe7dklGc= +github.com/aws/smithy-go v1.21.0 h1:H7L8dtDRk0P1Qm6y0ji7MCYMQObJ5R9CRpyPhRUkLYA= +github.com/aws/smithy-go v1.21.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/awslabs/kinesis-aggregation/go v0.0.0-20210630091500-54e17340d32f h1:Pf0BjJDga7C98f0vhw+Ip5EaiE07S3lTKpIYPNS0nMo= github.com/awslabs/kinesis-aggregation/go v0.0.0-20210630091500-54e17340d32f/go.mod h1:SghidfnxvX7ribW6nHI7T+IBbc9puZ9kk5Tx/88h8P4= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= @@ -439,7 +446,6 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -486,6 +492,8 @@ github.com/didip/tollbooth/v7 v7.0.1 h1:TkT4sBKoQoHQFPf7blQ54iHrZiTDnr8TceU+MulV github.com/didip/tollbooth/v7 v7.0.1/go.mod h1:VZhDSGl5bDSPj4wPsih3PFa4Uh9Ghv8hgacaTm5PRT4= github.com/dimfeld/httptreemux v5.0.1+incompatible h1:Qj3gVcDNoOthBAqftuD596rm4wg/adLLz5xh5CmpiCA= github.com/dimfeld/httptreemux v5.0.1+incompatible/go.mod h1:rbUlSV+CCpv/SuqUTP/8Bk2O3LyUV436/yaRGkhP6Z0= +github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= +github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= @@ -544,8 +552,8 @@ github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwo github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -620,13 +628,16 @@ github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNI github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.21.1 h1:wm0rhTb5z7qpJRHBdPOMuY4QjVUMbF6/kwoYeRAOrKU= github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es= github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= @@ -753,8 +764,8 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/flatbuffers v1.11.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= -github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM= -github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= +github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -782,8 +793,8 @@ github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= -github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= +github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -808,8 +819,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA= -github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= +github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw4Z96qg= +github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0= @@ -1108,8 +1119,9 @@ github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0Q github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo= github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= @@ -1138,11 +1150,12 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= +github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -1302,8 +1315,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0= +github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= @@ -1324,6 +1337,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pkoukk/tiktoken-go v0.1.6 h1:JF0TlJzhTbrI30wCvFuiw6FzP2+/bR+FIxUdgEAcUsw= +github.com/pkoukk/tiktoken-go v0.1.6/go.mod h1:9NiV+i9mJKGj1rYOT+njbv+ZwA/zJxYdewGl6qVatpg= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -1409,9 +1424,9 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -1438,8 +1453,13 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.21.6/go.mod h1:JfVbDpIBLVzT8oKbvMg9P3wEIMDDpVn+LwHTKj0ST88= -github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks= github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= +github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sijms/go-ora/v2 v2.7.18 h1:xl9CUeBlFi261AOKekiiFnfcp3ojHFEedLxIzsj909E= github.com/sijms/go-ora/v2 v2.7.18/go.mod h1:EHxlY6x7y9HAsdfumurRfTd+v8NrEOTR3Xl4FWlH6xk= @@ -1538,8 +1558,9 @@ github.com/tetratelabs/wazero v1.7.0/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXA github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= github.com/tidwall/gjson v1.2.1/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA= github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.13.0 h1:3TFY9yxOQShrvmjdM76K+jc66zJeT6D3/VFFYCGQf7M= github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= +github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= @@ -1552,16 +1573,20 @@ github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM= github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= -github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/langchaingo v0.1.12 h1:yXwSu54f3b1IKw0jJ5/DWu+qFVH1NBblwC0xddBzGJE= +github.com/tmc/langchaingo v0.1.12/go.mod h1:cd62xD6h+ouk8k/QQFhOsjRYBSA1JJ5UVKXSIgm7Ni4= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/uber/jaeger-client-go v2.29.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= @@ -1618,8 +1643,9 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ= github.com/zouyx/agollo/v3 v3.4.5/go.mod h1:LJr3kDmm23QSW+F1Ol4TMHDa7HvJvscMdVxJ2IpUTVc= go.einride.tech/aip v0.66.0 h1:XfV+NQX6L7EOYK11yoHHFtndeaWh3KbD9/cN/6iWEt8= @@ -1644,8 +1670,8 @@ go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/O go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0/go.mod h1:FAwse6Zlm5v4tEWZaTjmNhe17Int4Oxbu7+2r0DiD3w= go.etcd.io/etcd/server/v3 v3.5.0-alpha.0/go.mod h1:tsKetYpt980ZTpzl/gb+UOJj9RkIyCb1u4wjzMg90BQ= go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0= -go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= -go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= +go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -1657,10 +1683,10 @@ go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f/go.mod h1:5pWMHQbX5EPX2/6 go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= go.opentelemetry.io/contrib/instrumentation/runtime v0.32.0/go.mod h1:qtaLlIO4HC4DfedkYTOrvS2u7nA3N/v8w9mehrBD4O8= go.opentelemetry.io/contrib/propagators/b3 v1.7.0/go.mod h1:gXx7AhL4xXCF42gpm9dQvdohoDa2qeyEx4eIIxqK+h4= go.opentelemetry.io/contrib/propagators/jaeger v1.7.0/go.mod h1:kt2lNImfxV6dETRsDCENd6jU6G0mPRS+P0qlNuvtkTE= @@ -1668,8 +1694,8 @@ go.opentelemetry.io/contrib/propagators/opencensus v0.32.0/go.mod h1:rgmffkE6ivb go.opentelemetry.io/contrib/propagators/ot v1.7.0/go.mod h1:5qxBZR730yb71uXc3bazxt2Si8o8LQK3iJTnSLca/BU= go.opentelemetry.io/otel v1.4.1/go.mod h1:StM6F/0fSwpd8dKWDCdRr7uRvEPYdW0hBSlbdTiUde4= go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= +go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= go.opentelemetry.io/otel/bridge/opencensus v0.30.0/go.mod h1:jyERBSEU6EX7oR+LytaatX1UxNphEIRXj1q3n/6hIk0= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0/go.mod h1:M1hVZHNxcbkAlcvrOMlpQ4YOO3Awf+4N2dxkZL3xm04= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.30.0/go.mod h1:8Lz1GGcrx1kPGE3zqDrK7ZcPzABEfIQqBjq7roQa5ZA= @@ -1682,17 +1708,17 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S2 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.4.1/go.mod h1:BFiGsTMZdqtxufux8ANXuMeRz9dMPVFdJZadUWDFD7o= go.opentelemetry.io/otel/metric v0.30.0/go.mod h1:/ShZ7+TS4dHzDFmfi1kSXMhMVubNoP0oIaBp70J6UXU= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= +go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= go.opentelemetry.io/otel/sdk v1.4.1/go.mod h1:NBwHDgDIBYjwK2WNu1OPgsIc2IJzmBXNnvIJxJc8BpE= go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= -go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= -go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= +go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8= +go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs= go.opentelemetry.io/otel/sdk/metric v0.30.0/go.mod h1:8AKFRi5HyvTR0RRty3paN1aMC9HMT+NzcEhw/BLkLX8= go.opentelemetry.io/otel/trace v1.4.1/go.mod h1:iYEVbroFCNut9QkwEczV9vMRPHNKSSwYZjulEtsmhFc= go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= +go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.16.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= @@ -1908,8 +1934,8 @@ golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2041,6 +2067,9 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2191,8 +2220,8 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.169.0 h1:QwWPy71FgMWqJN/l6jVlFHUa29a7dcUy02I8o799nPY= -google.golang.org/api v0.169.0/go.mod h1:gpNOiMA2tZ4mf5R9Iwf4rK/Dcz0fbdIgWYWVoxmsyLg= +google.golang.org/api v0.180.0 h1:M2D87Yo0rGBPWpo1orwfCLehUUL6E7/TYe5gvMQWDh4= +google.golang.org/api v0.180.0/go.mod h1:51AiyoEg1MJPSZ9zvklA8VnRILPXxn1iVen9v25XHAE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2200,8 +2229,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -2243,12 +2270,12 @@ google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxH google.golang.org/genproto v0.0.0-20211104193956-4c6863e31247/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= -google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda h1:wu/KJm9KJwpfHWhkkZGohVC6KRrc1oJNr4jwtQMOQXw= +google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda/go.mod h1:g2LLCvCeCSir/JJSWosk19BR4NVxGqHUC6rxIRsd7Aw= +google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No= +google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434 h1:umK/Ey0QEzurTNlsV3R+MfxHAb78HCEX/IkuR+zH4WQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -2299,8 +2326,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= diff --git a/metadata/utils.go b/metadata/utils.go index dc82e8ff6f..7068dfd216 100644 --- a/metadata/utils.go +++ b/metadata/utils.go @@ -157,6 +157,7 @@ const ( CryptoType ComponentType = "crypto" NameResolutionType ComponentType = "nameresolution" WorkflowType ComponentType = "workflows" + ConversationType ComponentType = "conversation" ) // IsValid returns true if the component type is valid. diff --git a/tests/certification/go.mod b/tests/certification/go.mod index a83a7ee57d..cda79b8d90 100644 --- a/tests/certification/go.mod +++ b/tests/certification/go.mod @@ -1,11 +1,11 @@ module github.com/dapr/components-contrib/tests/certification -go 1.23 +go 1.23.0 toolchain go1.23.1 require ( - cloud.google.com/go/pubsub v1.36.1 + cloud.google.com/go/pubsub v1.37.0 dubbo.apache.org/dubbo-go/v3 v3.0.3-0.20230118042253-4f159a2b38f3 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2 github.com/IBM/sarama v1.42.2 @@ -36,7 +36,7 @@ require ( github.com/riferrei/srclient v0.6.0 github.com/stretchr/testify v1.9.0 github.com/tylertreat/comcast v1.0.1 - go.mongodb.org/mongo-driver v1.12.1 + go.mongodb.org/mongo-driver v1.14.0 go.uber.org/multierr v1.11.0 go.uber.org/ratelimit v0.3.0 k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 @@ -44,11 +44,12 @@ require ( ) require ( - cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute v1.25.1 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go v0.113.0 // indirect + cloud.google.com/go/auth v0.4.1 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/datastore v1.15.0 // indirect - cloud.google.com/go/iam v1.1.6 // indirect + cloud.google.com/go/iam v1.1.7 // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -84,19 +85,20 @@ require ( github.com/armon/go-metrics v0.4.1 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 // indirect - github.com/aws/aws-sdk-go-v2 v1.25.0 // indirect - github.com/aws/aws-sdk-go-v2/config v1.18.28 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.27 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 // indirect + github.com/aws/aws-sdk-go-v2 v1.31.0 // indirect + github.com/aws/aws-sdk-go-v2/config v1.27.39 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.37 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.3.10 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 // indirect - github.com/aws/smithy-go v1.20.0 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 // indirect + github.com/aws/smithy-go v1.21.0 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.4.0 // indirect @@ -131,7 +133,7 @@ require ( github.com/eapache/queue v1.1.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect - github.com/fatih/color v1.15.0 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect @@ -170,7 +172,7 @@ require ( github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.2 // indirect + github.com/googleapis/gax-go/v2 v2.12.4 // indirect github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.1 // indirect @@ -266,7 +268,8 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect github.com/segmentio/asm v1.2.0 // indirect - github.com/shirou/gopsutil/v3 v3.22.2 // indirect + github.com/shirou/gopsutil/v3 v3.23.12 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/smartystreets/assertions v1.1.0 // indirect github.com/sony/gobreaker v0.5.0 // indirect @@ -283,8 +286,8 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde // indirect - github.com/tklauser/go-sysconf v0.3.10 // indirect - github.com/tklauser/numcpus v0.4.0 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.51.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect @@ -294,11 +297,11 @@ require ( github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/yashtewari/glob-intersection v0.2.0 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/zeebo/errs v1.3.0 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect go.opentelemetry.io/otel v1.27.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.26.0 // indirect @@ -315,7 +318,7 @@ require ( golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/mod v0.18.0 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.21.0 // indirect @@ -323,9 +326,8 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/api v0.169.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/api v0.180.0 // indirect + google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect google.golang.org/grpc v1.64.1 // indirect diff --git a/tests/certification/go.sum b/tests/certification/go.sum index d3a9042f4e..83a47faa47 100644 --- a/tests/certification/go.sum +++ b/tests/certification/go.sum @@ -13,33 +13,35 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= -cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= +cloud.google.com/go v0.113.0 h1:g3C70mn3lWfckKBiCVsAshabrDg01pQ0pnX1MNtnMkA= +cloud.google.com/go v0.113.0/go.mod h1:glEqlogERKYeePz6ZdkcLJ28Q2I6aERgDDErBg9GzO8= +cloud.google.com/go/auth v0.4.1 h1:Z7YNIhlWRtrnKlZke7z3GMqzvuYzdc2z98F9D1NV5Hg= +cloud.google.com/go/auth v0.4.1/go.mod h1:QVBuVEKpCn4Zp58hzRGvL0tjRGU0YqdRTdCHM1IHnro= +cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= +cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU= -cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/datastore v1.15.0 h1:0P9WcsQeTWjuD1H14JIY7XQscIPQ4Laje8ti96IC5vg= cloud.google.com/go/datastore v1.15.0/go.mod h1:GAeStMBIt9bPS7jMJA85kgkpsMkvseWWXiaHya9Jes8= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc= -cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= -cloud.google.com/go/kms v1.15.7 h1:7caV9K3yIxvlQPAcaFffhlT7d1qpxjB1wHBtjWa13SM= -cloud.google.com/go/kms v1.15.7/go.mod h1:ub54lbsa6tDkUwnu4W7Yt1aAIFLnspgh0kPGToDukeI= +cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM= +cloud.google.com/go/iam v1.1.7/go.mod h1:J4PMPg8TtyurAUvSmPj8FF3EDgY1SPRZxcUGrn7WXGA= +cloud.google.com/go/kms v1.15.8 h1:szIeDCowID8th2i8XE4uRev5PMxQFqW+JjwYxL9h6xs= +cloud.google.com/go/kms v1.15.8/go.mod h1:WoUHcDjD9pluCg7pNds131awnH429QGvRM3N/4MyoVs= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.36.1 h1:dfEPuGCHGbWUhaMCTHUFjfroILEkx55iUmKBZTP5f+Y= -cloud.google.com/go/pubsub v1.36.1/go.mod h1:iYjCa9EzWOoBiTdd4ps7QoMtMln5NwaZQpK1hbRfBDE= +cloud.google.com/go/pubsub v1.37.0 h1:0uEEfaB1VIJzabPpwpZf44zWAKAme3zwKKxHk7vJQxQ= +cloud.google.com/go/pubsub v1.37.0/go.mod h1:YQOQr1uiUM092EXwKs56OPT650nwnawc+8/IjoUeGzQ= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= @@ -198,43 +200,43 @@ github.com/aws/aws-sdk-go v1.50.19 h1:YSIDKRSkh/TW0RPWoocdLqtC/T5W6IGBVhFs6P7Qca github.com/aws/aws-sdk-go v1.50.19/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= -github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.25.0 h1:sv7+1JVJxOu/dD/sz/csHX7jFqmP001TIY7aytBWDSQ= -github.com/aws/aws-sdk-go-v2 v1.25.0/go.mod h1:G104G1Aho5WqF+SR3mDIobTABQzpYV0WxMsKxlMggOA= +github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72QmG5U= +github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA= github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw= -github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= -github.com/aws/aws-sdk-go-v2/config v1.18.28/go.mod h1:nIL+4/8JdAuNHEjn/gPEXqtnS02Q3NXB/9Z7o5xE4+A= +github.com/aws/aws-sdk-go-v2/config v1.27.39 h1:FCylu78eTGzW1ynHcongXK9YHtoXD5AiiUqq3YfJYjU= +github.com/aws/aws-sdk-go-v2/config v1.27.39/go.mod h1:wczj2hbyskP4LjMKBEZwPRO1shXY+GsQleab+ZXT2ik= github.com/aws/aws-sdk-go-v2/credentials v1.4.3/go.mod h1:FNNC6nQZQUuyhq5aE5c7ata8o9e4ECGmS4lAXC7o1mQ= -github.com/aws/aws-sdk-go-v2/credentials v1.13.27 h1:dz0yr/yR1jweAnsCx+BmjerUILVPQ6FS5AwF/OyG1kA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.27/go.mod h1:syOqAek45ZXZp29HlnRS/BNgMIW6uiRmeuQsz4Qh2UE= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37 h1:G2aOH01yW8X373JK419THj5QVqu9vKEwxSEsGxihoW0= +github.com/aws/aws-sdk-go-v2/credentials v1.17.37/go.mod h1:0ecCjlb7htYCptRD45lXJ6aJDQac6D2NlKGpZqyTG6A= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.6.0/go.mod h1:gqlclDEZp4aqJOancXK6TN24aKhT0W0Ae9MHk3wzTMM= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 h1:kP3Me6Fy3vdi+9uHd7YLr6ewPxRL+PU6y15urfTaamU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5/go.mod h1:Gj7tm95r+QsDoN2Fhuz/3npQvcZbkEf5mL70n3Xfluc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 h1:C/d03NAmh8C4BZXhuRNboF/DqhBkBCeDiJDcaqIT5pA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14/go.mod h1:7I0Ju7p9mCIdlrfS+JCgqcYD0VXz/N4yozsox+0o078= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.3.10 h1:z6fAXB4HSuYjrE/P8RU3NdCaN+EPaeq/+80aisCjuF8= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.3.10/go.mod h1:PoPjOi7j+/DtKIGC58HRfcdWKBPYYXwdKnRG+po+hzo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 h1:hMUCiE3Zi5AHrRNGf5j985u0WyqI6r2NULhUfo0N/No= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35/go.mod h1:ipR5PvpSPqIqL5Mi82BxLnfMkHVbmco8kUwO2xrCi0M= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 h1:yOpYx+FTBdpk/g+sBU6Cb1H0U/TLEcYYp66mYqsPpcc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29/go.mod h1:M/eUABlDbw2uVrdAn+UsI6M727qp2fxkp8K0ejcBDUY= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 h1:kYQ3H1u0ANr9KEKlGs/jTLrBFPo8P8NaH/w7A01NeeM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18/go.mod h1:r506HmK5JDUh9+Mw4CfGJGSSoqIiLCndAuqXuhbv67Y= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 h1:Z7IdFUONvTcvS7YuhtVxN99v2cCoHRXOS4mTr0B/pUc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18/go.mod h1:DkKMmksZVVyat+Y+r1dEOgJEfUeA7UngIHWeKsi0yNc= github.com/aws/aws-sdk-go-v2/internal/ini v1.2.4/go.mod h1:ZcBrrI3zBKlhGFNYWvju0I3TR93I7YIgAfy82Fh4lcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 h1:8r5m1BoAWkn0TDC34lUculryf7nUF25EgIMdjvGCkgo= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36/go.mod h1:Rmw2M1hMVTwiUhjwMoIBFWFJMhvJbct06sSidxInkhY= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= github.com/aws/aws-sdk-go-v2/service/appconfig v1.4.2/go.mod h1:FZ3HkCe+b10uFZZkFdvf98LHW21k49W8o8J366lqVKY= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 h1:QFASJGfT8wMXtuP3D5CRmMjARHv9ZmzFUMJznHDOY3w= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5/go.mod h1:QdZ3OmoIjSX+8D1OPAzPxDfjXASbBMDsz9qvtyIhtik= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.3.2/go.mod h1:72HRZDLMtmVQiLG2tLfQcaWLCssELvGl+Zf2WVxMmR8= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 h1:IiDolu/eLmuB18DRZibj77n1hHQT7z12jnGO7Ze3pLc= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29/go.mod h1:fDbkK4o7fpPXWn8YAPmTieAMuB9mk/VgvW64uaUqxd4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 h1:Xbwbmk44URTiHNx6PNo0ujDE6ERlsCKJD3u1zfnzAPg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20/go.mod h1:oAfOFzUB14ltPZj1rWwRc3d/6OgD76R8KlvU3EqM9Fg= github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+IkPchKS7p7c2YPKwHmBOk= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 h1:sWDv7cMITPcZ21QdreULwxOOAmE05JjEsT6fCDtDA9k= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.13/go.mod h1:DfX0sWuT46KpcqbMhJ9QWtxAIP1VozkDWf8VAkByjYY= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 h1:BFubHS/xN5bjl818QaroN6mQdjneYQ+AOx44KNXlyH4= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13/go.mod h1:BzqsVVFduubEmzrVtUFQQIQdFqvUItF8XUq2EnS8Wog= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3 h1:rs4JCczF805+FDv2tRhZ1NU0RB2H6ryAvsWPanAr72Y= +github.com/aws/aws-sdk-go-v2/service/sso v1.23.3/go.mod h1:XRlMvmad0ZNL+75C5FYdMvbbLkd6qiqz6foR1nA1PXY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3 h1:S7EPdMVZod8BGKQQPTBK+FcX9g7bKR7c4+HxWqHP7Vg= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.3/go.mod h1:FnvDM4sfa+isJ3kDXIzAB9GAwVSzFzSy97uZ3IsHo4E= github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 h1:e5mnydVdCVWxP+5rPAGi2PYxC7u2OZgH1ypC114H04U= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.3/go.mod h1:yVGZA1CPkmUhBdA039jXNJJG7/6t+G+EBWmFq23xqnY= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3 h1:VzudTFrDCIDakXtemR7l6Qzt2+JYsVqo2MxBPt5k8T8= +github.com/aws/aws-sdk-go-v2/service/sts v1.31.3/go.mod h1:yMWe0F+XG0DkRZK5ODZhG7BEFYhLXi2dqGsv6tX0cgI= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.20.0 h1:6+kZsCXZwKxZS9RfISnPc4EXlHoyAkm2hPuM8X2BrrQ= -github.com/aws/smithy-go v1.20.0/go.mod h1:uo5RKksAl4PzhqaAbjd4rLgFoq5koTsQKYuGe7dklGc= +github.com/aws/smithy-go v1.21.0 h1:H7L8dtDRk0P1Qm6y0ji7MCYMQObJ5R9CRpyPhRUkLYA= +github.com/aws/smithy-go v1.21.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= @@ -475,8 +477,8 @@ github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwo github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= @@ -666,8 +668,8 @@ github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/cel-go v0.18.2 h1:L0B6sNBSVmt0OyECi8v6VOS74KOc9W/tLiWKfZABvf4= github.com/google/cel-go v0.18.2/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= -github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM= -github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= +github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -677,7 +679,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -715,8 +716,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfF github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA= -github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= +github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw4Z96qg= +github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0= @@ -930,7 +931,6 @@ github.com/kitex-contrib/monitor-prometheus v0.0.0-20210817080809-024dd7bd51e1/g github.com/kitex-contrib/obs-opentelemetry v0.0.0-20220601144657-c60210e3c928/go.mod h1:VvMzPMfgL7iUG92eVZGuRybGVMKzuSrsfMvHHpL7/Ac= github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20220601144657-c60210e3c928/go.mod h1:Eml/0Z+CqgGIPf9JXzLGu+N9NJoy2x5pqypN+hmKArE= github.com/kitex-contrib/tracer-opentracing v0.0.2/go.mod h1:mprt5pxqywFQxlHb7ugfiMdKbABTLI9YrBYs9WmlK5Q= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -1054,7 +1054,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/montanaflynn/stats v0.7.0 h1:r3y12KyNxj/Sb/iOE46ws+3mS1+MZca1wlHQFPsY/JU= github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= @@ -1254,8 +1253,13 @@ github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.21.6/go.mod h1:JfVbDpIBLVzT8oKbvMg9P3wEIMDDpVn+LwHTKj0ST88= -github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks= github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shirou/gopsutil/v3 v3.23.12 h1:z90NtUkp3bMtmICZKpC4+WaknU1eXtp5vtbQ11DgpE4= +github.com/shirou/gopsutil/v3 v3.23.12/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1326,6 +1330,7 @@ github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= @@ -1349,12 +1354,14 @@ github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde/go.mod h1:MvrEmd github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/tklauser/go-sysconf v0.3.6/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= -github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -1398,8 +1405,9 @@ github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ= @@ -1419,8 +1427,8 @@ go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/ go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0/go.mod h1:FAwse6Zlm5v4tEWZaTjmNhe17Int4Oxbu7+2r0DiD3w= go.etcd.io/etcd/server/v3 v3.5.0-alpha.0/go.mod h1:tsKetYpt980ZTpzl/gb+UOJj9RkIyCb1u4wjzMg90BQ= -go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= -go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= +go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -1432,10 +1440,10 @@ go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f/go.mod h1:5pWMHQbX5EPX2/6 go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= go.opentelemetry.io/contrib/instrumentation/runtime v0.32.0/go.mod h1:qtaLlIO4HC4DfedkYTOrvS2u7nA3N/v8w9mehrBD4O8= go.opentelemetry.io/contrib/propagators/b3 v1.7.0/go.mod h1:gXx7AhL4xXCF42gpm9dQvdohoDa2qeyEx4eIIxqK+h4= go.opentelemetry.io/contrib/propagators/jaeger v1.7.0/go.mod h1:kt2lNImfxV6dETRsDCENd6jU6G0mPRS+P0qlNuvtkTE= @@ -1531,7 +1539,6 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= @@ -1659,8 +1666,8 @@ golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1778,6 +1785,9 @@ golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1908,8 +1918,8 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.169.0 h1:QwWPy71FgMWqJN/l6jVlFHUa29a7dcUy02I8o799nPY= -google.golang.org/api v0.169.0/go.mod h1:gpNOiMA2tZ4mf5R9Iwf4rK/Dcz0fbdIgWYWVoxmsyLg= +google.golang.org/api v0.180.0 h1:M2D87Yo0rGBPWpo1orwfCLehUUL6E7/TYe5gvMQWDh4= +google.golang.org/api v0.180.0/go.mod h1:51AiyoEg1MJPSZ9zvklA8VnRILPXxn1iVen9v25XHAE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1917,8 +1927,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1959,8 +1967,8 @@ google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQ google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20211104193956-4c6863e31247/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= -google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= +google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda h1:wu/KJm9KJwpfHWhkkZGohVC6KRrc1oJNr4jwtQMOQXw= +google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda/go.mod h1:g2LLCvCeCSir/JJSWosk19BR4NVxGqHUC6rxIRsd7Aw= google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg= google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y= google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk= diff --git a/tests/config/conversation/echo/echo.yml b/tests/config/conversation/echo/echo.yml new file mode 100644 index 0000000000..e4fc3e0cc0 --- /dev/null +++ b/tests/config/conversation/echo/echo.yml @@ -0,0 +1,9 @@ +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: echo +spec: + type: conversation.echo + version: v1 + metadata: + \ No newline at end of file diff --git a/tests/config/conversation/tests.yml b/tests/config/conversation/tests.yml new file mode 100644 index 0000000000..622e62c251 --- /dev/null +++ b/tests/config/conversation/tests.yml @@ -0,0 +1,4 @@ +componentType: conversation +components: + - component: echo + operations: [] diff --git a/tests/conformance/conversation/conversation.go b/tests/conformance/conversation/conversation.go new file mode 100644 index 0000000000..e909c36061 --- /dev/null +++ b/tests/conformance/conversation/conversation.go @@ -0,0 +1,73 @@ +/* +Copyright 2024 The Dapr 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 conversation + +import ( + "context" + "testing" + + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/components-contrib/metadata" + "github.com/dapr/components-contrib/tests/conformance/utils" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +type TestConfig struct { + utils.CommonConfig +} + +func NewTestConfig(componentName string) TestConfig { + tc := TestConfig{ + utils.CommonConfig{ + ComponentType: "conversation", + ComponentName: componentName, + }, + } + + return tc +} + +func ConformanceTests(t *testing.T, props map[string]string, conv conversation.Conversation, component string) { + t.Run("init", func(t *testing.T) { + err := conv.Init(context.Background(), conversation.Metadata{ + Base: metadata.Base{ + Properties: props, + }, + }) + require.NoError(t, err) + }) + + if t.Failed() { + t.Fatal("initialization failed") + } + + t.Run("converse", func(t *testing.T) { + t.Run("get a non-empty response without errors", func(t *testing.T) { + req := &conversation.ConversationRequest{ + Inputs: []conversation.ConversationInput{ + { + Message: "what is the time?", + }, + }, + } + + resp, err := conv.Converse(context.Background(), req) + require.NoError(t, err) + assert.Len(t, resp.Outputs, 1) + assert.NotEmpty(t, resp.Outputs[0].Result) + }) + }) +} diff --git a/tests/conformance/conversation_test.go b/tests/conformance/conversation_test.go new file mode 100644 index 0000000000..0adb767fe5 --- /dev/null +++ b/tests/conformance/conversation_test.go @@ -0,0 +1,61 @@ +//go:build conftests +// +build conftests + +/* +Copyright 2021 The Dapr 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 conformance + +import ( + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/components-contrib/conversation/echo" + conf_conversation "github.com/dapr/components-contrib/tests/conformance/conversation" +) + +func TestConversationConformance(t *testing.T) { + const configPath = "../config/conversation/" + tc, err := NewTestConfiguration(filepath.Join(configPath, "tests.yml")) + require.NoError(t, err) + require.NotNil(t, tc) + + tc.TestFn = func(comp *TestComponent) func(t *testing.T) { + return func(t *testing.T) { + ParseConfigurationMap(t, comp.Config) + + componentConfigPath := convertComponentNameToPath(comp.Component, comp.Profile) + props, err := loadComponentsAndProperties(t, filepath.Join(configPath, componentConfigPath)) + require.NoErrorf(t, err, "error running conformance test for component %s", comp.Component) + + conv := loadConversationComponent(comp.Component) + require.NotNil(t, conv, "error running conformance test for component %s", comp.Component) + + conf_conversation.ConformanceTests(t, props, conv, comp.Component) + } + } + + tc.Run(t) +} + +func loadConversationComponent(name string) conversation.Conversation { + switch name { + case "echo": + return echo.NewEcho(testLogger) + default: + return nil + } +} diff --git a/tests/e2e/pubsub/jetstream/go.mod b/tests/e2e/pubsub/jetstream/go.mod index 2b2b978655..c9383d0c2a 100644 --- a/tests/e2e/pubsub/jetstream/go.mod +++ b/tests/e2e/pubsub/jetstream/go.mod @@ -1,6 +1,6 @@ module github.com/dapr/components-contrib/tests/e2e/pubsub/jetstream -go 1.23 +go 1.23.0 toolchain go1.23.1 @@ -28,7 +28,7 @@ require ( github.com/spf13/cast v1.5.1 // indirect golang.org/x/crypto v0.24.0 // indirect golang.org/x/sys v0.21.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect k8s.io/apimachinery v0.26.10 // indirect ) diff --git a/tests/e2e/pubsub/jetstream/go.sum b/tests/e2e/pubsub/jetstream/go.sum index 601ea5ed0d..281c3f7ec6 100644 --- a/tests/e2e/pubsub/jetstream/go.sum +++ b/tests/e2e/pubsub/jetstream/go.sum @@ -110,8 +110,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= From ebeff0a96afc8123248c5da22f67381088361d7b Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Fri, 11 Oct 2024 15:01:43 -0700 Subject: [PATCH 04/11] Add component for Anthropic (#3564) Signed-off-by: yaron2 Signed-off-by: Elena Kolevska --- conversation/anthropic/anthropic.go | 118 +++++++++++++++++++++++ conversation/anthropic/metadata.yaml | 29 ++++++ conversation/aws/bedrock/bedrock.go | 19 +--- conversation/aws/bedrock/bedrock_test.go | 25 ----- conversation/langchainroles.go | 34 +++++++ conversation/langchainroles_test.go | 39 ++++++++ 6 files changed, 221 insertions(+), 43 deletions(-) create mode 100644 conversation/anthropic/anthropic.go create mode 100644 conversation/anthropic/metadata.yaml delete mode 100644 conversation/aws/bedrock/bedrock_test.go create mode 100644 conversation/langchainroles.go create mode 100644 conversation/langchainroles_test.go diff --git a/conversation/anthropic/anthropic.go b/conversation/anthropic/anthropic.go new file mode 100644 index 0000000000..344c458d03 --- /dev/null +++ b/conversation/anthropic/anthropic.go @@ -0,0 +1,118 @@ +/* +Copyright 2024 The Dapr 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 anthropic + +import ( + "context" + "reflect" + + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/components-contrib/metadata" + "github.com/dapr/kit/logger" + kmeta "github.com/dapr/kit/metadata" + + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/anthropic" +) + +type Anthropic struct { + llm *anthropic.LLM + + logger logger.Logger +} + +type AnthropicMetadata struct { + Key string `json:"key"` + Model string `json:"model"` +} + +func NewAnthropic(logger logger.Logger) conversation.Conversation { + a := &Anthropic{ + logger: logger, + } + + return a +} + +const defaultModel = "claude-3-5-sonnet-20240620" + +func (a *Anthropic) Init(ctx context.Context, meta conversation.Metadata) error { + m := AnthropicMetadata{} + err := kmeta.DecodeMetadata(meta.Properties, &m) + if err != nil { + return err + } + + model := defaultModel + if m.Model != "" { + model = m.Model + } + + llm, err := anthropic.New( + anthropic.WithModel(model), + anthropic.WithToken(m.Key), + ) + if err != nil { + return err + } + + a.llm = llm + return nil +} + +func (a *Anthropic) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { + metadataStruct := AnthropicMetadata{} + metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) + return +} + +func (a *Anthropic) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) { + messages := make([]llms.MessageContent, 0, len(r.Inputs)) + + for _, input := range r.Inputs { + role := conversation.ConvertLangchainRole(input.Role) + + messages = append(messages, llms.MessageContent{ + Role: role, + Parts: []llms.ContentPart{ + llms.TextPart(input.Message), + }, + }) + } + + resp, err := a.llm.GenerateContent(ctx, messages) + if err != nil { + return nil, err + } + + outputs := make([]conversation.ConversationResult, 0, len(resp.Choices)) + + for i := range resp.Choices { + outputs = append(outputs, conversation.ConversationResult{ + Result: resp.Choices[i].Content, + Parameters: r.Parameters, + }) + } + + res = &conversation.ConversationResponse{ + Outputs: outputs, + } + + return res, nil +} + +func (a *Anthropic) Close() error { + return nil +} diff --git a/conversation/anthropic/metadata.yaml b/conversation/anthropic/metadata.yaml new file mode 100644 index 0000000000..e8e6587a40 --- /dev/null +++ b/conversation/anthropic/metadata.yaml @@ -0,0 +1,29 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: conversation +name: anthropic +version: v1 +status: alpha +title: "Anthropic" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-conversation/setup-anthropic/ +authenticationProfiles: + - title: "API Key" + description: "Authenticate using an API key" + metadata: + - name: key + type: string + required: true + sensitive: true + description: | + API key for Anthropic. + example: "**********" + default: "" +metadata: + - name: model + required: false + description: | + The Anthropic LLM to use. Defaults to claude-3-5-sonnet-20240620 + type: string + example: 'claude-3-5-sonnet-20240620' diff --git a/conversation/aws/bedrock/bedrock.go b/conversation/aws/bedrock/bedrock.go index 9fbf805d5f..709e74da00 100644 --- a/conversation/aws/bedrock/bedrock.go +++ b/conversation/aws/bedrock/bedrock.go @@ -53,23 +53,6 @@ func NewAWSBedrock(logger logger.Logger) conversation.Conversation { return b } -func convertRole(role conversation.Role) llms.ChatMessageType { - switch role { - case conversation.RoleSystem: - return llms.ChatMessageTypeSystem - case conversation.RoleUser: - return llms.ChatMessageTypeHuman - case conversation.RoleAssistant: - return llms.ChatMessageTypeAI - case conversation.RoleTool: - return llms.ChatMessageTypeTool - case conversation.RoleFunction: - return llms.ChatMessageTypeFunction - default: - return llms.ChatMessageTypeHuman - } -} - func (b *AWSBedrock) Init(ctx context.Context, meta conversation.Metadata) error { m := AWSBedrockMetadata{} err := kmeta.DecodeMetadata(meta.Properties, &m) @@ -111,7 +94,7 @@ func (b *AWSBedrock) Converse(ctx context.Context, r *conversation.ConversationR messages := make([]llms.MessageContent, 0, len(r.Inputs)) for _, input := range r.Inputs { - role := convertRole(input.Role) + role := conversation.ConvertLangchainRole(input.Role) messages = append(messages, llms.MessageContent{ Role: role, diff --git a/conversation/aws/bedrock/bedrock_test.go b/conversation/aws/bedrock/bedrock_test.go deleted file mode 100644 index 63bda0187f..0000000000 --- a/conversation/aws/bedrock/bedrock_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package bedrock - -import ( - "testing" - - "github.com/dapr/components-contrib/conversation" - - "github.com/stretchr/testify/assert" - "github.com/tmc/langchaingo/llms" -) - -func TestConvertRole(t *testing.T) { - roles := map[string]string{ - conversation.RoleSystem: string(llms.ChatMessageTypeSystem), - conversation.RoleAssistant: string(llms.ChatMessageTypeAI), - conversation.RoleFunction: string(llms.ChatMessageTypeFunction), - conversation.RoleUser: string(llms.ChatMessageTypeHuman), - conversation.RoleTool: string(llms.ChatMessageTypeTool), - } - - for k, v := range roles { - r := convertRole(conversation.Role(k)) - assert.Equal(t, v, string(r)) - } -} diff --git a/conversation/langchainroles.go b/conversation/langchainroles.go new file mode 100644 index 0000000000..a3d4a60fd3 --- /dev/null +++ b/conversation/langchainroles.go @@ -0,0 +1,34 @@ +/* +Copyright 2024 The Dapr 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 conversation + +import "github.com/tmc/langchaingo/llms" + +func ConvertLangchainRole(role Role) llms.ChatMessageType { + switch role { + case RoleSystem: + return llms.ChatMessageTypeSystem + case RoleUser: + return llms.ChatMessageTypeHuman + case RoleAssistant: + return llms.ChatMessageTypeAI + case RoleTool: + return llms.ChatMessageTypeTool + case RoleFunction: + return llms.ChatMessageTypeFunction + default: + return llms.ChatMessageTypeHuman + } +} diff --git a/conversation/langchainroles_test.go b/conversation/langchainroles_test.go new file mode 100644 index 0000000000..5f83de34ba --- /dev/null +++ b/conversation/langchainroles_test.go @@ -0,0 +1,39 @@ +/* +Copyright 2024 The Dapr 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 conversation + +import ( + "testing" + + "github.com/tmc/langchaingo/llms" + + "github.com/stretchr/testify/assert" +) + +func TestConvertLangchainRole(t *testing.T) { + roles := map[string]string{ + RoleSystem: string(llms.ChatMessageTypeSystem), + RoleAssistant: string(llms.ChatMessageTypeAI), + RoleFunction: string(llms.ChatMessageTypeFunction), + RoleUser: string(llms.ChatMessageTypeHuman), + RoleTool: string(llms.ChatMessageTypeTool), + } + + for k, v := range roles { + r := ConvertLangchainRole(Role(k)) + assert.Equal(t, v, string(r)) + } +} From 45a721fcb97ee496014449149978951f46b4ec37 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 14 Oct 2024 16:46:51 -0400 Subject: [PATCH 05/11] fix(redis): make auth profiles consistent for username/pwd (#3565) Signed-off-by: Samantha Coyle Signed-off-by: Elena Kolevska --- pubsub/redis/metadata.yaml | 33 +++++++++++++++++++++------------ state/redis/metadata.yaml | 32 +++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/pubsub/redis/metadata.yaml b/pubsub/redis/metadata.yaml index 91628099df..9bafdb5f7d 100644 --- a/pubsub/redis/metadata.yaml +++ b/pubsub/redis/metadata.yaml @@ -10,6 +10,27 @@ urls: url: https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-redis-pubsub/ capabilities: - ttl +authenticationProfiles: + - title: "Username and password" + description: "Authenticate using username and password." + metadata: + - name: redisUsername + type: string + required: false + description: | + Username for Redis host. Defaults to empty. Make sure your Redis server + version is 6 or above, and have created ACL rule correctly. + example: "my-username" + default: "" + - name: redisPassword + type: string + required: false + sensitive: true + description: | + Password for Redis host. No default. Use secretKeyRef for + secret reference + example: "KeFg23!" + default: "" metadata: - name: redisHost required: true @@ -17,18 +38,6 @@ metadata: Connection-string for the redis host. If "redisType" is "cluster" it can be multiple hosts separated by commas or just a single host example: '"redis-master.default.svc.cluster.local:6379"' type: string - - name: redisPassword - required: true - sensitive: true - description: | - Password for Redis host. No Default. Can be "secretKeyRef" to use a secret reference - example: '"KeFg23!"' - type: string - - name: redisUsername - required: false - description: Username for Redis host. Defaults to empty. Make sure your redis server version is 6 or above, and have created acl rule correctly. - example: "default" - type: string - name: consumerID required: false description: The consumer group ID diff --git a/state/redis/metadata.yaml b/state/redis/metadata.yaml index fbee1e0525..79898a759b 100644 --- a/state/redis/metadata.yaml +++ b/state/redis/metadata.yaml @@ -15,23 +15,33 @@ capabilities: - transactional - etag - query +authenticationProfiles: + - title: "Username and password" + description: "Authenticate using username and password." + metadata: + - name: redisUsername + type: string + required: false + description: | + Username for Redis host. Defaults to empty. Make sure your Redis server + version is 6 or above, and have created ACL rule correctly. + example: "my-username" + default: "" + - name: redisPassword + type: string + required: false + sensitive: true + description: | + Password for Redis host. No default. Use secretKeyRef for + secret reference + example: "KeFg23!" + default: "" metadata: - name: redisHost required: true description: Connection-string for the redis host example: "redis-master.default.svc.cluster.local:6379" type: string - - name: redisPassword - required: false - sensitive: true - description: Password for Redis host. No Default. Can be secretKeyRef to use a secret reference - example: "KeFg23!" - type: string - - name: redisUsername - required: false - description: Username for Redis host. Defaults to empty. Make sure your redis server version is 6 or above, and have created acl rule correctly. - example: "default" - type: string - name: enableTLS required: false description: If the Redis instance supports TLS with public certificates, can be configured to be enabled or disabled. Defaults to false. From 7d683b659875ebf6b5e60b09d4aaf1313579e410 Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Mon, 14 Oct 2024 16:04:03 -0700 Subject: [PATCH 06/11] Add temperature support to conversational api (#3566) Signed-off-by: yaron2 Signed-off-by: Elena Kolevska --- conversation/anthropic/anthropic.go | 8 +++++++- conversation/aws/bedrock/bedrock.go | 8 +++++++- conversation/converse.go | 1 + conversation/openai/openai.go | 5 +++-- conversation/temperature.go | 22 ++++++++++++++++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 conversation/temperature.go diff --git a/conversation/anthropic/anthropic.go b/conversation/anthropic/anthropic.go index 344c458d03..4273e57f05 100644 --- a/conversation/anthropic/anthropic.go +++ b/conversation/anthropic/anthropic.go @@ -92,7 +92,13 @@ func (a *Anthropic) Converse(ctx context.Context, r *conversation.ConversationRe }) } - resp, err := a.llm.GenerateContent(ctx, messages) + opts := []llms.CallOption{} + + if r.Temperature > 0 { + opts = append(opts, conversation.LangchainTemperature(r.Temperature)) + } + + resp, err := a.llm.GenerateContent(ctx, messages, opts...) if err != nil { return nil, err } diff --git a/conversation/aws/bedrock/bedrock.go b/conversation/aws/bedrock/bedrock.go index 709e74da00..2da96d5383 100644 --- a/conversation/aws/bedrock/bedrock.go +++ b/conversation/aws/bedrock/bedrock.go @@ -104,7 +104,13 @@ func (b *AWSBedrock) Converse(ctx context.Context, r *conversation.ConversationR }) } - resp, err := b.llm.GenerateContent(ctx, messages) + opts := []llms.CallOption{} + + if r.Temperature > 0 { + opts = append(opts, conversation.LangchainTemperature(r.Temperature)) + } + + resp, err := b.llm.GenerateContent(ctx, messages, opts...) if err != nil { return nil, err } diff --git a/conversation/converse.go b/conversation/converse.go index 16fce9f6d6..6d3183bc4c 100644 --- a/conversation/converse.go +++ b/conversation/converse.go @@ -42,6 +42,7 @@ type ConversationRequest struct { Inputs []ConversationInput `json:"inputs"` Parameters map[string]*anypb.Any `json:"parameters"` ConversationContext string `json:"conversationContext"` + Temperature float64 `json:"temperature"` // from metadata Key string `json:"key"` diff --git a/conversation/openai/openai.go b/conversation/openai/openai.go index 02606aca28..beb164db2e 100644 --- a/conversation/openai/openai.go +++ b/conversation/openai/openai.go @@ -111,8 +111,9 @@ func (o *OpenAI) Converse(ctx context.Context, r *conversation.ConversationReque } req := openai.ChatCompletionRequest{ - Model: o.model, - Messages: messages, + Model: o.model, + Messages: messages, + Temperature: float32(r.Temperature), } // TODO: support ConversationContext diff --git a/conversation/temperature.go b/conversation/temperature.go new file mode 100644 index 0000000000..8e4bfa96e2 --- /dev/null +++ b/conversation/temperature.go @@ -0,0 +1,22 @@ +/* +Copyright 2024 The Dapr 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 conversation + +import "github.com/tmc/langchaingo/llms" + +// LangchainTemperature returns a langchain compliant LLM temperature +func LangchainTemperature(temperature float64) llms.CallOption { + return llms.WithTemperature(temperature) +} From 6c17689494d4016148125d4d515df7588bbc504c Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Tue, 15 Oct 2024 21:30:26 -0700 Subject: [PATCH 07/11] Conversation API: add cache support, add huggingface+mistral models (#3567) Signed-off-by: yaron2 Signed-off-by: Elena Kolevska --- conversation/anthropic/anthropic.go | 21 ++-- conversation/anthropic/metadata.yaml | 6 ++ conversation/aws/bedrock/bedrock.go | 12 ++- conversation/aws/bedrock/metadata.yaml | 6 ++ conversation/huggingface/huggingface.go | 129 +++++++++++++++++++++++ conversation/huggingface/metadata.yaml | 35 ++++++ conversation/metadata.go | 7 ++ conversation/mistral/metadata.yaml | 35 ++++++ conversation/mistral/mistral.go | 128 ++++++++++++++++++++++ conversation/openai/metadata.yaml | 6 ++ conversation/openai/openai.go | 99 +++++++---------- conversation/openai/openai_test.go | 26 ----- conversation/{temperature.go => opts.go} | 25 ++++- go.mod | 3 +- go.sum | 6 +- 15 files changed, 447 insertions(+), 97 deletions(-) create mode 100644 conversation/huggingface/huggingface.go create mode 100644 conversation/huggingface/metadata.yaml create mode 100644 conversation/mistral/metadata.yaml create mode 100644 conversation/mistral/mistral.go delete mode 100644 conversation/openai/openai_test.go rename conversation/{temperature.go => opts.go} (54%) diff --git a/conversation/anthropic/anthropic.go b/conversation/anthropic/anthropic.go index 4273e57f05..4f125edb05 100644 --- a/conversation/anthropic/anthropic.go +++ b/conversation/anthropic/anthropic.go @@ -28,16 +28,11 @@ import ( ) type Anthropic struct { - llm *anthropic.LLM + llm llms.Model logger logger.Logger } -type AnthropicMetadata struct { - Key string `json:"key"` - Model string `json:"model"` -} - func NewAnthropic(logger logger.Logger) conversation.Conversation { a := &Anthropic{ logger: logger, @@ -49,7 +44,7 @@ func NewAnthropic(logger logger.Logger) conversation.Conversation { const defaultModel = "claude-3-5-sonnet-20240620" func (a *Anthropic) Init(ctx context.Context, meta conversation.Metadata) error { - m := AnthropicMetadata{} + m := conversation.LangchainMetadata{} err := kmeta.DecodeMetadata(meta.Properties, &m) if err != nil { return err @@ -69,11 +64,21 @@ func (a *Anthropic) Init(ctx context.Context, meta conversation.Metadata) error } a.llm = llm + + if m.CacheTTL != "" { + cachedModel, cacheErr := conversation.CacheModel(ctx, m.CacheTTL, a.llm) + if cacheErr != nil { + return cacheErr + } + + a.llm = cachedModel + } + return nil } func (a *Anthropic) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { - metadataStruct := AnthropicMetadata{} + metadataStruct := conversation.LangchainMetadata{} metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) return } diff --git a/conversation/anthropic/metadata.yaml b/conversation/anthropic/metadata.yaml index e8e6587a40..c80710395d 100644 --- a/conversation/anthropic/metadata.yaml +++ b/conversation/anthropic/metadata.yaml @@ -27,3 +27,9 @@ metadata: The Anthropic LLM to use. Defaults to claude-3-5-sonnet-20240620 type: string example: 'claude-3-5-sonnet-20240620' + - name: cacheTTL + required: false + description: | + A time-to-live value for a prompt cache to expire. Uses Golang durations + type: string + example: '10m' diff --git a/conversation/aws/bedrock/bedrock.go b/conversation/aws/bedrock/bedrock.go index 2da96d5383..d7b5ffc226 100644 --- a/conversation/aws/bedrock/bedrock.go +++ b/conversation/aws/bedrock/bedrock.go @@ -31,7 +31,7 @@ import ( type AWSBedrock struct { model string - llm *bedrock.LLM + llm llms.Model logger logger.Logger } @@ -43,6 +43,7 @@ type AWSBedrockMetadata struct { SecretKey string `json:"secretKey"` SessionToken string `json:"sessionToken"` Model string `json:"model"` + CacheTTL string `json:"cacheTTL"` } func NewAWSBedrock(logger logger.Logger) conversation.Conversation { @@ -81,6 +82,15 @@ func (b *AWSBedrock) Init(ctx context.Context, meta conversation.Metadata) error } b.llm = llm + + if m.CacheTTL != "" { + cachedModel, cacheErr := conversation.CacheModel(ctx, m.CacheTTL, b.llm) + if cacheErr != nil { + return cacheErr + } + + b.llm = cachedModel + } return nil } diff --git a/conversation/aws/bedrock/metadata.yaml b/conversation/aws/bedrock/metadata.yaml index 56c764845b..608fd0c8e4 100644 --- a/conversation/aws/bedrock/metadata.yaml +++ b/conversation/aws/bedrock/metadata.yaml @@ -24,3 +24,9 @@ metadata: The LLM to use. Defaults to Bedrock's default provider model from Amazon. type: string example: 'amazon.titan-text-express-v1' + - name: cacheTTL + required: false + description: | + A time-to-live value for a prompt cache to expire. Uses Golang durations + type: string + example: '10m' diff --git a/conversation/huggingface/huggingface.go b/conversation/huggingface/huggingface.go new file mode 100644 index 0000000000..e075fa68cf --- /dev/null +++ b/conversation/huggingface/huggingface.go @@ -0,0 +1,129 @@ +/* +Copyright 2024 The Dapr 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 huggingface + +import ( + "context" + "reflect" + + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/components-contrib/metadata" + "github.com/dapr/kit/logger" + kmeta "github.com/dapr/kit/metadata" + + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/huggingface" +) + +type Huggingface struct { + llm llms.Model + + logger logger.Logger +} + +func NewHuggingface(logger logger.Logger) conversation.Conversation { + h := &Huggingface{ + logger: logger, + } + + return h +} + +const defaultModel = "meta-llama/Meta-Llama-3-8B" + +func (h *Huggingface) Init(ctx context.Context, meta conversation.Metadata) error { + m := conversation.LangchainMetadata{} + err := kmeta.DecodeMetadata(meta.Properties, &m) + if err != nil { + return err + } + + model := defaultModel + if m.Model != "" { + model = m.Model + } + + llm, err := huggingface.New( + huggingface.WithModel(model), + huggingface.WithToken(m.Key), + ) + if err != nil { + return err + } + + h.llm = llm + + if m.CacheTTL != "" { + cachedModel, cacheErr := conversation.CacheModel(ctx, m.CacheTTL, h.llm) + if cacheErr != nil { + return cacheErr + } + + h.llm = cachedModel + } + + return nil +} + +func (h *Huggingface) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { + metadataStruct := conversation.LangchainMetadata{} + metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) + return +} + +func (h *Huggingface) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) { + messages := make([]llms.MessageContent, 0, len(r.Inputs)) + + for _, input := range r.Inputs { + role := conversation.ConvertLangchainRole(input.Role) + + messages = append(messages, llms.MessageContent{ + Role: role, + Parts: []llms.ContentPart{ + llms.TextPart(input.Message), + }, + }) + } + + opts := []llms.CallOption{} + + if r.Temperature > 0 { + opts = append(opts, conversation.LangchainTemperature(r.Temperature)) + } + + resp, err := h.llm.GenerateContent(ctx, messages, opts...) + if err != nil { + return nil, err + } + + outputs := make([]conversation.ConversationResult, 0, len(resp.Choices)) + + for i := range resp.Choices { + outputs = append(outputs, conversation.ConversationResult{ + Result: resp.Choices[i].Content, + Parameters: r.Parameters, + }) + } + + res = &conversation.ConversationResponse{ + Outputs: outputs, + } + + return res, nil +} + +func (h *Huggingface) Close() error { + return nil +} diff --git a/conversation/huggingface/metadata.yaml b/conversation/huggingface/metadata.yaml new file mode 100644 index 0000000000..70d975e336 --- /dev/null +++ b/conversation/huggingface/metadata.yaml @@ -0,0 +1,35 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: conversation +name: huggingface +version: v1 +status: alpha +title: "Huggingface" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-conversation/setup-huggingface/ +authenticationProfiles: + - title: "API Key" + description: "Authenticate using an API key" + metadata: + - name: key + type: string + required: true + sensitive: true + description: | + API key for Huggingface. + example: "**********" + default: "" +metadata: + - name: model + required: false + description: | + The Huggingface LLM to use. Defaults to meta-llama/Meta-Llama-3-8B + type: string + example: 'meta-llama/Meta-Llama-3-8B' + - name: cacheTTL + required: false + description: | + A time-to-live value for a prompt cache to expire. Uses Golang durations + type: string + example: '10m' diff --git a/conversation/metadata.go b/conversation/metadata.go index 33259a1c5c..30a2412aaf 100644 --- a/conversation/metadata.go +++ b/conversation/metadata.go @@ -20,3 +20,10 @@ import "github.com/dapr/components-contrib/metadata" type Metadata struct { metadata.Base `json:",inline"` } + +// LangchainMetadata is a common metadata structure for langchain supported implementations. +type LangchainMetadata struct { + Key string `json:"key"` + Model string `json:"model"` + CacheTTL string `json:"cacheTTL"` +} diff --git a/conversation/mistral/metadata.yaml b/conversation/mistral/metadata.yaml new file mode 100644 index 0000000000..6fcd66cbaa --- /dev/null +++ b/conversation/mistral/metadata.yaml @@ -0,0 +1,35 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: conversation +name: mistral +version: v1 +status: alpha +title: "Mistral" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-conversation/setup-mistral/ +authenticationProfiles: + - title: "API Key" + description: "Authenticate using an API key" + metadata: + - name: key + type: string + required: true + sensitive: true + description: | + API key for Mistral. + example: "**********" + default: "" +metadata: + - name: model + required: false + description: | + The Mistral LLM to use. Defaults to open-mistral-7b + type: string + example: 'open-mistral-7b' + - name: cacheTTL + required: false + description: | + A time-to-live value for a prompt cache to expire. Uses Golang durations + type: string + example: '10m' diff --git a/conversation/mistral/mistral.go b/conversation/mistral/mistral.go new file mode 100644 index 0000000000..6d97be209f --- /dev/null +++ b/conversation/mistral/mistral.go @@ -0,0 +1,128 @@ +/* +Copyright 2024 The Dapr 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 mistral + +import ( + "context" + "reflect" + + "github.com/dapr/components-contrib/conversation" + "github.com/dapr/components-contrib/metadata" + "github.com/dapr/kit/logger" + kmeta "github.com/dapr/kit/metadata" + + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/mistral" +) + +type Mistral struct { + llm llms.Model + + logger logger.Logger +} + +func NewMistral(logger logger.Logger) conversation.Conversation { + m := &Mistral{ + logger: logger, + } + + return m +} + +const defaultModel = "open-mistral-7b" + +func (m *Mistral) Init(ctx context.Context, meta conversation.Metadata) error { + md := conversation.LangchainMetadata{} + err := kmeta.DecodeMetadata(meta.Properties, &md) + if err != nil { + return err + } + + model := defaultModel + if md.Model != "" { + model = md.Model + } + + llm, err := mistral.New( + mistral.WithModel(model), + mistral.WithAPIKey(md.Key), + ) + if err != nil { + return err + } + + m.llm = llm + + if md.CacheTTL != "" { + cachedModel, cacheErr := conversation.CacheModel(ctx, md.CacheTTL, m.llm) + if cacheErr != nil { + return cacheErr + } + + m.llm = cachedModel + } + return nil +} + +func (m *Mistral) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { + metadataStruct := conversation.LangchainMetadata{} + metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) + return +} + +func (m *Mistral) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) { + messages := make([]llms.MessageContent, 0, len(r.Inputs)) + + for _, input := range r.Inputs { + role := conversation.ConvertLangchainRole(input.Role) + + messages = append(messages, llms.MessageContent{ + Role: role, + Parts: []llms.ContentPart{ + llms.TextPart(input.Message), + }, + }) + } + + opts := []llms.CallOption{} + + if r.Temperature > 0 { + opts = append(opts, conversation.LangchainTemperature(r.Temperature)) + } + + resp, err := m.llm.GenerateContent(ctx, messages, opts...) + if err != nil { + return nil, err + } + + outputs := make([]conversation.ConversationResult, 0, len(resp.Choices)) + + for i := range resp.Choices { + outputs = append(outputs, conversation.ConversationResult{ + Result: resp.Choices[i].Content, + Parameters: r.Parameters, + }) + } + + res = &conversation.ConversationResponse{ + Outputs: outputs, + } + + return res, nil +} + +func (m *Mistral) Close() error { + return nil +} diff --git a/conversation/openai/metadata.yaml b/conversation/openai/metadata.yaml index dfe1abbeb0..d84ca8ee04 100644 --- a/conversation/openai/metadata.yaml +++ b/conversation/openai/metadata.yaml @@ -27,3 +27,9 @@ metadata: The OpenAI LLM to use. Defaults to gpt-4o type: string example: 'gpt-4-turbo' + - name: cacheTTL + required: false + description: | + A time-to-live value for a prompt cache to expire. Uses Golang durations + type: string + example: '10m' diff --git a/conversation/openai/openai.go b/conversation/openai/openai.go index beb164db2e..da9894eb48 100644 --- a/conversation/openai/openai.go +++ b/conversation/openai/openai.go @@ -23,14 +23,12 @@ import ( "github.com/dapr/kit/logger" kmeta "github.com/dapr/kit/metadata" - openai "github.com/sashabaranov/go-openai" + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/openai" ) -const defaultModel = "gpt-4o" - type OpenAI struct { - client *openai.Client - model string + llm llms.Model logger logger.Logger } @@ -43,83 +41,69 @@ func NewOpenAI(logger logger.Logger) conversation.Conversation { return o } +const defaultModel = "gpt-4o" + func (o *OpenAI) Init(ctx context.Context, meta conversation.Metadata) error { - r := &conversation.ConversationRequest{} - err := kmeta.DecodeMetadata(meta.Properties, r) + md := conversation.LangchainMetadata{} + err := kmeta.DecodeMetadata(meta.Properties, &md) if err != nil { return err } - o.client = openai.NewClient(r.Key) - o.model = r.Model + model := defaultModel + if md.Model != "" { + model = md.Model + } - if o.model == "" { - o.model = defaultModel + llm, err := openai.New( + openai.WithModel(model), + openai.WithToken(md.Key), + ) + if err != nil { + return err } + o.llm = llm + + if md.CacheTTL != "" { + cachedModel, cacheErr := conversation.CacheModel(ctx, md.CacheTTL, o.llm) + if cacheErr != nil { + return cacheErr + } + + o.llm = cachedModel + } return nil } func (o *OpenAI) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { - metadataStruct := conversation.ConversationRequest{} + metadataStruct := conversation.LangchainMetadata{} metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.ConversationType) return } -func convertRole(role conversation.Role) string { - switch role { - case conversation.RoleSystem: - return string(openai.ChatMessageRoleSystem) - case conversation.RoleUser: - return string(openai.ChatMessageRoleUser) - case conversation.RoleAssistant: - return string(openai.ChatMessageRoleAssistant) - case conversation.RoleTool: - return string(openai.ChatMessageRoleTool) - case conversation.RoleFunction: - return string(openai.ChatMessageRoleFunction) - default: - return string(openai.ChatMessageRoleUser) - } -} - func (o *OpenAI) Converse(ctx context.Context, r *conversation.ConversationRequest) (res *conversation.ConversationResponse, err error) { - // Note: OPENAI does not support load balance - messages := make([]openai.ChatCompletionMessage, 0, len(r.Inputs)) - - var systemPrompt string + messages := make([]llms.MessageContent, 0, len(r.Inputs)) for _, input := range r.Inputs { - role := convertRole(input.Role) - if role == openai.ChatMessageRoleSystem { - systemPrompt = input.Message - continue - } + role := conversation.ConvertLangchainRole(input.Role) - messages = append(messages, openai.ChatCompletionMessage{ - Role: role, - Content: input.Message, + messages = append(messages, llms.MessageContent{ + Role: role, + Parts: []llms.ContentPart{ + llms.TextPart(input.Message), + }, }) } - // OpenAI needs system prompts to be added last in the array to function properly - if systemPrompt != "" { - messages = append(messages, openai.ChatCompletionMessage{ - Role: openai.ChatMessageRoleSystem, - Content: systemPrompt, - }) - } + opts := []llms.CallOption{} - req := openai.ChatCompletionRequest{ - Model: o.model, - Messages: messages, - Temperature: float32(r.Temperature), + if r.Temperature > 0 { + opts = append(opts, conversation.LangchainTemperature(r.Temperature)) } - // TODO: support ConversationContext - resp, err := o.client.CreateChatCompletion(ctx, req) + resp, err := o.llm.GenerateContent(ctx, messages, opts...) if err != nil { - o.logger.Error(err) return nil, err } @@ -127,14 +111,13 @@ func (o *OpenAI) Converse(ctx context.Context, r *conversation.ConversationReque for i := range resp.Choices { outputs = append(outputs, conversation.ConversationResult{ - Result: resp.Choices[i].Message.Content, + Result: resp.Choices[i].Content, Parameters: r.Parameters, }) } res = &conversation.ConversationResponse{ - ConversationContext: resp.ID, - Outputs: outputs, + Outputs: outputs, } return res, nil diff --git a/conversation/openai/openai_test.go b/conversation/openai/openai_test.go deleted file mode 100644 index 19b0ab085b..0000000000 --- a/conversation/openai/openai_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package openai - -import ( - "testing" - - "github.com/dapr/components-contrib/conversation" - - "github.com/stretchr/testify/assert" - - openai "github.com/sashabaranov/go-openai" -) - -func TestConvertRole(t *testing.T) { - roles := map[string]string{ - conversation.RoleSystem: string(openai.ChatMessageRoleSystem), - conversation.RoleAssistant: string(openai.ChatMessageRoleAssistant), - conversation.RoleFunction: string(openai.ChatMessageRoleFunction), - conversation.RoleUser: string(openai.ChatMessageRoleUser), - conversation.RoleTool: string(openai.ChatMessageRoleTool), - } - - for k, v := range roles { - r := convertRole(conversation.Role(k)) - assert.Equal(t, v, r) - } -} diff --git a/conversation/temperature.go b/conversation/opts.go similarity index 54% rename from conversation/temperature.go rename to conversation/opts.go index 8e4bfa96e2..e67f0717f9 100644 --- a/conversation/temperature.go +++ b/conversation/opts.go @@ -14,9 +14,32 @@ limitations under the License. */ package conversation -import "github.com/tmc/langchaingo/llms" +import ( + "context" + "fmt" + "time" + + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/cache" + "github.com/tmc/langchaingo/llms/cache/inmemory" +) // LangchainTemperature returns a langchain compliant LLM temperature func LangchainTemperature(temperature float64) llms.CallOption { return llms.WithTemperature(temperature) } + +// CacheModel creates a prompt query cache with a configured TTL +func CacheModel(ctx context.Context, ttl string, model llms.Model) (llms.Model, error) { + d, err := time.ParseDuration(ttl) + if err != nil { + return model, fmt.Errorf("failed to parse cacheTTL duration: %s", err) + } + + mem, err := inmemory.New(ctx, inmemory.WithExpiration(d)) + if err != nil { + return model, fmt.Errorf("failed to create llm cache: %s", err) + } + + return cache.New(model, mem), nil +} diff --git a/go.mod b/go.mod index 037e257b23..7ba8abaacb 100644 --- a/go.mod +++ b/go.mod @@ -102,7 +102,6 @@ require ( github.com/rabbitmq/amqp091-go v1.8.1 github.com/redis/go-redis/v9 v9.2.1 github.com/riferrei/srclient v0.6.0 - github.com/sashabaranov/go-openai v1.27.1 github.com/sendgrid/sendgrid-go v3.13.0+incompatible github.com/sijms/go-ora/v2 v2.7.18 github.com/spf13/cast v1.5.1 @@ -155,6 +154,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/Code-Hex/go-generics-cache v1.3.1 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/RoaringBitmap/roaring v1.1.0 // indirect @@ -224,6 +224,7 @@ require ( github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/gage-technologies/mistral-go v1.0.0 // indirect github.com/gavv/httpexpect v2.0.0+incompatible // indirect github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect github.com/go-ini/ini v1.67.0 // indirect diff --git a/go.sum b/go.sum index e33df61840..0b416716e0 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Code-Hex/go-generics-cache v1.3.1 h1:i8rLwyhoyhaerr7JpjtYjJZUcCbWOdiYO3fZXLiEC4g= +github.com/Code-Hex/go-generics-cache v1.3.1/go.mod h1:qxcC9kRVrct9rHeiYpFWSoW1vxyillCVzX13KZG8dl4= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -577,6 +579,8 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/gage-technologies/mistral-go v1.0.0 h1:Hwk0uJO+Iq4kMX/EwbfGRUq9zkO36w7HZ/g53N4N73A= +github.com/gage-technologies/mistral-go v1.0.0/go.mod h1:tF++Xt7U975GcLlzhrjSQb8l/x+PrriO9QEdsgm9l28= github.com/gavv/httpexpect v2.0.0+incompatible h1:1X9kcRshkSKEjNJJxX9Y9mQ5BRfbxU5kORdjhlA1yX8= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/getkin/kin-openapi v0.94.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q= @@ -1438,8 +1442,6 @@ github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIH github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 h1:TToq11gyfNlrMFZiYujSekIsPd9AmsA2Bj/iv+s4JHE= github.com/santhosh-tekuri/jsonschema/v5 v5.0.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= -github.com/sashabaranov/go-openai v1.27.1 h1:7Nx6db5NXbcoutNmAUQulEQZEpHG/SkzfexP2X5RWMk= -github.com/sashabaranov/go-openai v1.27.1/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= From 4644f0d48d7f332aa73f5817e098be2dca07648e Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Thu, 29 Aug 2024 12:03:22 -0500 Subject: [PATCH 08/11] Fix kafka metadata to HTTP headers conversion of invalid characters (#3511) Signed-off-by: Anton Troshin Signed-off-by: Elena Kolevska --- common/component/kafka/consumer.go | 7 ++++--- common/component/kafka/metadata_test.go | 28 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/common/component/kafka/consumer.go b/common/component/kafka/consumer.go index 4b30ed58b8..570689d7df 100644 --- a/common/component/kafka/consumer.go +++ b/common/component/kafka/consumer.go @@ -16,6 +16,7 @@ package kafka import ( "errors" "fmt" + "net/url" "strconv" "sync" "time" @@ -132,7 +133,7 @@ func (consumer *consumer) doBulkCallback(session sarama.ConsumerGroupSession, messages []*sarama.ConsumerMessage, handler BulkEventHandler, topic string, ) error { consumer.k.logger.Debugf("Processing Kafka bulk message: %s", topic) - messageValues := make([]KafkaBulkMessageEntry, (len(messages))) + messageValues := make([]KafkaBulkMessageEntry, len(messages)) for i, message := range messages { if message != nil { @@ -209,14 +210,14 @@ func GetEventMetadata(message *sarama.ConsumerMessage) map[string]string { if message != nil { metadata := make(map[string]string, len(message.Headers)+5) if message.Key != nil { - metadata[keyMetadataKey] = string(message.Key) + metadata[keyMetadataKey] = url.QueryEscape(string(message.Key)) } metadata[offsetMetadataKey] = strconv.FormatInt(message.Offset, 10) metadata[topicMetadataKey] = message.Topic metadata[timestampMetadataKey] = strconv.FormatInt(message.Timestamp.UnixMilli(), 10) metadata[partitionMetadataKey] = strconv.FormatInt(int64(message.Partition), 10) for _, header := range message.Headers { - metadata[string(header.Key)] = string(header.Value) + metadata[string(header.Key)] = url.QueryEscape(string(header.Value)) } return metadata } diff --git a/common/component/kafka/metadata_test.go b/common/component/kafka/metadata_test.go index 3006f5f3fd..6e25d309ad 100644 --- a/common/component/kafka/metadata_test.go +++ b/common/component/kafka/metadata_test.go @@ -15,6 +15,7 @@ package kafka import ( "fmt" + "net/url" "strconv" "testing" "time" @@ -556,4 +557,31 @@ func TestGetEventMetadata(t *testing.T) { act := GetEventMetadata(nil) require.Nil(t, act) }) + + t.Run("key with invalid value escaped", func(t *testing.T) { + keyValue := "key1\xFF" + escapedKeyValue := url.QueryEscape(keyValue) + + m := sarama.ConsumerMessage{ + Headers: nil, Timestamp: ts, Key: []byte(keyValue), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", + } + act := GetEventMetadata(&m) + require.Equal(t, escapedKeyValue, act[keyMetadataKey]) + }) + + t.Run("header with invalid value escaped", func(t *testing.T) { + headerKey := "key1" + headerValue := "value1\xFF" + escapedHeaderValue := url.QueryEscape(headerValue) + + headers := []*sarama.RecordHeader{ + {Key: []byte(headerKey), Value: []byte(headerValue)}, + } + m := sarama.ConsumerMessage{ + Headers: headers, Timestamp: ts, Key: []byte("MyKey"), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", + } + act := GetEventMetadata(&m) + require.Len(t, act, 6) + require.Equal(t, escapedHeaderValue, act[headerKey]) + }) } From ab23680a61eaf5ce3602884fadcb8982c80df91d Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Fri, 30 Aug 2024 18:37:43 -0500 Subject: [PATCH 09/11] Add Kafka metadata opt-in setting to escapeHeaders (#3524) Signed-off-by: Anton Troshin Signed-off-by: Elena Kolevska --- bindings/kafka/metadata.yaml | 10 +++++- common/component/kafka/consumer.go | 18 ++++++++--- common/component/kafka/kafka.go | 2 ++ common/component/kafka/metadata.go | 2 ++ common/component/kafka/metadata_test.go | 41 ++++++++++++++++++++----- pubsub/kafka/metadata.yaml | 10 +++++- 6 files changed, 68 insertions(+), 15 deletions(-) diff --git a/bindings/kafka/metadata.yaml b/bindings/kafka/metadata.yaml index 3b1a077a7b..ab24f3e8fe 100644 --- a/bindings/kafka/metadata.yaml +++ b/bindings/kafka/metadata.yaml @@ -331,4 +331,12 @@ metadata: description: | The TTL for schema caching when publishing a message with latest schema available. example: '"5m"' - default: '"5m"' \ No newline at end of file + default: '"5m"' + - name: escapeHeaders + type: bool + required: false + description: | + Enables URL escaping of the message header values. + It allows sending headers with special characters that are usually not allowed in HTTP headers. + example: "true" + default: "false" diff --git a/common/component/kafka/consumer.go b/common/component/kafka/consumer.go index 570689d7df..7cb923a455 100644 --- a/common/component/kafka/consumer.go +++ b/common/component/kafka/consumer.go @@ -137,7 +137,7 @@ func (consumer *consumer) doBulkCallback(session sarama.ConsumerGroupSession, for i, message := range messages { if message != nil { - metadata := GetEventMetadata(message) + metadata := GetEventMetadata(message, consumer.k.escapeHeaders) handlerConfig, err := consumer.k.GetTopicHandlerConfig(message.Topic) if err != nil { return err @@ -197,7 +197,7 @@ func (consumer *consumer) doCallback(session sarama.ConsumerGroupSession, messag Topic: message.Topic, Data: messageVal, } - event.Metadata = GetEventMetadata(message) + event.Metadata = GetEventMetadata(message, consumer.k.escapeHeaders) err = handlerConfig.Handler(session.Context(), &event) if err == nil { @@ -206,18 +206,26 @@ func (consumer *consumer) doCallback(session sarama.ConsumerGroupSession, messag return err } -func GetEventMetadata(message *sarama.ConsumerMessage) map[string]string { +func GetEventMetadata(message *sarama.ConsumerMessage, escapeHeaders bool) map[string]string { if message != nil { metadata := make(map[string]string, len(message.Headers)+5) if message.Key != nil { - metadata[keyMetadataKey] = url.QueryEscape(string(message.Key)) + if escapeHeaders { + metadata[keyMetadataKey] = url.QueryEscape(string(message.Key)) + } else { + metadata[keyMetadataKey] = string(message.Key) + } } metadata[offsetMetadataKey] = strconv.FormatInt(message.Offset, 10) metadata[topicMetadataKey] = message.Topic metadata[timestampMetadataKey] = strconv.FormatInt(message.Timestamp.UnixMilli(), 10) metadata[partitionMetadataKey] = strconv.FormatInt(int64(message.Partition), 10) for _, header := range message.Headers { - metadata[string(header.Key)] = url.QueryEscape(string(header.Value)) + if escapeHeaders { + metadata[string(header.Key)] = url.QueryEscape(string(header.Value)) + } else { + metadata[string(header.Key)] = string(header.Value) + } } return metadata } diff --git a/common/component/kafka/kafka.go b/common/component/kafka/kafka.go index 3f3bfca8c4..28883b2c1e 100644 --- a/common/component/kafka/kafka.go +++ b/common/component/kafka/kafka.go @@ -45,6 +45,7 @@ type Kafka struct { saslPassword string initialOffset int64 config *sarama.Config + escapeHeaders bool cg sarama.ConsumerGroup subscribeTopics TopicHandlerConfig @@ -136,6 +137,7 @@ func (k *Kafka) Init(ctx context.Context, metadata map[string]string) error { k.consumerGroup = meta.ConsumerGroup k.initialOffset = meta.internalInitialOffset k.authType = meta.AuthType + k.escapeHeaders = meta.EscapeHeaders config := sarama.NewConfig() config.Version = meta.internalVersion diff --git a/common/component/kafka/metadata.go b/common/component/kafka/metadata.go index 4c1c175cd8..020d61d52b 100644 --- a/common/component/kafka/metadata.go +++ b/common/component/kafka/metadata.go @@ -89,6 +89,7 @@ type KafkaMetadata struct { HeartbeatInterval time.Duration `mapstructure:"heartbeatInterval"` SessionTimeout time.Duration `mapstructure:"sessionTimeout"` Version string `mapstructure:"version"` + EscapeHeaders bool `mapstructure:"escapeHeaders"` internalVersion sarama.KafkaVersion `mapstructure:"-"` internalOidcExtensions map[string]string `mapstructure:"-"` @@ -162,6 +163,7 @@ func (k *Kafka) getKafkaMetadata(meta map[string]string) (*KafkaMetadata, error) ClientConnectionKeepAliveInterval: defaultClientConnectionKeepAliveInterval, HeartbeatInterval: 3 * time.Second, SessionTimeout: 10 * time.Second, + EscapeHeaders: false, } err := metadata.DecodeMetadata(meta, &m) diff --git a/common/component/kafka/metadata_test.go b/common/component/kafka/metadata_test.go index 6e25d309ad..e53b1721d8 100644 --- a/common/component/kafka/metadata_test.go +++ b/common/component/kafka/metadata_test.go @@ -513,7 +513,7 @@ func TestGetEventMetadata(t *testing.T) { m := sarama.ConsumerMessage{ Headers: nil, Timestamp: ts, Key: []byte("MyKey"), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", } - act := GetEventMetadata(&m) + act := GetEventMetadata(&m, false) require.Len(t, act, 5) require.Equal(t, strconv.FormatInt(ts.UnixMilli(), 10), act["__timestamp"]) require.Equal(t, "MyKey", act["__key"]) @@ -530,7 +530,7 @@ func TestGetEventMetadata(t *testing.T) { m := sarama.ConsumerMessage{ Headers: headers, Timestamp: ts, Key: []byte("MyKey"), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", } - act := GetEventMetadata(&m) + act := GetEventMetadata(&m, false) require.Len(t, act, 7) require.Equal(t, strconv.FormatInt(ts.UnixMilli(), 10), act["__timestamp"]) require.Equal(t, "MyKey", act["__key"]) @@ -545,7 +545,7 @@ func TestGetEventMetadata(t *testing.T) { m := sarama.ConsumerMessage{ Headers: nil, Timestamp: ts, Key: nil, Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", } - act := GetEventMetadata(&m) + act := GetEventMetadata(&m, false) require.Len(t, act, 4) require.Equal(t, strconv.FormatInt(ts.UnixMilli(), 10), act["__timestamp"]) require.Equal(t, "0", act["__partition"]) @@ -554,22 +554,32 @@ func TestGetEventMetadata(t *testing.T) { }) t.Run("null message", func(t *testing.T) { - act := GetEventMetadata(nil) + act := GetEventMetadata(nil, false) require.Nil(t, act) }) - t.Run("key with invalid value escaped", func(t *testing.T) { + t.Run("key with invalid value escapeHeaders true", func(t *testing.T) { keyValue := "key1\xFF" escapedKeyValue := url.QueryEscape(keyValue) m := sarama.ConsumerMessage{ Headers: nil, Timestamp: ts, Key: []byte(keyValue), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", } - act := GetEventMetadata(&m) + act := GetEventMetadata(&m, true) require.Equal(t, escapedKeyValue, act[keyMetadataKey]) }) - t.Run("header with invalid value escaped", func(t *testing.T) { + t.Run("key with invalid value escapeHeaders false", func(t *testing.T) { + keyValue := "key1\xFF" + + m := sarama.ConsumerMessage{ + Headers: nil, Timestamp: ts, Key: []byte(keyValue), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", + } + act := GetEventMetadata(&m, false) + require.Equal(t, keyValue, act[keyMetadataKey]) + }) + + t.Run("header with invalid value escapeHeaders true", func(t *testing.T) { headerKey := "key1" headerValue := "value1\xFF" escapedHeaderValue := url.QueryEscape(headerValue) @@ -580,8 +590,23 @@ func TestGetEventMetadata(t *testing.T) { m := sarama.ConsumerMessage{ Headers: headers, Timestamp: ts, Key: []byte("MyKey"), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", } - act := GetEventMetadata(&m) + act := GetEventMetadata(&m, true) require.Len(t, act, 6) require.Equal(t, escapedHeaderValue, act[headerKey]) }) + + t.Run("header with invalid value escapeHeaders false", func(t *testing.T) { + headerKey := "key1" + headerValue := "value1\xFF" + + headers := []*sarama.RecordHeader{ + {Key: []byte(headerKey), Value: []byte(headerValue)}, + } + m := sarama.ConsumerMessage{ + Headers: headers, Timestamp: ts, Key: []byte("MyKey"), Value: []byte("MyValue"), Partition: 0, Offset: 123, Topic: "TestTopic", + } + act := GetEventMetadata(&m, false) + require.Len(t, act, 6) + require.Equal(t, headerValue, act[headerKey]) + }) } diff --git a/pubsub/kafka/metadata.yaml b/pubsub/kafka/metadata.yaml index 8d3638e837..b6536c2b43 100644 --- a/pubsub/kafka/metadata.yaml +++ b/pubsub/kafka/metadata.yaml @@ -322,4 +322,12 @@ metadata: description: | The TTL for schema caching when publishing a message with latest schema available. example: '"5m"' - default: '"5m"' \ No newline at end of file + default: '"5m"' + - name: escapeHeaders + type: bool + required: false + description: | + Enables URL escaping of the message header values. + It allows sending headers with special characters that are usually not allowed in HTTP headers. + example: "true" + default: "false" From e8308a3168463fdda8fe6b0190f541219c118c94 Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Thu, 5 Sep 2024 16:46:48 -0500 Subject: [PATCH 10/11] Lint fixes (#3526) Signed-off-by: Anton Troshin Co-authored-by: Bernd Verst <4535280+berndverst@users.noreply.github.com> Signed-off-by: Elena Kolevska --- .golangci.yml | 7 ++ Makefile | 4 +- bindings/alicloud/sls/sls.go | 10 +-- bindings/alicloud/tablestore/tablestore.go | 2 - bindings/aws/kinesis/kinesis.go | 1 - bindings/aws/s3/s3.go | 4 +- bindings/aws/ses/ses.go | 7 +- bindings/azure/blobstorage/blobstorage.go | 5 +- bindings/azure/cosmosdb/cosmosdb.go | 5 +- bindings/azure/signalr/signalr.go | 10 +-- bindings/azure/signalr/signalr_test.go | 1 - bindings/azure/storagequeues/storagequeues.go | 2 +- bindings/commercetools/commercetools.go | 2 +- bindings/cron/cron.go | 2 +- bindings/cron/cron_test.go | 4 +- bindings/gcp/bucket/bucket.go | 6 +- bindings/graphql/graphql.go | 7 +- bindings/http/http.go | 2 +- bindings/http/http_test.go | 2 +- bindings/huawei/obs/obs.go | 12 +-- bindings/huawei/obs/obs_test.go | 19 +++-- bindings/input_binding.go | 4 +- bindings/kubemq/options.go | 16 ++-- bindings/mqtt3/mqtt.go | 4 +- bindings/mysql/mysql.go | 4 +- bindings/mysql/mysql_integration_test.go | 6 +- bindings/output_binding.go | 4 +- bindings/postgres/postgres_test.go | 4 +- bindings/postmark/postmark.go | 6 +- bindings/rocketmq/rocketmq.go | 2 +- bindings/rocketmq/rocketmq_test.go | 2 +- bindings/smtp/smtp.go | 7 +- bindings/twilio/sendgrid/sendgrid.go | 6 +- bindings/wasm/output.go | 3 +- bindings/wasm/output_test.go | 6 +- bindings/zeebe/jobworker/jobworker.go | 2 +- common/authentication/aws/aws.go | 2 +- common/authentication/azure/auth.go | 4 +- common/authentication/sqlite/metadata.go | 2 +- common/authentication/sqlserver/metadata.go | 4 +- common/component/azure/blobstorage/client.go | 2 +- common/component/azure/blobstorage/request.go | 8 +- common/component/azure/eventhubs/eventhubs.go | 6 +- common/component/azure/servicebus/client.go | 2 +- .../azure/servicebus/message_pubsub_test.go | 1 - .../azure/servicebus/subscription.go | 4 +- .../component/cloudflare/workers/workers.go | 3 +- common/component/kafka/auth.go | 2 +- common/component/kafka/kafka.go | 2 +- common/component/kafka/sasl_oauthbearer.go | 5 +- common/component/kafka/subscriber_test.go | 2 +- common/component/redis/redis.go | 2 +- .../postgres/postgres_migrations.go | 2 +- .../sqlserver/sqlserver_migrations_test.go | 6 +- configuration/azure/appconfig/appconfig.go | 2 +- .../azure/appconfig/appconfig_test.go | 4 +- configuration/postgres/metadata.go | 3 +- crypto/pubkey_cache_test.go | 2 +- lock/redis/standalone.go | 2 +- metadata/utils.go | 2 +- middleware/http/sentinel/middleware_test.go | 3 +- middleware/http/wasm/benchmark_test.go | 4 +- middleware/http/wasm/internal/e2e_test.go | 2 +- nameresolution/consul/configuration.go | 8 +- nameresolution/consul/consul.go | 2 +- nameresolution/consul/consul_test.go | 21 ++--- nameresolution/consul/watcher.go | 2 +- nameresolution/mdns/mdns.go | 4 +- nameresolution/mdns/mdns_test.go | 16 ++-- nameresolution/sqlite/sqlite_test.go | 2 +- pubsub/aws/snssqs/metadata.go | 2 +- pubsub/aws/snssqs/snssqs.go | 4 +- pubsub/aws/snssqs/snssqs_test.go | 2 +- pubsub/azure/servicebus/topics/servicebus.go | 2 +- pubsub/envelope_test.go | 4 +- pubsub/gcp/pubsub/pubsub.go | 2 +- pubsub/in-memory/in-memory.go | 2 +- pubsub/jetstream/metadata.go | 11 +-- pubsub/kubemq/kubemq_events.go | 3 +- pubsub/kubemq/kubemq_events_test.go | 6 +- pubsub/kubemq/kubemq_eventstore.go | 5 +- pubsub/kubemq/kubemq_eventstore_test.go | 8 +- pubsub/kubemq/metadata.go | 10 +-- pubsub/mqtt3/mqtt.go | 2 +- pubsub/pubsub.go | 4 +- pubsub/pulsar/pulsar.go | 4 +- pubsub/rabbitmq/metadata_test.go | 16 ++-- pubsub/rabbitmq/rabbitmq.go | 6 +- pubsub/redis/redis.go | 2 +- pubsub/solace/amqp/amqp.go | 2 - pubsub/tls.go | 2 +- .../parameterstore/parameterstore_test.go | 6 +- .../aws/parameterstore/parameterstore_test.go | 7 +- .../aws/secretmanager/secretmanager_test.go | 4 +- .../gcp/secretmanager/secretmanager.go | 17 ++-- .../gcp/secretmanager/secretmanager_test.go | 12 +-- secretstores/hashicorp/vault/vault.go | 8 +- secretstores/huaweicloud/csms/csms_test.go | 8 +- secretstores/local/file/filestore.go | 4 +- secretstores/local/file/filestore_test.go | 3 +- secretstores/secret_store.go | 4 +- secretstores/tencentcloud/ssm/ssm_test.go | 8 +- state/aws/dynamodb/dynamodb_test.go | 9 +-- .../azure/blobstorage/internal/blobstorage.go | 1 - .../blobstorage/internal/blobstorage_test.go | 4 +- state/azure/cosmosdb/cosmosdb_query.go | 5 +- state/azure/tablestorage/tablestorage.go | 1 - state/bulk.go | 4 +- state/bulk_test.go | 2 +- state/cassandra/cassandra.go | 2 +- .../cockroachdb_integration_test.go | 24 +++--- state/couchbase/couchbase.go | 9 ++- state/gcp/firestore/firestore.go | 1 - state/hazelcast/hazelcast.go | 2 - state/memcached/memcached.go | 4 +- state/mongodb/mongodb_query.go | 2 +- state/mysql/mySQLFactory.go | 4 +- state/mysql/mysql.go | 8 +- state/mysql/mysql_integration_test.go | 8 +- state/mysql/mysql_test.go | 15 ++-- state/oci/objectstorage/objectstorage.go | 11 +-- .../objectstorage_integration_test.go | 6 +- state/oci/objectstorage/objectstorage_test.go | 24 +++--- .../oracledatabase_integration_test.go | 24 +++--- .../v1/postgresql_integration_test.go | 22 ++--- .../v2/postgresql_integration_test.go | 22 ++--- state/query/filter.go | 35 ++++---- state/redis/redis.go | 4 +- state/redis/redis_query.go | 14 ++-- state/redis/redis_query_schema.go | 5 +- state/requests.go | 4 +- state/rethinkdb/rethinkdb_test.go | 2 +- state/sqlite/sqlite_dbaccess.go | 2 +- state/sqlite/sqlite_integration_test.go | 22 ++--- state/sqlserver/metadata.go | 10 +-- state/sqlserver/migration.go | 2 +- state/sqlserver/sqlserver_integration_test.go | 6 +- tests/conformance/pubsub/pubsub.go | 2 +- tests/conformance/state/state.go | 80 +++++++++---------- .../utils/configupdater/postgres/postgres.go | 9 ++- 140 files changed, 456 insertions(+), 463 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index dcc8354447..acc05ada09 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -261,6 +261,11 @@ linters-settings: allow-case-traling-whitespace: true # Allow declarations (var) to be cuddled. allow-cuddle-declarations: false + testifylint: + disable: + - float-compare + - negative-positive + - go-require linters: fast: false @@ -317,3 +322,5 @@ linters: - goconst - tagalign - inamedparam + - canonicalheader + - fatcontext diff --git a/Makefile b/Makefile index d2e37480f7..a97cfbd37e 100644 --- a/Makefile +++ b/Makefile @@ -119,9 +119,9 @@ test: lint: verify-linter-installed verify-linter-version ifdef LINT_BASE @echo "LINT_BASE is set to "$(LINT_BASE)". Linter will only check diff." - $(GOLANGCI_LINT) run --timeout=20m --new-from-rev $(shell git rev-parse $(LINT_BASE)) + $(GOLANGCI_LINT) run --timeout=20m --max-same-issues 0 --max-issues-per-linter 0 --new-from-rev $(shell git rev-parse $(LINT_BASE)) else - $(GOLANGCI_LINT) run --timeout=20m + $(GOLANGCI_LINT) run --timeout=20m --max-same-issues 0 --max-issues-per-linter 0 endif ################################################################################ diff --git a/bindings/alicloud/sls/sls.go b/bindings/alicloud/sls/sls.go index 84ea79690f..7c80174a09 100644 --- a/bindings/alicloud/sls/sls.go +++ b/bindings/alicloud/sls/sls.go @@ -3,7 +3,7 @@ package sls import ( "context" "encoding/json" - "fmt" + "errors" "reflect" "time" @@ -61,16 +61,16 @@ func NewAliCloudSlsLogstorage(logger logger.Logger) bindings.OutputBinding { func (s *AliCloudSlsLogstorage) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) { // verify the metadata property if logProject := req.Metadata["project"]; logProject == "" { - return nil, fmt.Errorf("SLS binding error: project property not supplied") + return nil, errors.New("SLS binding error: project property not supplied") } if logstore := req.Metadata["logstore"]; logstore == "" { - return nil, fmt.Errorf("SLS binding error: logstore property not supplied") + return nil, errors.New("SLS binding error: logstore property not supplied") } if topic := req.Metadata["topic"]; topic == "" { - return nil, fmt.Errorf("SLS binding error: topic property not supplied") + return nil, errors.New("SLS binding error: topic property not supplied") } if source := req.Metadata["source"]; source == "" { - return nil, fmt.Errorf("SLS binding error: source property not supplied") + return nil, errors.New("SLS binding error: source property not supplied") } log, err := s.parseLog(req) diff --git a/bindings/alicloud/tablestore/tablestore.go b/bindings/alicloud/tablestore/tablestore.go index 13cc61aa98..c153f2c1e0 100644 --- a/bindings/alicloud/tablestore/tablestore.go +++ b/bindings/alicloud/tablestore/tablestore.go @@ -271,7 +271,6 @@ func (s *AliCloudTableStore) create(req *bindings.InvokeRequest, resp *bindings. } _, err = s.client.PutRow(putRequest) - if err != nil { return err } @@ -302,7 +301,6 @@ func (s *AliCloudTableStore) delete(req *bindings.InvokeRequest, resp *bindings. change.SetCondition(tablestore.RowExistenceExpectation_IGNORE) //nolint:nosnakecase deleteReq := &tablestore.DeleteRowRequest{DeleteRowChange: change} _, err = s.client.DeleteRow(deleteReq) - if err != nil { return err } diff --git a/bindings/aws/kinesis/kinesis.go b/bindings/aws/kinesis/kinesis.go index 94bf590bb4..dbe0ceb918 100644 --- a/bindings/aws/kinesis/kinesis.go +++ b/bindings/aws/kinesis/kinesis.go @@ -300,7 +300,6 @@ func (a *AWSKinesis) registerConsumer(ctx context.Context, streamARN *string) (* ConsumerName: &a.metadata.ConsumerName, StreamARN: streamARN, }) - if err != nil { return nil, err } diff --git a/bindings/aws/s3/s3.go b/bindings/aws/s3/s3.go index 70a0c8a518..cc67cec94f 100644 --- a/bindings/aws/s3/s3.go +++ b/bindings/aws/s3/s3.go @@ -313,7 +313,7 @@ func (s *AWSS3) get(ctx context.Context, req *bindings.InvokeRequest) (*bindings if err != nil { var awsErr awserr.Error if errors.As(err, &awsErr) && awsErr.Code() == s3.ErrCodeNoSuchKey { - return nil, fmt.Errorf("object not found") + return nil, errors.New("object not found") } return nil, fmt.Errorf("s3 binding error: error downloading S3 object: %w", err) } @@ -348,7 +348,7 @@ func (s *AWSS3) delete(ctx context.Context, req *bindings.InvokeRequest) (*bindi if err != nil { var awsErr awserr.Error if errors.As(err, &awsErr) && awsErr.Code() == s3.ErrCodeNoSuchKey { - return nil, fmt.Errorf("object not found") + return nil, errors.New("object not found") } return nil, fmt.Errorf("s3 binding error: delete operation failed: %w", err) } diff --git a/bindings/aws/ses/ses.go b/bindings/aws/ses/ses.go index 6b59657c9c..483fde8c64 100644 --- a/bindings/aws/ses/ses.go +++ b/bindings/aws/ses/ses.go @@ -15,6 +15,7 @@ package ses import ( "context" + "errors" "fmt" "reflect" "strconv" @@ -92,13 +93,13 @@ func (a *AWSSES) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bind metadata := a.metadata.mergeWithRequestMetadata(req) if metadata.EmailFrom == "" { - return nil, fmt.Errorf("SES binding error: emailFrom property not supplied in configuration- or request-metadata") + return nil, errors.New("SES binding error: emailFrom property not supplied in configuration- or request-metadata") } if metadata.EmailTo == "" { - return nil, fmt.Errorf("SES binding error: emailTo property not supplied in configuration- or request-metadata") + return nil, errors.New("SES binding error: emailTo property not supplied in configuration- or request-metadata") } if metadata.Subject == "" { - return nil, fmt.Errorf("SES binding error: subject property not supplied in configuration- or request-metadata") + return nil, errors.New("SES binding error: subject property not supplied in configuration- or request-metadata") } body, err := strconv.Unquote(string(req.Data)) diff --git a/bindings/azure/blobstorage/blobstorage.go b/bindings/azure/blobstorage/blobstorage.go index ba38ae9b6d..b132f9bf4a 100644 --- a/bindings/azure/blobstorage/blobstorage.go +++ b/bindings/azure/blobstorage/blobstorage.go @@ -154,7 +154,6 @@ func (a *AzureBlobStorage) create(ctx context.Context, req *bindings.InvokeReque blockBlobClient := a.containerClient.NewBlockBlobClient(blobName) _, err = blockBlobClient.UploadBuffer(ctx, req.Data, &uploadOptions) - if err != nil { return nil, fmt.Errorf("error uploading az blob: %w", err) } @@ -192,7 +191,7 @@ func (a *AzureBlobStorage) get(ctx context.Context, req *bindings.InvokeRequest) blobDownloadResponse, err := blockBlobClient.DownloadStream(ctx, &downloadOptions) if err != nil { if bloberror.HasCode(err, bloberror.BlobNotFound) { - return nil, fmt.Errorf("blob not found") + return nil, errors.New("blob not found") } return nil, fmt.Errorf("error downloading az blob: %w", err) } @@ -261,7 +260,7 @@ func (a *AzureBlobStorage) delete(ctx context.Context, req *bindings.InvokeReque _, err := blockBlobClient.Delete(ctx, &deleteOptions) if bloberror.HasCode(err, bloberror.BlobNotFound) { - return nil, fmt.Errorf("blob not found") + return nil, errors.New("blob not found") } return nil, err diff --git a/bindings/azure/cosmosdb/cosmosdb.go b/bindings/azure/cosmosdb/cosmosdb.go index 41571a1042..c210d440ec 100644 --- a/bindings/azure/cosmosdb/cosmosdb.go +++ b/bindings/azure/cosmosdb/cosmosdb.go @@ -16,6 +16,7 @@ package cosmosdb import ( "context" "encoding/json" + "errors" "fmt" "reflect" "strings" @@ -158,7 +159,7 @@ func (c *CosmosDB) getPartitionKeyValue(key string, obj interface{}) (string, er } val, ok := valI.(string) if !ok { - return "", fmt.Errorf("partition key is not a string") + return "", errors.New("partition key is not a string") } if val == "" { @@ -172,7 +173,7 @@ func (c *CosmosDB) lookup(m map[string]interface{}, ks []string) (val interface{ var ok bool if len(ks) == 0 { - return nil, fmt.Errorf("needs at least one key") + return nil, errors.New("needs at least one key") } if val, ok = m[ks[0]]; !ok { diff --git a/bindings/azure/signalr/signalr.go b/bindings/azure/signalr/signalr.go index 23d1804477..c0de8dd358 100644 --- a/bindings/azure/signalr/signalr.go +++ b/bindings/azure/signalr/signalr.go @@ -156,7 +156,7 @@ func (s *SignalR) parseMetadata(md map[string]string) (err error) { s.accessKey = connectionValue[i+1:] case "AuthType": if connectionValue[i+1:] != "aad" { - return fmt.Errorf("invalid value for AuthType in the connection string; only 'aad' is supported") + return errors.New("invalid value for AuthType in the connection string; only 'aad' is supported") } useAAD = true case "ClientId", "ClientSecret", "TenantId": @@ -171,14 +171,14 @@ func (s *SignalR) parseMetadata(md map[string]string) (err error) { } } } else if len(connectionValue) != 0 { - return fmt.Errorf("the connection string is invalid or malformed") + return errors.New("the connection string is invalid or malformed") } } // Check here because if we use a connection string, we'd have an explicit "AuthType=aad" option // We would otherwise catch this issue later, but here we can be more explicit with the error if s.accessKey == "" && !useAAD { - return fmt.Errorf("missing AccessKey in the connection string") + return errors.New("missing AccessKey in the connection string") } } @@ -198,7 +198,7 @@ func (s *SignalR) parseMetadata(md map[string]string) (err error) { // Check for required values if s.endpoint == "" { - return fmt.Errorf("missing endpoint in the metadata or connection string") + return errors.New("missing endpoint in the metadata or connection string") } return nil @@ -333,7 +333,7 @@ func (s *SignalR) GetAadClientAccessToken(ctx context.Context, hub string, user u := fmt.Sprintf("%s/api/hubs/%s/:generateToken?api-version=%s", s.endpoint, hub, apiVersion) if user != "" { - u += fmt.Sprintf("&userId=%s", url.QueryEscape(user)) + u += "&userId=" + url.QueryEscape(user) } body, err := s.sendRequestToSignalR(ctx, u, aadToken, nil) diff --git a/bindings/azure/signalr/signalr_test.go b/bindings/azure/signalr/signalr_test.go index 44d7121c28..fef7b94abd 100644 --- a/bindings/azure/signalr/signalr_test.go +++ b/bindings/azure/signalr/signalr_test.go @@ -394,7 +394,6 @@ func TestWriteShouldSucceed(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { httpTransport.reset() s.hub = tt.hubInMetadata diff --git a/bindings/azure/storagequeues/storagequeues.go b/bindings/azure/storagequeues/storagequeues.go index 78e5540281..aa14f00d2e 100644 --- a/bindings/azure/storagequeues/storagequeues.go +++ b/bindings/azure/storagequeues/storagequeues.go @@ -220,7 +220,7 @@ func (d *AzureQueueHelper) Read(ctx context.Context, consumer *consumer) error { } return nil } else { - return fmt.Errorf("could not delete message from queue: message ID or pop receipt is nil") + return errors.New("could not delete message from queue: message ID or pop receipt is nil") } } diff --git a/bindings/commercetools/commercetools.go b/bindings/commercetools/commercetools.go index 7efd4053cf..1da4183e63 100644 --- a/bindings/commercetools/commercetools.go +++ b/bindings/commercetools/commercetools.go @@ -65,7 +65,7 @@ func (ct *Binding) Init(_ context.Context, metadata bindings.Metadata) error { baseURLdomain := fmt.Sprintf("%s.%s.commercetools.com", commercetoolsM.Region, commercetoolsM.Provider) authURL := fmt.Sprintf("https://auth.%s/oauth/token", baseURLdomain) - apiURL := fmt.Sprintf("https://api.%s", baseURLdomain) + apiURL := "https://api." + baseURLdomain // Create the new client. When an empty value is passed it will use the CTP_* // environment variables to get the value. The HTTPClient arg is optional, diff --git a/bindings/cron/cron.go b/bindings/cron/cron.go index cefd4057f5..dec1faa2ae 100644 --- a/bindings/cron/cron.go +++ b/bindings/cron/cron.go @@ -76,7 +76,7 @@ func (b *Binding) Init(ctx context.Context, meta bindings.Metadata) error { return err } if m.Schedule == "" { - return fmt.Errorf("schedule not set") + return errors.New("schedule not set") } _, err = b.parser.Parse(m.Schedule) if err != nil { diff --git a/bindings/cron/cron_test.go b/bindings/cron/cron_test.go index e64dd6eb07..06c2024209 100644 --- a/bindings/cron/cron_test.go +++ b/bindings/cron/cron_test.go @@ -109,7 +109,7 @@ func TestCronRead(t *testing.T) { return nil, nil }) // Check if cron triggers 5 times in 5 seconds - for i := int32(0); i < expectedCount; i++ { + for range expectedCount { // Add time to mock clock in 1 second intervals using loop to allow cron go routine to run clk.Step(time.Second) runtime.Gosched() @@ -143,7 +143,7 @@ func TestCronReadWithContextCancellation(t *testing.T) { return nil, nil }) // Check if cron triggers only 5 times in 10 seconds since context should be cancelled after 5 triggers - for i := 0; i < 10; i++ { + for range 10 { // Add time to mock clock in 1 second intervals using loop to allow cron go routine to run clk.Step(time.Second) runtime.Gosched() diff --git a/bindings/gcp/bucket/bucket.go b/bindings/gcp/bucket/bucket.go index 7fa929ae40..2a8b5e1faa 100644 --- a/bindings/gcp/bucket/bucket.go +++ b/bindings/gcp/bucket/bucket.go @@ -220,7 +220,7 @@ func (g *GCPStorage) get(ctx context.Context, req *bindings.InvokeRequest) (*bin if val, ok := req.Metadata[metadataKey]; ok && val != "" { key = val } else { - return nil, fmt.Errorf("gcp bucket binding error: can't read key value") + return nil, errors.New("gcp bucket binding error: can't read key value") } var rc io.ReadCloser @@ -256,7 +256,7 @@ func (g *GCPStorage) delete(ctx context.Context, req *bindings.InvokeRequest) (* if val, ok := req.Metadata[metadataKey]; ok && val != "" { key = val } else { - return nil, fmt.Errorf("gcp bucketgcp bucket binding error: can't read key value") + return nil, errors.New("gcp bucketgcp bucket binding error: can't read key value") } object := g.client.Bucket(g.metadata.Bucket).Object(key) @@ -355,7 +355,7 @@ func (g *GCPStorage) sign(ctx context.Context, req *bindings.InvokeRequest) (*bi if val, ok := req.Metadata[metadataKey]; ok && val != "" { key = val } else { - return nil, fmt.Errorf("gcp bucket binding error: can't read key value") + return nil, errors.New("gcp bucket binding error: can't read key value") } if metadata.SignTTL == "" { diff --git a/bindings/graphql/graphql.go b/bindings/graphql/graphql.go index 606c04253c..55cf556e3d 100644 --- a/bindings/graphql/graphql.go +++ b/bindings/graphql/graphql.go @@ -16,6 +16,7 @@ package graphql import ( "context" "encoding/json" + "errors" "fmt" "reflect" "regexp" @@ -73,7 +74,7 @@ func (gql *GraphQL) Init(_ context.Context, meta bindings.Metadata) error { } if m.Endpoint == "" { - return fmt.Errorf("GraphQL Error: Missing GraphQL URL") + return errors.New("GraphQL Error: Missing GraphQL URL") } // Connect to GraphQL Server @@ -101,11 +102,11 @@ func (gql *GraphQL) Operations() []bindings.OperationKind { // Invoke handles all invoke operations. func (gql *GraphQL) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) { if req == nil { - return nil, fmt.Errorf("GraphQL Error: Invoke request required") + return nil, errors.New("GraphQL Error: Invoke request required") } if req.Metadata == nil { - return nil, fmt.Errorf("GraphQL Error: Metadata required") + return nil, errors.New("GraphQL Error: Metadata required") } gql.logger.Debugf("operation: %v", req.Operation) diff --git a/bindings/http/http.go b/bindings/http/http.go index 6e401308cb..e79de5964a 100644 --- a/bindings/http/http.go +++ b/bindings/http/http.go @@ -354,7 +354,7 @@ func (h *HTTPSource) Invoke(parentCtx context.Context, req *bindings.InvokeReque } // Create an error for non-200 status codes unless suppressed. - if errorIfNot2XX && resp.StatusCode/100 != 2 { + if errorIfNot2XX && resp.StatusCode/100 != 2 { //nolint:usestdlibvars err = fmt.Errorf("received status code %d", resp.StatusCode) } diff --git a/bindings/http/http_test.go b/bindings/http/http_test.go index ecc297d7b3..58661f35f9 100644 --- a/bindings/http/http_test.go +++ b/bindings/http/http_test.go @@ -330,7 +330,7 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { h.Path = req.URL.Path if strings.TrimPrefix(h.Path, "/") == "large" { // Write 5KB - for i := 0; i < 1<<10; i++ { + for range 1 << 10 { fmt.Fprint(w, "12345") } return diff --git a/bindings/huawei/obs/obs.go b/bindings/huawei/obs/obs.go index 65085f3f87..c393da6ad5 100644 --- a/bindings/huawei/obs/obs.go +++ b/bindings/huawei/obs/obs.go @@ -104,16 +104,16 @@ func (o *HuaweiOBS) parseMetadata(meta bindings.Metadata) (*obsMetadata, error) } if m.Bucket == "" { - return nil, fmt.Errorf("missing obs bucket name") + return nil, errors.New("missing obs bucket name") } if m.Endpoint == "" { - return nil, fmt.Errorf("missing obs endpoint") + return nil, errors.New("missing obs endpoint") } if m.AccessKey == "" { - return nil, fmt.Errorf("missing the huawei access key") + return nil, errors.New("missing the huawei access key") } if m.SecretKey == "" { - return nil, fmt.Errorf("missing the huawei secret key") + return nil, errors.New("missing the huawei secret key") } o.logger.Debugf("Huawei OBS metadata=[%s]", m) @@ -212,7 +212,7 @@ func (o *HuaweiOBS) get(ctx context.Context, req *bindings.InvokeRequest) (*bind if val, ok := req.Metadata[metadataKey]; ok && val != "" { key = val } else { - return nil, fmt.Errorf("obs binding error: can't read key value") + return nil, errors.New("obs binding error: can't read key value") } input := &obs.GetObjectInput{} @@ -252,7 +252,7 @@ func (o *HuaweiOBS) delete(ctx context.Context, req *bindings.InvokeRequest) (*b if val, ok := req.Metadata[metadataKey]; ok && val != "" { key = val } else { - return nil, fmt.Errorf("obs binding error: can't read key value") + return nil, errors.New("obs binding error: can't read key value") } input := &obs.DeleteObjectInput{} diff --git a/bindings/huawei/obs/obs_test.go b/bindings/huawei/obs/obs_test.go index b87762f563..5ab85def17 100644 --- a/bindings/huawei/obs/obs_test.go +++ b/bindings/huawei/obs/obs_test.go @@ -17,7 +17,6 @@ import ( "context" "encoding/json" "errors" - "fmt" "io" "strings" "testing" @@ -107,7 +106,7 @@ func TestInit(t *testing.T) { } err := obs.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing obs bucket name")) + assert.Equal(t, err, errors.New("missing obs bucket name")) }) t.Run("Init with missing access key", func(t *testing.T) { m := bindings.Metadata{} @@ -118,7 +117,7 @@ func TestInit(t *testing.T) { } err := obs.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing the huawei access key")) + assert.Equal(t, err, errors.New("missing the huawei access key")) }) t.Run("Init with missing secret key", func(t *testing.T) { m := bindings.Metadata{} @@ -129,7 +128,7 @@ func TestInit(t *testing.T) { } err := obs.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing the huawei secret key")) + assert.Equal(t, err, errors.New("missing the huawei secret key")) }) t.Run("Init with missing endpoint", func(t *testing.T) { m := bindings.Metadata{} @@ -140,7 +139,7 @@ func TestInit(t *testing.T) { } err := obs.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing obs endpoint")) + assert.Equal(t, err, errors.New("missing obs endpoint")) }) } @@ -251,7 +250,7 @@ func TestCreateOperation(t *testing.T) { mo := &HuaweiOBS{ service: &MockHuaweiOBSService{ PutObjectFn: func(ctx context.Context, input *obs.PutObjectInput) (output *obs.PutObjectOutput, err error) { - return nil, fmt.Errorf("error while creating object") + return nil, errors.New("error while creating object") }, }, logger: logger.NewLogger("test"), @@ -343,7 +342,7 @@ func TestUploadOperation(t *testing.T) { mo := &HuaweiOBS{ service: &MockHuaweiOBSService{ PutFileFn: func(ctx context.Context, input *obs.PutFileInput) (output *obs.PutObjectOutput, err error) { - return nil, fmt.Errorf("error while creating object") + return nil, errors.New("error while creating object") }, }, logger: logger.NewLogger("test"), @@ -419,7 +418,7 @@ func TestGetOperation(t *testing.T) { mo := &HuaweiOBS{ service: &MockHuaweiOBSService{ GetObjectFn: func(ctx context.Context, input *obs.GetObjectInput) (output *obs.GetObjectOutput, err error) { - return nil, fmt.Errorf("error while getting object") + return nil, errors.New("error while getting object") }, }, logger: logger.NewLogger("test"), @@ -527,7 +526,7 @@ func TestDeleteOperation(t *testing.T) { mo := &HuaweiOBS{ service: &MockHuaweiOBSService{ DeleteObjectFn: func(ctx context.Context, input *obs.DeleteObjectInput) (output *obs.DeleteObjectOutput, err error) { - return nil, fmt.Errorf("error while deleting object") + return nil, errors.New("error while deleting object") }, }, logger: logger.NewLogger("test"), @@ -582,7 +581,7 @@ func TestListOperation(t *testing.T) { mo := &HuaweiOBS{ service: &MockHuaweiOBSService{ ListObjectsFn: func(ctx context.Context, input *obs.ListObjectsInput) (output *obs.ListObjectsOutput, err error) { - return nil, fmt.Errorf("error while listing objects") + return nil, errors.New("error while listing objects") }, }, logger: logger.NewLogger("test"), diff --git a/bindings/input_binding.go b/bindings/input_binding.go index b87f7b9d4c..8649dfb696 100644 --- a/bindings/input_binding.go +++ b/bindings/input_binding.go @@ -15,7 +15,7 @@ package bindings import ( "context" - "fmt" + "errors" "io" "github.com/dapr/components-contrib/health" @@ -43,6 +43,6 @@ func PingInpBinding(ctx context.Context, inputBinding InputBinding) error { if inputBindingWithPing, ok := inputBinding.(health.Pinger); ok { return inputBindingWithPing.Ping(ctx) } else { - return fmt.Errorf("ping is not implemented by this input binding") + return errors.New("ping is not implemented by this input binding") } } diff --git a/bindings/kubemq/options.go b/bindings/kubemq/options.go index 9b642c661c..a73f58b0e9 100644 --- a/bindings/kubemq/options.go +++ b/bindings/kubemq/options.go @@ -1,7 +1,7 @@ package kubemq import ( - "fmt" + "errors" "strconv" "strings" @@ -27,15 +27,15 @@ func parseAddress(address string) (string, int, error) { var err error hostPort := strings.Split(address, ":") if len(hostPort) != 2 { - return "", 0, fmt.Errorf("invalid kubemq address, address format is invalid") + return "", 0, errors.New("invalid kubemq address, address format is invalid") } host = hostPort[0] if len(host) == 0 { - return "", 0, fmt.Errorf("invalid kubemq address, host is empty") + return "", 0, errors.New("invalid kubemq address, host is empty") } port, err = strconv.Atoi(hostPort[1]) if err != nil { - return "", 0, fmt.Errorf("invalid kubemq address, port is invalid") + return "", 0, errors.New("invalid kubemq address, port is invalid") } return host, port, nil } @@ -64,19 +64,19 @@ func createOptions(md bindings.Metadata) (*options, error) { return nil, err } } else { - return nil, fmt.Errorf("invalid kubemq address, address is empty") + return nil, errors.New("invalid kubemq address, address is empty") } if result.Channel == "" { - return nil, fmt.Errorf("invalid kubemq channel, channel is empty") + return nil, errors.New("invalid kubemq channel, channel is empty") } if result.PollMaxItems < 1 { - return nil, fmt.Errorf("invalid kubemq pollMaxItems value, value must be greater than 0") + return nil, errors.New("invalid kubemq pollMaxItems value, value must be greater than 0") } if result.PollTimeoutSeconds < 1 { - return nil, fmt.Errorf("invalid kubemq pollTimeoutSeconds value, value must be greater than 0") + return nil, errors.New("invalid kubemq pollTimeoutSeconds value, value must be greater than 0") } return result, nil diff --git a/bindings/mqtt3/mqtt.go b/bindings/mqtt3/mqtt.go index bac9ae5ea6..df7fcaa68b 100644 --- a/bindings/mqtt3/mqtt.go +++ b/bindings/mqtt3/mqtt.go @@ -95,7 +95,7 @@ func (m *MQTT) getProducer() (mqtt.Client, error) { } // mqtt broker allows only one connection at a given time from a clientID. - producerClientID := fmt.Sprintf("%s-producer", m.metadata.ClientID) + producerClientID := m.metadata.ClientID + "-producer" p, err := m.connect(producerClientID, false) if err != nil { return nil, err @@ -170,7 +170,7 @@ func (m *MQTT) Read(ctx context.Context, handler bindings.Handler) error { m.readHandler = handler // mqtt broker allows only one connection at a given time from a clientID - consumerClientID := fmt.Sprintf("%s-consumer", m.metadata.ClientID) + consumerClientID := m.metadata.ClientID + "-consumer" // Establish the connection // This will also create the subscription in the OnConnect handler diff --git a/bindings/mysql/mysql.go b/bindings/mysql/mysql.go index 2064be8b25..4bcd99a009 100644 --- a/bindings/mysql/mysql.go +++ b/bindings/mysql/mysql.go @@ -114,7 +114,7 @@ func (m *Mysql) Init(ctx context.Context, md bindings.Metadata) error { } if meta.URL == "" { - return fmt.Errorf("missing MySql connection string") + return errors.New("missing MySql connection string") } m.db, err = initDB(meta.URL, meta.PemPath) @@ -281,7 +281,7 @@ func initDB(url, pemPath string) (*sql.DB, error) { ok := rootCertPool.AppendCertsFromPEM(pem) if !ok { - return nil, fmt.Errorf("failed to append PEM") + return nil, errors.New("failed to append PEM") } err = mysql.RegisterTLSConfig("custom", &tls.Config{ diff --git a/bindings/mysql/mysql_integration_test.go b/bindings/mysql/mysql_integration_test.go index 6c86396f7b..eadeaa31c1 100644 --- a/bindings/mysql/mysql_integration_test.go +++ b/bindings/mysql/mysql_integration_test.go @@ -91,7 +91,7 @@ func TestMysqlIntegration(t *testing.T) { }) t.Run("Invoke insert", func(t *testing.T) { - for i := 0; i < 10; i++ { + for i := range 10 { res, err := b.Invoke(context.Background(), &bindings.InvokeRequest{ Operation: execOperation, Metadata: map[string]string{ @@ -106,7 +106,7 @@ func TestMysqlIntegration(t *testing.T) { t.Run("Invoke update", func(t *testing.T) { date := time.Now().Add(time.Hour) - for i := 0; i < 10; i++ { + for i := range 10 { res, err := b.Invoke(context.Background(), &bindings.InvokeRequest{ Operation: execOperation, Metadata: map[string]string{ @@ -122,7 +122,7 @@ func TestMysqlIntegration(t *testing.T) { t.Run("Invoke update with parameters", func(t *testing.T) { date := time.Now().Add(2 * time.Hour) - for i := 0; i < 10; i++ { + for i := range 10 { res, err := b.Invoke(context.Background(), &bindings.InvokeRequest{ Operation: execOperation, Metadata: map[string]string{ diff --git a/bindings/output_binding.go b/bindings/output_binding.go index ac20b7dce8..69ecbccbe3 100644 --- a/bindings/output_binding.go +++ b/bindings/output_binding.go @@ -15,7 +15,7 @@ package bindings import ( "context" - "fmt" + "errors" "io" "github.com/dapr/components-contrib/health" @@ -37,6 +37,6 @@ func PingOutBinding(ctx context.Context, outputBinding OutputBinding) error { if outputBindingWithPing, ok := outputBinding.(health.Pinger); ok { return outputBindingWithPing.Ping(ctx) } else { - return fmt.Errorf("ping is not implemented by this output binding") + return errors.New("ping is not implemented by this output binding") } } diff --git a/bindings/postgres/postgres_test.go b/bindings/postgres/postgres_test.go index 9f9cf207b5..c24fc099fb 100644 --- a/bindings/postgres/postgres_test.go +++ b/bindings/postgres/postgres_test.go @@ -87,7 +87,7 @@ func TestPostgresIntegration(t *testing.T) { }) t.Run("Invoke insert", func(t *testing.T) { - for i := 0; i < 10; i++ { + for i := range 10 { req.Metadata[commandSQLKey] = fmt.Sprintf(testInsert, i, i, time.Now().Format(time.RFC3339)) res, err := b.Invoke(ctx, req) assertResponse(t, res, err) @@ -95,7 +95,7 @@ func TestPostgresIntegration(t *testing.T) { }) t.Run("Invoke update", func(t *testing.T) { - for i := 0; i < 10; i++ { + for i := range 10 { req.Metadata[commandSQLKey] = fmt.Sprintf(testUpdate, time.Now().Format(time.RFC3339), i) res, err := b.Invoke(ctx, req) assertResponse(t, res, err) diff --git a/bindings/postmark/postmark.go b/bindings/postmark/postmark.go index 30197f03b4..526d2b4e70 100644 --- a/bindings/postmark/postmark.go +++ b/bindings/postmark/postmark.go @@ -104,7 +104,7 @@ func (p *Postmark) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bi email.From = req.Metadata["emailFrom"] } if len(email.From) == 0 { - return nil, fmt.Errorf("error Postmark from email not supplied") + return nil, errors.New("error Postmark from email not supplied") } // Build email to address, this is required @@ -115,7 +115,7 @@ func (p *Postmark) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bi email.To = req.Metadata["emailTo"] } if len(email.To) == 0 { - return nil, fmt.Errorf("error Postmark to email not supplied") + return nil, errors.New("error Postmark to email not supplied") } // Build email subject, this is required @@ -126,7 +126,7 @@ func (p *Postmark) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bi email.Subject = req.Metadata["subject"] } if len(email.Subject) == 0 { - return nil, fmt.Errorf("error Postmark subject not supplied") + return nil, errors.New("error Postmark subject not supplied") } // Build email cc address, this is optional diff --git a/bindings/rocketmq/rocketmq.go b/bindings/rocketmq/rocketmq.go index 8b9ed0e50f..65eaad967b 100644 --- a/bindings/rocketmq/rocketmq.go +++ b/bindings/rocketmq/rocketmq.go @@ -89,7 +89,7 @@ func (a *RocketMQ) Read(ctx context.Context, handler bindings.Handler) error { } if len(a.settings.Topics) == 0 { - return fmt.Errorf("binding-rocketmq error: must configure topics") + return errors.New("binding-rocketmq error: must configure topics") } for _, topicStr := range a.settings.Topics { diff --git a/bindings/rocketmq/rocketmq_test.go b/bindings/rocketmq/rocketmq_test.go index 4cb162257e..885e7d8cea 100644 --- a/bindings/rocketmq/rocketmq_test.go +++ b/bindings/rocketmq/rocketmq_test.go @@ -55,7 +55,7 @@ func TestInputBindingRead(t *testing.T) { //nolint:paralleltest require.NoError(t, err) time.Sleep(10 * time.Second) - for i := 0; i < 30; i++ { + for range 30 { if atomic.LoadInt32(&count) > 0 { break } diff --git a/bindings/smtp/smtp.go b/bindings/smtp/smtp.go index 47467e092d..dd317a061d 100644 --- a/bindings/smtp/smtp.go +++ b/bindings/smtp/smtp.go @@ -88,13 +88,13 @@ func (s *Mailer) Invoke(_ context.Context, req *bindings.InvokeRequest) (*bindin return nil, err } if metadata.EmailFrom == "" { - return nil, fmt.Errorf("smtp binding error: emailFrom property not supplied in configuration- or request-metadata") + return nil, errors.New("smtp binding error: emailFrom property not supplied in configuration- or request-metadata") } if metadata.EmailTo == "" { - return nil, fmt.Errorf("smtp binding error: emailTo property not supplied in configuration- or request-metadata") + return nil, errors.New("smtp binding error: emailTo property not supplied in configuration- or request-metadata") } if metadata.Subject == "" { - return nil, fmt.Errorf("smtp binding error: subject property not supplied in configuration- or request-metadata") + return nil, errors.New("smtp binding error: subject property not supplied in configuration- or request-metadata") } // Compose message @@ -168,7 +168,6 @@ func (s *Mailer) parseMetadata(meta bindings.Metadata) (Metadata, error) { } err = smtpMeta.parsePriority(meta.Properties["priority"]) - if err != nil { return smtpMeta, err } diff --git a/bindings/twilio/sendgrid/sendgrid.go b/bindings/twilio/sendgrid/sendgrid.go index a065b9813f..1e2229c84c 100644 --- a/bindings/twilio/sendgrid/sendgrid.go +++ b/bindings/twilio/sendgrid/sendgrid.go @@ -136,7 +136,7 @@ func (sg *SendGrid) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*b fromAddress = mail.NewEmail(fromName, req.Metadata["emailFrom"]) } if fromAddress == nil { - return nil, fmt.Errorf("error SendGrid from email not supplied") + return nil, errors.New("error SendGrid from email not supplied") } // Build email to address, this is required @@ -160,7 +160,7 @@ func (sg *SendGrid) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*b toAddress = mail.NewEmail(toName, req.Metadata["emailTo"]) } if toAddress == nil { - return nil, fmt.Errorf("error SendGrid to email not supplied") + return nil, errors.New("error SendGrid to email not supplied") } // Build email subject, this is required @@ -172,7 +172,7 @@ func (sg *SendGrid) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*b subject = req.Metadata["subject"] } if subject == "" { - return nil, fmt.Errorf("error SendGrid subject not supplied") + return nil, errors.New("error SendGrid subject not supplied") } // Build email cc address, this is optional diff --git a/bindings/wasm/output.go b/bindings/wasm/output.go index 424b2dd7f3..8855d1f7de 100644 --- a/bindings/wasm/output.go +++ b/bindings/wasm/output.go @@ -16,6 +16,7 @@ package wasm import ( "bytes" "context" + "errors" "fmt" "io" "reflect" @@ -91,7 +92,7 @@ func (out *outputBinding) Init(ctx context.Context, metadata bindings.Metadata) if _, found := imports[modeWasiHTTP]; found { if out.meta.StrictSandbox { _ = out.runtime.Close(context.Background()) - return fmt.Errorf("can not instantiate wasi-http with strict sandbox") + return errors.New("can not instantiate wasi-http with strict sandbox") } err = wasi_http.MakeWasiHTTP().Instantiate(ctx, out.runtime) } diff --git a/bindings/wasm/output_test.go b/bindings/wasm/output_test.go index b5e765c0b1..502591e454 100644 --- a/bindings/wasm/output_test.go +++ b/bindings/wasm/output_test.go @@ -172,7 +172,7 @@ func Test_Invoke(t *testing.T) { if tc.expectedErr == "" { // execute twice to prove idempotency - for i := 0; i < 2; i++ { + for range 2 { resp, outputErr := output.Invoke(reqCtx, tc.request) require.NoError(t, outputErr) require.Equal(t, tc.expectedData, string(resp.Data)) @@ -258,7 +258,7 @@ func Test_InvokeHttp(t *testing.T) { if tc.expectedErr == "" { // execute twice to prove idempotency - for i := 0; i < 2; i++ { + for range 2 { resp, outputErr := output.Invoke(reqCtx, tc.request) require.NoError(t, outputErr) require.Equal(t, tc.expectedData, string(resp.Data)) @@ -292,7 +292,7 @@ func TestEnsureConcurrency(t *testing.T) { // Wasm is running in goroutine, use wait group to ensure all goroutines are finished wg := sync.WaitGroup{} // 100 is enough to trigger concurrency, and wasm should be executed run fast enough to not consuming too much time - for i := 0; i < 100; i++ { + for i := range 100 { wg.Add(1) go func(i int) { request := &bindings.InvokeRequest{ diff --git a/bindings/zeebe/jobworker/jobworker.go b/bindings/zeebe/jobworker/jobworker.go index 63384c5aa3..ff3299cc73 100644 --- a/bindings/zeebe/jobworker/jobworker.go +++ b/bindings/zeebe/jobworker/jobworker.go @@ -104,7 +104,7 @@ func (z *ZeebeJobWorker) Init(ctx context.Context, metadata bindings.Metadata) e func (z *ZeebeJobWorker) Read(ctx context.Context, handler bindings.Handler) error { if z.closed.Load() { - return fmt.Errorf("binding is closed") + return errors.New("binding is closed") } var retryBackOff *time.Duration diff --git a/common/authentication/aws/aws.go b/common/authentication/aws/aws.go index 26d4c9fe63..48c8b209a4 100644 --- a/common/authentication/aws/aws.go +++ b/common/authentication/aws/aws.go @@ -148,7 +148,7 @@ func (opts *AWSIAMAuthOptions) GetAccessToken(ctx context.Context) (string, erro return authenticationToken, nil case err != nil: - return "", fmt.Errorf("failed to load default AWS authentication configuration") + return "", errors.New("failed to load default AWS authentication configuration") } authenticationToken, err = auth.BuildAuthToken( diff --git a/common/authentication/azure/auth.go b/common/authentication/azure/auth.go index 98418dc14f..cf588a7e84 100644 --- a/common/authentication/azure/auth.go +++ b/common/authentication/azure/auth.go @@ -234,7 +234,7 @@ func (s EnvironmentSettings) GetTokenCredential() (azcore.TokenCredential, error break } else { // If authMethod is "none", we don't add any provider and return an error - return nil, fmt.Errorf("all Azure auth methods have been disabled with auth method 'None'") + return nil, errors.New("all Azure auth methods have been disabled with auth method 'None'") } } } @@ -412,7 +412,7 @@ func (c CertConfig) decodePEM(data []byte) (certificate *x509.Certificate, priva parsedKey any ok bool ) - for i := 0; i < 2; i++ { + for range 2 { block, data = pem.Decode(data) if block == nil { break diff --git a/common/authentication/sqlite/metadata.go b/common/authentication/sqlite/metadata.go index ef54cffb79..f182750d12 100644 --- a/common/authentication/sqlite/metadata.go +++ b/common/authentication/sqlite/metadata.go @@ -190,7 +190,7 @@ func ValidIdentifier(v string) bool { // Loop through the string as byte slice as we only care about ASCII characters b := []byte(v) - for i := 0; i < len(b); i++ { + for i := range len(b) { if (b[i] >= '0' && b[i] <= '9') || (b[i] >= 'a' && b[i] <= 'z') || (b[i] >= 'A' && b[i] <= 'Z') || diff --git a/common/authentication/sqlserver/metadata.go b/common/authentication/sqlserver/metadata.go index 6543b301a0..003fbdba7f 100644 --- a/common/authentication/sqlserver/metadata.go +++ b/common/authentication/sqlserver/metadata.go @@ -51,10 +51,10 @@ func (m *SQLServerAuthMetadata) Validate(meta map[string]string) (err error) { return errors.New("missing connection string") } if !IsValidSQLName(m.DatabaseName) { - return fmt.Errorf("invalid database name, accepted characters are (A-Z, a-z, 0-9, _)") + return errors.New("invalid database name, accepted characters are (A-Z, a-z, 0-9, _)") } if !IsValidSQLName(m.SchemaName) { - return fmt.Errorf("invalid schema name, accepted characters are (A-Z, a-z, 0-9, _)") + return errors.New("invalid schema name, accepted characters are (A-Z, a-z, 0-9, _)") } // If using Azure AD diff --git a/common/component/azure/blobstorage/client.go b/common/component/azure/blobstorage/client.go index 70e0f87f25..ca054a4f37 100644 --- a/common/component/azure/blobstorage/client.go +++ b/common/component/azure/blobstorage/client.go @@ -109,7 +109,7 @@ func (opts *ContainerClientOpts) GetContainerURL(azEnvSettings azauth.Environmen if opts.customEndpoint != "" { u, err = url.Parse(fmt.Sprintf("%s/%s/%s", opts.customEndpoint, opts.AccountName, opts.ContainerName)) if err != nil { - return nil, fmt.Errorf("failed to get container's URL with custom endpoint") + return nil, errors.New("failed to get container's URL with custom endpoint") } } else { u = opts.getAzureBlobStorageContainerURL(azEnvSettings) diff --git a/common/component/azure/blobstorage/request.go b/common/component/azure/blobstorage/request.go index 6aa6d7945b..34ccd8dcd0 100644 --- a/common/component/azure/blobstorage/request.go +++ b/common/component/azure/blobstorage/request.go @@ -15,7 +15,7 @@ package blobstorage import ( b64 "encoding/base64" - "fmt" + "errors" "strings" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob" @@ -56,7 +56,7 @@ func CreateBlobHTTPHeadersFromRequest(meta map[string]string, contentType *strin if val, ok := meta[caseMap[contentMD5Key]]; ok && val != "" { sDec, err := b64.StdEncoding.DecodeString(val) if err != nil || len(sDec) != 16 { - return blob.HTTPHeaders{}, fmt.Errorf("the MD5 value specified in Content MD5 is invalid, MD5 value must be 128 bits and base64 encoded") + return blob.HTTPHeaders{}, errors.New("the MD5 value specified in Content MD5 is invalid, MD5 value must be 128 bits and base64 encoded") } blobHTTPHeaders.BlobContentMD5 = sDec delete(meta, caseMap[contentMD5Key]) @@ -88,7 +88,7 @@ func SanitizeMetadata(log logger.Logger, metadata map[string]string) map[string] // Keep only letters and digits n := 0 newKey := make([]byte, len(key)) - for i := 0; i < len(key); i++ { + for i := range len(key) { if (key[i] >= 'A' && key[i] <= 'Z') || (key[i] >= 'a' && key[i] <= 'z') || (key[i] >= '0' && key[i] <= '9') { @@ -106,7 +106,7 @@ func SanitizeMetadata(log logger.Logger, metadata map[string]string) map[string] // Remove all non-ascii characters n = 0 newVal := make([]byte, len(val)) - for i := 0; i < len(val); i++ { + for i := range len(val) { if val[i] > 127 || val[i] == 0 { continue } diff --git a/common/component/azure/eventhubs/eventhubs.go b/common/component/azure/eventhubs/eventhubs.go index e4e80412ec..f5724e891f 100644 --- a/common/component/azure/eventhubs/eventhubs.go +++ b/common/component/azure/eventhubs/eventhubs.go @@ -115,7 +115,7 @@ func (aeh *AzureEventHubs) Init(metadata map[string]string) error { aeh.backOffConfig.MaxRetries = 3 err = retry.DecodeConfigWithPrefix(&aeh.backOffConfig, metadata, "backOff") if err != nil { - return fmt.Errorf("failed to decode backoff configuration") + return errors.New("failed to decode backoff configuration") } return nil @@ -365,15 +365,13 @@ func (aeh *AzureEventHubs) processEvents(subscribeCtx context.Context, partition // Loop to receive messages var ( - ctx context.Context - cancel context.CancelFunc events []*azeventhubs.ReceivedEventData err error ) counter := 0 for { // Maximum duration to wait till bulk message is sent to app is `maxBulkSubAwaitDurationMs` - ctx, cancel = context.WithTimeout(subscribeCtx, time.Duration(config.MaxBulkSubAwaitDurationMs)*time.Millisecond) + ctx, cancel := context.WithTimeout(subscribeCtx, time.Duration(config.MaxBulkSubAwaitDurationMs)*time.Millisecond) // Receive events with batchsize of `maxBulkSubCount` events, err = partitionClient.ReceiveEvents(ctx, config.MaxBulkSubCount, nil) cancel() diff --git a/common/component/azure/servicebus/client.go b/common/component/azure/servicebus/client.go index 7aa74eebf3..a775b45eba 100644 --- a/common/component/azure/servicebus/client.go +++ b/common/component/azure/servicebus/client.go @@ -185,7 +185,7 @@ func (c *Client) CloseAllSenders(log logger.Logger) { <-workersCh }(k, t) } - for i := 0; i < cap(workersCh); i++ { + for range cap(workersCh) { // Wait for all workers to be done workersCh <- true } diff --git a/common/component/azure/servicebus/message_pubsub_test.go b/common/component/azure/servicebus/message_pubsub_test.go index 3495897515..4e15560c3d 100644 --- a/common/component/azure/servicebus/message_pubsub_test.go +++ b/common/component/azure/servicebus/message_pubsub_test.go @@ -76,7 +76,6 @@ func TestAddMessageAttributesToMetadata(t *testing.T) { } for _, tc := range testCases { - tc := tc for mType, mMap := range metadataMap { t.Run(fmt.Sprintf("%s, metadata is %s", tc.name, mType), func(t *testing.T) { actual := addMessageAttributesToMetadata(mMap, &tc.ASBMessage) diff --git a/common/component/azure/servicebus/subscription.go b/common/component/azure/servicebus/subscription.go index a37e8777e5..7ff5949fe9 100644 --- a/common/component/azure/servicebus/subscription.go +++ b/common/component/azure/servicebus/subscription.go @@ -331,7 +331,7 @@ func (s *Subscription) doRenewLocks(ctx context.Context, receiver *MessageReceiv err error errored int ) - for i := 0; i < len(msgs); i++ { + for range len(msgs) { // This is a nop if the received error is nil if multierr.AppendInto(&err, <-errCh) { errored++ @@ -548,7 +548,7 @@ func (s *Subscription) CompleteMessage(ctx context.Context, receiver Receiver, m func (s *Subscription) addActiveMessage(m *azservicebus.ReceivedMessage) error { if m.SequenceNumber == nil { - return fmt.Errorf("message sequence number is nil") + return errors.New("message sequence number is nil") } var logSuffix string diff --git a/common/component/cloudflare/workers/workers.go b/common/component/cloudflare/workers/workers.go index 9038d78d1a..fd89135a89 100644 --- a/common/component/cloudflare/workers/workers.go +++ b/common/component/cloudflare/workers/workers.go @@ -20,6 +20,7 @@ import ( "crypto/x509" "encoding/json" "encoding/pem" + "errors" "fmt" "io" "mime/multipart" @@ -188,7 +189,7 @@ func (w *Base) getWorkersSubdomain() (string, error) { } if data.Result.Subdomain == "" { - return "", fmt.Errorf("response does not contain a value for 'subdomain'") + return "", errors.New("response does not contain a value for 'subdomain'") } return data.Result.Subdomain, nil diff --git a/common/component/kafka/auth.go b/common/component/kafka/auth.go index 43d195e28c..bd61690c05 100644 --- a/common/component/kafka/auth.go +++ b/common/component/kafka/auth.go @@ -43,7 +43,7 @@ func updatePasswordAuthInfo(config *sarama.Config, metadata *KafkaMetadata, sasl func updateMTLSAuthInfo(config *sarama.Config, metadata *KafkaMetadata) error { if metadata.TLSDisable { - return fmt.Errorf("kafka: cannot configure mTLS authentication when TLSDisable is 'true'") + return errors.New("kafka: cannot configure mTLS authentication when TLSDisable is 'true'") } cert, err := tls.X509KeyPair([]byte(metadata.TLSClientCert), []byte(metadata.TLSClientKey)) if err != nil { diff --git a/common/component/kafka/kafka.go b/common/component/kafka/kafka.go index 28883b2c1e..97e714ef4d 100644 --- a/common/component/kafka/kafka.go +++ b/common/component/kafka/kafka.go @@ -280,7 +280,7 @@ func (k *Kafka) DeserializeValue(message *sarama.ConsumerMessage, config Subscri return nil, err } if len(message.Value) < 5 { - return nil, fmt.Errorf("value is too short") + return nil, errors.New("value is too short") } schemaID := binary.BigEndian.Uint32(message.Value[1:5]) schema, err := srClient.GetSchema(int(schemaID)) diff --git a/common/component/kafka/sasl_oauthbearer.go b/common/component/kafka/sasl_oauthbearer.go index b591c1fbb8..125956617c 100644 --- a/common/component/kafka/sasl_oauthbearer.go +++ b/common/component/kafka/sasl_oauthbearer.go @@ -18,6 +18,7 @@ import ( "crypto/tls" "crypto/x509" "encoding/pem" + "errors" "fmt" "net/http" "time" @@ -58,7 +59,7 @@ func (ts *OAuthTokenSource) addCa(caPem string) error { block, _ := pem.Decode(pemBytes) if block == nil || block.Type != "CERTIFICATE" { - return fmt.Errorf("PEM data not valid or not of a valid type (CERTIFICATE)") + return errors.New("PEM data not valid or not of a valid type (CERTIFICATE)") } caCert, err := x509.ParseCertificate(block.Bytes) @@ -109,7 +110,7 @@ func (ts *OAuthTokenSource) Token() (*sarama.AccessToken, error) { } if ts.TokenEndpoint.TokenURL == "" || ts.ClientID == "" || ts.ClientSecret == "" { - return nil, fmt.Errorf("cannot generate token, OAuthTokenSource not fully configured") + return nil, errors.New("cannot generate token, OAuthTokenSource not fully configured") } oidcCfg := ccred.Config{ClientID: ts.ClientID, ClientSecret: ts.ClientSecret, Scopes: ts.Scopes, TokenURL: ts.TokenEndpoint.TokenURL, AuthStyle: ts.TokenEndpoint.AuthStyle} diff --git a/common/component/kafka/subscriber_test.go b/common/component/kafka/subscriber_test.go index f54948e341..57b87cf4f2 100644 --- a/common/component/kafka/subscriber_test.go +++ b/common/component/kafka/subscriber_test.go @@ -503,7 +503,7 @@ func Test_Subscribe(t *testing.T) { } ctx, cancel := context.WithCancel(context.Background()) - for i := 0; i < 100; i++ { + for i := range 100 { go func(i int) { k.Subscribe(ctx, SubscriptionHandlerConfig{}, strconv.Itoa(i)) }(i) diff --git a/common/component/redis/redis.go b/common/component/redis/redis.go index d5ecb187ab..de098891a5 100644 --- a/common/component/redis/redis.go +++ b/common/component/redis/redis.go @@ -364,7 +364,7 @@ func GetServerVersion(c RedisClient) (string, error) { return strings.TrimSpace(strings.Split(row, ":")[1]), nil } } - return "", fmt.Errorf("could not find redis_version in redis info response") + return "", errors.New("could not find redis_version in redis info response") } // GetConnectedSlaves returns the number of slaves connected to the Redis master. diff --git a/common/component/sql/migrations/postgres/postgres_migrations.go b/common/component/sql/migrations/postgres/postgres_migrations.go index ac3626be91..e7a4ebae37 100644 --- a/common/component/sql/migrations/postgres/postgres_migrations.go +++ b/common/component/sql/migrations/postgres/postgres_migrations.go @@ -107,7 +107,7 @@ func (m Migrations) EnsureMetadataTable(ctx context.Context) (err error) { // Add an "IF NOT EXISTS" in case another Dapr sidecar is creating the same table at the same time // In the next step we'll acquire a lock so there won't be issues with concurrency // Note that this query can fail with error `23505` on constraint `pg_type_typname_nsp_index` if ran in parallel; we will just retry that up to 3 times - for i := 0; i < 3; i++ { + for range 3 { _, err = m.DB.Exec(ctx, fmt.Sprintf( `CREATE TABLE IF NOT EXISTS %s ( key text NOT NULL PRIMARY KEY, diff --git a/common/component/sql/migrations/sqlserver/sqlserver_migrations_test.go b/common/component/sql/migrations/sqlserver/sqlserver_migrations_test.go index 17de5001c9..074f18a608 100644 --- a/common/component/sql/migrations/sqlserver/sqlserver_migrations_test.go +++ b/common/component/sql/migrations/sqlserver/sqlserver_migrations_test.go @@ -158,7 +158,7 @@ func TestMigration(t *testing.T) { const parallel = 5 errs := make(chan error, parallel) hasLogs := atomic.Uint32{} - for i := 0; i < parallel; i++ { + for i := range parallel { go func(i int) { // Collect logs collectLog := logger.NewLogger("concurrent-" + strconv.Itoa(i)) @@ -188,7 +188,7 @@ func TestMigration(t *testing.T) { }(i) } - for i := 0; i < parallel; i++ { + for range parallel { select { case err := <-errs: assert.NoError(t, err) //nolint:testifylint @@ -213,7 +213,7 @@ func getUniqueDBSchema(t *testing.T) string { b := make([]byte, 4) _, err := io.ReadFull(rand.Reader, b) require.NoError(t, err) - return fmt.Sprintf("m%s", hex.EncodeToString(b)) + return "m%s" + hex.EncodeToString(b) } func assertTableExists(t *testing.T, db *sql.DB, schema, table string) { diff --git a/configuration/azure/appconfig/appconfig.go b/configuration/azure/appconfig/appconfig.go index 0bc7e3a4c1..580f98a43a 100644 --- a/configuration/azure/appconfig/appconfig.go +++ b/configuration/azure/appconfig/appconfig.go @@ -231,7 +231,7 @@ func (r *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S sentinelKey := r.getSentinelKeyFromMetadata(req.Metadata) if sentinelKey == "" { - return "", fmt.Errorf("sentinel key is not provided in metadata") + return "", errors.New("sentinel key is not provided in metadata") } uuid, err := uuid.NewRandom() if err != nil { diff --git a/configuration/azure/appconfig/appconfig_test.go b/configuration/azure/appconfig/appconfig_test.go index 733d409f89..0ef05f418a 100644 --- a/configuration/azure/appconfig/appconfig_test.go +++ b/configuration/azure/appconfig/appconfig_test.go @@ -246,7 +246,7 @@ func TestInit(t *testing.T) { } func TestParseMetadata(t *testing.T) { - t.Run(fmt.Sprintf("parse metadata with %s", host), func(t *testing.T) { + t.Run("parse metadata with "+host, func(t *testing.T) { testProperties := make(map[string]string) testProperties[host] = "testHost" testProperties[maxRetries] = "3" @@ -279,7 +279,7 @@ func TestParseMetadata(t *testing.T) { assert.Equal(t, want.RequestTimeout, m.RequestTimeout) }) - t.Run(fmt.Sprintf("parse metadata with %s", connectionString), func(t *testing.T) { + t.Run("parse metadata with "+connectionString, func(t *testing.T) { testProperties := make(map[string]string) testProperties[connectionString] = "testConnectionString" testProperties[maxRetries] = "3" diff --git a/configuration/postgres/metadata.go b/configuration/postgres/metadata.go index e4d6492246..3ca391d3a8 100644 --- a/configuration/postgres/metadata.go +++ b/configuration/postgres/metadata.go @@ -14,6 +14,7 @@ limitations under the License. package postgres import ( + "errors" "fmt" "time" @@ -53,7 +54,7 @@ func (m *metadata) InitWithMetadata(meta map[string]string) error { // Validate and sanitize input if m.ConfigTable == "" { - return fmt.Errorf("missing postgreSQL configuration table name") + return errors.New("missing postgreSQL configuration table name") } if len(m.ConfigTable) > maxIdentifierLength { return fmt.Errorf("table name is too long - tableName : '%s'. max allowed field length is %d", m.ConfigTable, maxIdentifierLength) diff --git a/crypto/pubkey_cache_test.go b/crypto/pubkey_cache_test.go index ed4ab134a7..dcbe7777ac 100644 --- a/crypto/pubkey_cache_test.go +++ b/crypto/pubkey_cache_test.go @@ -156,7 +156,7 @@ func TestPubKeyCacheGetKey(t *testing.T) { var wg sync.WaitGroup wg.Add(10) - for i := 0; i < 10; i++ { + for range 10 { go func() { defer wg.Done() result, err := cache.GetKey(context.Background(), "key") diff --git a/lock/redis/standalone.go b/lock/redis/standalone.go index acb4d988dc..4ae6e29552 100644 --- a/lock/redis/standalone.go +++ b/lock/redis/standalone.go @@ -85,7 +85,7 @@ func (r *StandaloneRedisLock) TryLock(ctx context.Context, req *lock.TryLockRequ // Set a key if doesn't exist with an expiration time nxval, err := r.client.SetNX(ctx, req.ResourceID, req.LockOwner, time.Second*time.Duration(req.ExpiryInSeconds)) if nxval == nil { - return &lock.TryLockResponse{}, fmt.Errorf("setNX returned a nil response") + return &lock.TryLockResponse{}, errors.New("setNX returned a nil response") } if err != nil { diff --git a/metadata/utils.go b/metadata/utils.go index 7068dfd216..f1ba5b1365 100644 --- a/metadata/utils.go +++ b/metadata/utils.go @@ -220,7 +220,7 @@ func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *MetadataMap, com *metadataMap = MetadataMap{} } - for i := 0; i < t.NumField(); i++ { + for i := range t.NumField() { currentField := t.Field(i) // fields that are not exported cannot be set via the mapstructure metadata decoding mechanism if !currentField.IsExported() { diff --git a/middleware/http/sentinel/middleware_test.go b/middleware/http/sentinel/middleware_test.go index c0b587e1fc..588d51c517 100644 --- a/middleware/http/sentinel/middleware_test.go +++ b/middleware/http/sentinel/middleware_test.go @@ -56,7 +56,7 @@ func TestRequestHandlerWithFlowRules(t *testing.T) { r := httptest.NewRequest(http.MethodGet, "http://localhost:5001/v1.0/nodeapp/healthz", nil) counter := &counter{} - for i := 0; i < 100; i++ { + for range 100 { w := httptest.NewRecorder() handler(http.HandlerFunc(counter.handle)).ServeHTTP(w, r) } @@ -126,7 +126,6 @@ func TestLoadRules(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { sentinel, _ := NewMiddleware(nil).(*Middleware) err := sentinel.loadSentinelRules(&c.meta) diff --git a/middleware/http/wasm/benchmark_test.go b/middleware/http/wasm/benchmark_test.go index 24505eb0f7..42d884613e 100644 --- a/middleware/http/wasm/benchmark_test.go +++ b/middleware/http/wasm/benchmark_test.go @@ -91,11 +91,11 @@ var benches = map[string]struct { httputils.RespondWithErrorAndMessage(w, http.StatusInternalServerError, body) } if path := r.URL.Path; path != "/v1.0/hello" { - body := fmt.Sprintf("Expected wasm to rewrite path: %s", path) + body := "Expected wasm to rewrite path: " + path httputils.RespondWithErrorAndMessage(w, http.StatusInternalServerError, body) } if query := r.URL.RawQuery; query != "name=teddy" { - body := fmt.Sprintf("Expected wasm to retain query: %s", query) + body := "Expected wasm to retain query: " + query httputils.RespondWithErrorAndMessage(w, http.StatusInternalServerError, body) } w.Header().Set("Content-Type", "text/plain") diff --git a/middleware/http/wasm/internal/e2e_test.go b/middleware/http/wasm/internal/e2e_test.go index 21c91ce34f..bf31b5abe4 100644 --- a/middleware/http/wasm/internal/e2e_test.go +++ b/middleware/http/wasm/internal/e2e_test.go @@ -97,7 +97,7 @@ func Test_EndToEnd(t *testing.T) { guest: guestWasm[guestWasmOutput], test: func(t *testing.T, handler http.Handler, log *bytes.Buffer) { // Service more requests than one to ensure pooling works properly. - for i := 0; i < 3; i++ { + for range 3 { r := httptest.NewRequest(http.MethodGet, "/", nil) w := httptest.NewRecorder() handler.ServeHTTP(w, r) diff --git a/nameresolution/consul/configuration.go b/nameresolution/consul/configuration.go index 9fba047479..8c1de3b382 100644 --- a/nameresolution/consul/configuration.go +++ b/nameresolution/consul/configuration.go @@ -140,7 +140,7 @@ func mapChecks(config []*AgentServiceCheck) []*consul.AgentServiceCheck { mapped := []*consul.AgentServiceCheck{} - for i := 0; i < len(config); i++ { + for i := range len(config) { mapped = append(mapped, mapCheck(config[i])) } @@ -211,7 +211,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ mapped.Checks = config.Checks - for i := 0; i < len(config.Paths); i++ { + for i := range len(config.Paths) { tmp := consul.ExposePath{ ListenerPort: config.Paths[i].ListenerPort, Path: config.Paths[i].Path, @@ -232,7 +232,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ mapped := []consul.Upstream{} - for i := 0; i < len(config); i++ { + for i := range len(config) { tmp := consul.Upstream{ DestinationType: consul.UpstreamDestType(config[i].DestinationType), DestinationNamespace: config[i].DestinationNamespace, @@ -273,7 +273,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ mapped := consul.AgentServiceChecks{} - for i := 0; i < len(config); i++ { + for i := range len(config) { mapped = append(mapped, mapCheck(config[i])) } diff --git a/nameresolution/consul/consul.go b/nameresolution/consul/consul.go index d07f9fdd80..8fc8eb2134 100644 --- a/nameresolution/consul/consul.go +++ b/nameresolution/consul/consul.go @@ -420,7 +420,7 @@ func getRegistrationConfig(cfg configSpec, props map[string]string) (*consul.Age cfg.Checks = []*consul.AgentServiceCheck{ { Name: "Dapr Health Status", - CheckID: fmt.Sprintf("daprHealth:%s", id), + CheckID: "daprHealth:" + id, Interval: "15s", HTTP: fmt.Sprintf("http://%s/v1.0/healthz?appid=%s", net.JoinHostPort(host, httpPort), appID), }, diff --git a/nameresolution/consul/consul_test.go b/nameresolution/consul/consul_test.go index 8dda8fc77c..2ab43f8c7b 100644 --- a/nameresolution/consul/consul_test.go +++ b/nameresolution/consul/consul_test.go @@ -15,6 +15,7 @@ package consul import ( "context" + "errors" "fmt" "net" "strconv" @@ -246,7 +247,6 @@ func TestInit(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.testName, func(t *testing.T) { tt.test(t, tt.metadata) }) @@ -589,7 +589,7 @@ func TestResolveID(t *testing.T) { LastIndex: 0, } - err := fmt.Errorf("oh no") + err := errors.New("oh no") serviceEntries := []*consul.ServiceEntry{ { @@ -909,7 +909,7 @@ func TestResolveID(t *testing.T) { total1 := 0 total2 := 0 - for i := 0; i < 100; i++ { + for range 100 { addr, _ := resolver.ResolveID(context.Background(), req) if addr == "10.3.245.137:50005" { @@ -1026,7 +1026,6 @@ func TestResolveID(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.testName, func(t *testing.T) { tt.test(t, tt.req) }) @@ -1111,7 +1110,6 @@ func TestClose(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.testName, func(t *testing.T) { t.Parallel() tt.test(t, tt.metadata) @@ -1265,7 +1263,6 @@ func TestRegistry(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.testName, func(t *testing.T) { t.Parallel() tt.test(t) @@ -1356,7 +1353,6 @@ func TestParseConfig(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.testName, func(t *testing.T) { actual, err := parseConfig(tt.input) @@ -1727,7 +1723,6 @@ func TestGetConfig(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.testName, func(t *testing.T) { tt.test(t, tt.metadata) }) @@ -2015,7 +2010,7 @@ func TestMapConfig(t *testing.T) { compareRegistration(t, expected.AdvancedRegistration, actual.AdvancedRegistration) compareClientConfig(t, expected.Client, actual.Client) - for i := 0; i < len(expected.Checks); i++ { + for i := range len(expected.Checks) { compareCheck(t, expected.Checks[i], actual.Checks[i]) } @@ -2102,7 +2097,7 @@ func compareRegistration(t *testing.T, expected *AgentServiceRegistration, actua compareCheck(t, expected.Check, actual.Check) - for i := 0; i < len(expected.Checks); i++ { + for i := range len(expected.Checks) { compareCheck(t, expected.Checks[i], actual.Checks[i]) } @@ -2113,7 +2108,7 @@ func compareRegistration(t *testing.T, expected *AgentServiceRegistration, actua assert.Equal(t, expected.Proxy.LocalServicePort, actual.Proxy.LocalServicePort) assert.Equal(t, expected.Proxy.Config, actual.Proxy.Config) - for i := 0; i < len(expected.Proxy.Upstreams); i++ { + for i := range len(expected.Proxy.Upstreams) { assert.Equal(t, string(expected.Proxy.Upstreams[i].DestinationType), string(actual.Proxy.Upstreams[i].DestinationType)) assert.Equal(t, expected.Proxy.Upstreams[i].DestinationNamespace, actual.Proxy.Upstreams[i].DestinationNamespace) assert.Equal(t, expected.Proxy.Upstreams[i].DestinationName, actual.Proxy.Upstreams[i].DestinationName) @@ -2128,7 +2123,7 @@ func compareRegistration(t *testing.T, expected *AgentServiceRegistration, actua assert.Equal(t, expected.Proxy.Expose.Checks, actual.Proxy.Expose.Checks) - for i := 0; i < len(expected.Proxy.Expose.Paths); i++ { + for i := range len(expected.Proxy.Expose.Paths) { assert.Equal(t, expected.Proxy.Expose.Paths[i].ListenerPort, actual.Proxy.Expose.Paths[i].ListenerPort) assert.Equal(t, expected.Proxy.Expose.Paths[i].LocalPathPort, actual.Proxy.Expose.Paths[i].LocalPathPort) assert.Equal(t, expected.Proxy.Expose.Paths[i].ParsedFromCheck, actual.Proxy.Expose.Paths[i].ParsedFromCheck) @@ -2192,7 +2187,7 @@ func getInstanceInfoWithoutKey(removeKey string) nr.Instance { } func waitTillTrueOrTimeout(d time.Duration, condition func() bool) { - for i := 0; i < 100; i++ { + for range 100 { if condition() { return } diff --git a/nameresolution/consul/watcher.go b/nameresolution/consul/watcher.go index ece97ab05d..050acfa5c6 100644 --- a/nameresolution/consul/watcher.go +++ b/nameresolution/consul/watcher.go @@ -298,7 +298,7 @@ watchLoop: // generate set of keys serviceKeys := make(map[string]any) - for i := 0; i < len(services); i++ { + for i := range len(services) { serviceKeys[services[i]] = nil } diff --git a/nameresolution/mdns/mdns.go b/nameresolution/mdns/mdns.go index 228d680f91..e0ced9f620 100644 --- a/nameresolution/mdns/mdns.go +++ b/nameresolution/mdns/mdns.go @@ -299,14 +299,14 @@ func (m *Resolver) getZeroconfResolver() (resolver *zeroconf.Resolver, err error zeroconf.SelectIPTraffic(zeroconf.IPv4), zeroconf.SelectIPTraffic(zeroconf.IPv6), } - for i := 0; i < len(opts); i++ { + for i := range len(opts) { resolver, err = zeroconf.NewResolver(opts[i]) if err == nil { break } } if err != nil { - return nil, fmt.Errorf("failed to initialize resolver after attempting IPv4+IPv6, IPv4-only, and IPv6-only") + return nil, errors.New("failed to initialize resolver after attempting IPv4+IPv6, IPv4-only, and IPv6-only") } return resolver, nil } diff --git a/nameresolution/mdns/mdns_test.go b/nameresolution/mdns/mdns_test.go index bbd50ee921..6417b96ac0 100644 --- a/nameresolution/mdns/mdns_test.go +++ b/nameresolution/mdns/mdns_test.go @@ -142,7 +142,7 @@ func TestResolver(t *testing.T) { // assert require.NoError(t, err) - assert.Equal(t, fmt.Sprintf("%s:1234", localhost), pt) + assert.Equal(t, localhost+":1234", pt) } func TestResolverClose(t *testing.T) { @@ -163,7 +163,7 @@ func TestResolverClose(t *testing.T) { // assert require.NoError(t, err) - assert.Equal(t, fmt.Sprintf("%s:1234", localhost), pt) + assert.Equal(t, localhost+":1234", pt) // act again err = resolver.Close() @@ -217,7 +217,7 @@ func TestResolverMultipleInstances(t *testing.T) { // instance A and instance B and we see them each atleast m times. instanceACount := atomic.Uint32{} instanceBCount := atomic.Uint32{} - for i := 0; i < 100; i++ { + for range 100 { addr, err := resolver.ResolveID(context.Background(), request) require.NoError(t, err) require.Contains(t, []string{instanceAPQDN, instanceBPQDN}, addr) @@ -294,14 +294,14 @@ func ResolverConcurrencySubsriberClear(t *testing.T) { request := nr.ResolveRequest{ID: "testAppID"} var wg sync.WaitGroup - for i := 0; i < 10; i++ { + for range 10 { wg.Add(1) go func() { defer wg.Done() pt, err := resolver.ResolveID(context.Background(), request) require.NoError(t, err) - require.Equal(t, fmt.Sprintf("%s:1234", localhost), pt) + require.Equal(t, localhost+":1234", pt) }() } @@ -354,7 +354,7 @@ func ResolverConcurrencyFound(t *testing.T) { // act... wg := sync.WaitGroup{} - for i := 0; i < numConcurrency; i++ { + for i := range numConcurrency { wg.Add(1) go func(i int) { defer wg.Done() @@ -401,7 +401,7 @@ func ResolverConcurrencyNotFound(t *testing.T) { // act... wg := sync.WaitGroup{} - for i := 0; i < numConcurrency; i++ { + for i := range numConcurrency { idx := i wg.Add(1) go func() { @@ -509,7 +509,7 @@ func TestAddressListAddExisitingAddress(t *testing.T) { // assert require.Len(t, addressList.addresses, 2) - require.Greater(t, deltaSec, 0) // Ensures expiry has been extended for existing address. + require.Positive(t, deltaSec, 0) // Ensures expiry has been extended for existing address. } func TestAddressListNext(t *testing.T) { diff --git a/nameresolution/sqlite/sqlite_test.go b/nameresolution/sqlite/sqlite_test.go index fce242e578..58c42ba792 100644 --- a/nameresolution/sqlite/sqlite_test.go +++ b/nameresolution/sqlite/sqlite_test.go @@ -102,7 +102,7 @@ func TestSqliteNameResolver(t *testing.T) { require.Equal(t, tc.expectOne, res) } } else { - for i := 0; i < 20; i++ { + for i := range 20 { res, err := nr.ResolveID(context.Background(), nameresolution.ResolveRequest{ID: tc.appID}) require.NoErrorf(t, err, "Error on iteration %d", i) require.Contains(t, tc.expectAny, res) diff --git a/pubsub/aws/snssqs/metadata.go b/pubsub/aws/snssqs/metadata.go index 113cf126b2..db45fb8d84 100644 --- a/pubsub/aws/snssqs/metadata.go +++ b/pubsub/aws/snssqs/metadata.go @@ -61,7 +61,7 @@ type snsSqsMetadata struct { func maskLeft(s string) string { rs := []rune(s) - for i := 0; i < len(rs)-4; i++ { + for i := range len(rs) - 4 { rs[i] = 'X' } return string(rs) diff --git a/pubsub/aws/snssqs/snssqs.go b/pubsub/aws/snssqs/snssqs.go index 501a7344aa..357cfcabb9 100644 --- a/pubsub/aws/snssqs/snssqs.go +++ b/pubsub/aws/snssqs/snssqs.go @@ -414,7 +414,7 @@ func (s *snsSqs) getSnsSqsSubscriptionArn(parentCtx context.Context, topicArn st } } - return "", fmt.Errorf("sns sqs subscription not found for topic arn") + return "", errors.New("sns sqs subscription not found for topic arn") } func (s *snsSqs) getOrCreateSnsSqsSubscription(ctx context.Context, queueArn, topicArn string) (subscriptionArn string, err error) { @@ -552,7 +552,7 @@ func (s *snsSqs) callHandler(ctx context.Context, message *sqs.Message, queueInf ) if handler, loadOK = s.subscriptionManager.GetSubscriptionTopicHandler(sanitizedTopic); loadOK { if len(handler.requestTopic) == 0 { - return fmt.Errorf("handler topic name is missing") + return errors.New("handler topic name is missing") } } else { return fmt.Errorf("handler for (sanitized) topic: %s was not found", sanitizedTopic) diff --git a/pubsub/aws/snssqs/snssqs_test.go b/pubsub/aws/snssqs/snssqs_test.go index 2a6ca77a0d..1c789b67be 100644 --- a/pubsub/aws/snssqs/snssqs_test.go +++ b/pubsub/aws/snssqs/snssqs_test.go @@ -335,7 +335,7 @@ func Test_replaceNameToAWSSanitizedExistingFifoName_NonMax(t *testing.T) { s := `0123456789` v := nameToAWSSanitizedName(s, true) - r.EqualValues(len(s)+len(".fifo"), len(v)) + r.Len(v, len(s)+len(".fifo")) r.Equal("0123456789.fifo", v) } diff --git a/pubsub/azure/servicebus/topics/servicebus.go b/pubsub/azure/servicebus/topics/servicebus.go index 0bf59f8fa3..2ba8358051 100644 --- a/pubsub/azure/servicebus/topics/servicebus.go +++ b/pubsub/azure/servicebus/topics/servicebus.go @@ -256,7 +256,7 @@ func (a *azureServiceBus) connectAndReceive(ctx context.Context, req pubsub.Subs func (a *azureServiceBus) connectAndReceiveWithSessions(ctx context.Context, req pubsub.SubscribeRequest, sub *impl.Subscription, handlerFn impl.HandlerFn, onFirstSuccess func(), maxConcurrentSessions int) { sessionsChan := make(chan struct{}, maxConcurrentSessions) - for i := 0; i < maxConcurrentSessions; i++ { + for range maxConcurrentSessions { sessionsChan <- struct{}{} } diff --git a/pubsub/envelope_test.go b/pubsub/envelope_test.go index 0904b24422..ff8bab7c90 100644 --- a/pubsub/envelope_test.go +++ b/pubsub/envelope_test.go @@ -213,7 +213,7 @@ func TestCreateCloudEventsEnvelopeExpiration(t *testing.T) { ApplyMetadata(envelope, []Feature{FeatureMessageTTL}, map[string]string{ "ttlInSeconds": "10000", }) - assert.Equal(t, nil, envelope[ExpirationField]) + assert.Nil(t, envelope[ExpirationField]) assert.False(t, HasExpired(envelope)) }) @@ -376,7 +376,7 @@ func TestCreateFromCloudEventsProtobufPayload(t *testing.T) { contenttypes := []string{contribContenttype.CloudEventProtobufContentType, contribContenttype.ProtobufContentType} - for i := 0; i < len(contenttypes); i++ { + for i := range len(contenttypes) { envelope := NewCloudEventsEnvelope("", "", "", "", "", "", contenttypes[i], ceProtoBytes, "trace", "") diff --git a/pubsub/gcp/pubsub/pubsub.go b/pubsub/gcp/pubsub/pubsub.go index 22088f5ddc..d7e63627ec 100644 --- a/pubsub/gcp/pubsub/pubsub.go +++ b/pubsub/gcp/pubsub/pubsub.go @@ -320,7 +320,7 @@ func BuildSubscriptionID(consumerID, topic string) string { func (g *GCPPubSub) handleSubscriptionMessages(parentCtx context.Context, topic *gcppubsub.Topic, sub *gcppubsub.Subscription, handler pubsub.Handler) error { // Limit the number of attempted reconnects we make. reconnAttempts := make(chan struct{}, g.metadata.MaxReconnectionAttempts) - for i := 0; i < g.metadata.MaxReconnectionAttempts; i++ { + for range g.metadata.MaxReconnectionAttempts { reconnAttempts <- struct{}{} } diff --git a/pubsub/in-memory/in-memory.go b/pubsub/in-memory/in-memory.go index 8076f7b894..bbd4db6244 100644 --- a/pubsub/in-memory/in-memory.go +++ b/pubsub/in-memory/in-memory.go @@ -76,7 +76,7 @@ func (a *bus) Subscribe(ctx context.Context, req pubsub.SubscribeRequest, handle // For this component we allow built-in retries because it is backed by memory retryHandler := func(data []byte) { - for i := 0; i < 10; i++ { + for range 10 { handleErr := handler(ctx, &pubsub.NewMessage{Data: data, Topic: req.Topic, Metadata: req.Metadata}) if handleErr == nil { break diff --git a/pubsub/jetstream/metadata.go b/pubsub/jetstream/metadata.go index 4c91d7f8ec..f78eb0592f 100644 --- a/pubsub/jetstream/metadata.go +++ b/pubsub/jetstream/metadata.go @@ -14,6 +14,7 @@ limitations under the License. package jetstream import ( + "errors" "fmt" "time" @@ -70,23 +71,23 @@ func parseMetadata(psm pubsub.Metadata) (metadata, error) { } if m.NatsURL == "" { - return metadata{}, fmt.Errorf("missing nats URL") + return metadata{}, errors.New("missing nats URL") } if m.Jwt != "" && m.SeedKey == "" { - return metadata{}, fmt.Errorf("missing seed key") + return metadata{}, errors.New("missing seed key") } if m.Jwt == "" && m.SeedKey != "" { - return metadata{}, fmt.Errorf("missing jwt") + return metadata{}, errors.New("missing jwt") } if m.TLSClientCert != "" && m.TLSClientKey == "" { - return metadata{}, fmt.Errorf("missing tls client key") + return metadata{}, errors.New("missing tls client key") } if m.TLSClientCert == "" && m.TLSClientKey != "" { - return metadata{}, fmt.Errorf("missing tls client cert") + return metadata{}, errors.New("missing tls client cert") } if m.Name == "" { diff --git a/pubsub/kubemq/kubemq_events.go b/pubsub/kubemq/kubemq_events.go index 730ef00a09..0661480538 100644 --- a/pubsub/kubemq/kubemq_events.go +++ b/pubsub/kubemq/kubemq_events.go @@ -3,6 +3,7 @@ package kubemq import ( "context" "encoding/json" + "errors" "fmt" "sync" "time" @@ -104,7 +105,7 @@ func (k *kubeMQEvents) Publish(req *pubsub.PublishRequest) error { return err } if req.Topic == "" { - return fmt.Errorf("kubemq pub/sub error: topic is required") + return errors.New("kubemq pub/sub error: topic is required") } metadata := "" if req.Metadata != nil { diff --git a/pubsub/kubemq/kubemq_events_test.go b/pubsub/kubemq/kubemq_events_test.go index 57cdc79db3..92f46b7cce 100644 --- a/pubsub/kubemq/kubemq_events_test.go +++ b/pubsub/kubemq/kubemq_events_test.go @@ -2,7 +2,7 @@ package kubemq import ( "context" - "fmt" + "errors" "testing" "time" @@ -111,7 +111,7 @@ func Test_kubeMQEvents_Publish(t *testing.T) { Topic: "some-topic", }, resultError: nil, - publishErr: fmt.Errorf("some error"), + publishErr: errors.New("some error"), wantErr: true, }, } @@ -175,7 +175,7 @@ func Test_kubeMQEvents_Subscribe(t *testing.T) { subscribeHandler: func(ctx context.Context, msg *pubsub.NewMessage) error { return nil }, - subscribeError: fmt.Errorf("some error"), + subscribeError: errors.New("some error"), wantErr: true, }, } diff --git a/pubsub/kubemq/kubemq_eventstore.go b/pubsub/kubemq/kubemq_eventstore.go index de004129dd..12776d4295 100644 --- a/pubsub/kubemq/kubemq_eventstore.go +++ b/pubsub/kubemq/kubemq_eventstore.go @@ -3,6 +3,7 @@ package kubemq import ( "context" "encoding/json" + "errors" "fmt" "sync" "time" @@ -108,7 +109,7 @@ func (k *kubeMQEventStore) Publish(req *pubsub.PublishRequest) error { return err } if req.Topic == "" { - return fmt.Errorf("kubemq pub/sub error: topic is required") + return errors.New("kubemq pub/sub error: topic is required") } k.logger.Debugf("kubemq pub/sub: publishing message to %s", req.Topic) metadata := "" @@ -143,7 +144,7 @@ func (k *kubeMQEventStore) Publish(req *pubsub.PublishRequest) error { return res.Err } case <-time.After(k.waitForResultTimeout): - return fmt.Errorf("kubemq pub/sub error: timeout waiting for response") + return errors.New("kubemq pub/sub error: timeout waiting for response") } return nil } diff --git a/pubsub/kubemq/kubemq_eventstore_test.go b/pubsub/kubemq/kubemq_eventstore_test.go index e4d3bd1bca..6d79081eb5 100644 --- a/pubsub/kubemq/kubemq_eventstore_test.go +++ b/pubsub/kubemq/kubemq_eventstore_test.go @@ -2,7 +2,7 @@ package kubemq import ( "context" - "fmt" + "errors" "testing" "time" @@ -114,7 +114,7 @@ func Test_kubeMQEventsStore_Publish(t *testing.T) { Data: []byte("data"), Topic: "some-topic", }, - resultError: fmt.Errorf("some error"), + resultError: errors.New("some error"), wantErr: true, }, { @@ -134,7 +134,7 @@ func Test_kubeMQEventsStore_Publish(t *testing.T) { Topic: "some-topic", }, resultError: nil, - publishErr: fmt.Errorf("some error"), + publishErr: errors.New("some error"), wantErr: true, }, } @@ -198,7 +198,7 @@ func Test_kubeMQkubeMQEventsStore_Subscribe(t *testing.T) { subscribeHandler: func(ctx context.Context, msg *pubsub.NewMessage) error { return nil }, - subscribeError: fmt.Errorf("some error"), + subscribeError: errors.New("some error"), wantErr: true, }, } diff --git a/pubsub/kubemq/metadata.go b/pubsub/kubemq/metadata.go index 19f3f3bae8..3964f6c40c 100644 --- a/pubsub/kubemq/metadata.go +++ b/pubsub/kubemq/metadata.go @@ -1,7 +1,7 @@ package kubemq import ( - "fmt" + "errors" "strconv" "strings" @@ -26,15 +26,15 @@ func parseAddress(address string) (string, int, error) { var err error hostPort := strings.Split(address, ":") if len(hostPort) != 2 { - return "", 0, fmt.Errorf("invalid kubeMQ address, address format is invalid") + return "", 0, errors.New("invalid kubeMQ address, address format is invalid") } host = hostPort[0] if len(host) == 0 { - return "", 0, fmt.Errorf("invalid kubeMQ address, host is empty") + return "", 0, errors.New("invalid kubeMQ address, host is empty") } port, err = strconv.Atoi(hostPort[1]) if err != nil { - return "", 0, fmt.Errorf("invalid kubeMQ address, port is invalid") + return "", 0, errors.New("invalid kubeMQ address, port is invalid") } return host, port, nil } @@ -56,7 +56,7 @@ func createMetadata(pubSubMetadata pubsub.Metadata) (*kubemqMetadata, error) { return nil, err } } else { - return nil, fmt.Errorf("invalid kubeMQ address, address is empty") + return nil, errors.New("invalid kubeMQ address, address is empty") } return result, nil } diff --git a/pubsub/mqtt3/mqtt.go b/pubsub/mqtt3/mqtt.go index f36a7ceb37..75442b2714 100644 --- a/pubsub/mqtt3/mqtt.go +++ b/pubsub/mqtt3/mqtt.go @@ -459,7 +459,7 @@ func buildRegexForTopic(topicName string) string { if strings.ContainsAny(topicName, "#+") { regexStr = "^" // It's ok to iterate over bytes here (rather than codepoints) because all characters we're looking for are always single-byte - for i := 0; i < len(topicName); i++ { + for i := range len(topicName) { // Wildcard chars must either be at the beginning of the string or must follow a / okPos = (i == 0 || topicName[i-1] == '/') if topicName[i] == '#' && okPos { diff --git a/pubsub/pubsub.go b/pubsub/pubsub.go index 36e1541ff0..f61261108e 100644 --- a/pubsub/pubsub.go +++ b/pubsub/pubsub.go @@ -15,7 +15,7 @@ package pubsub import ( "context" - "fmt" + "errors" "io" "github.com/dapr/components-contrib/health" @@ -73,6 +73,6 @@ func Ping(ctx context.Context, pubsub PubSub) error { if pubsubWithPing, ok := pubsub.(health.Pinger); ok { return pubsubWithPing.Ping(ctx) } else { - return fmt.Errorf("ping is not implemented by this pubsub") + return errors.New("ping is not implemented by this pubsub") } } diff --git a/pubsub/pulsar/pulsar.go b/pubsub/pulsar/pulsar.go index 7a77cea601..6e4fb94d87 100644 --- a/pubsub/pulsar/pulsar.go +++ b/pubsub/pulsar/pulsar.go @@ -212,7 +212,7 @@ func (p *Pulsar) Init(ctx context.Context, metadata pubsub.Metadata) error { } }) if err != nil { - return fmt.Errorf("could not initialize pulsar lru cache for publisher") + return errors.New("could not initialize pulsar lru cache for publisher") } p.cache = c defer p.cache.Purge() @@ -318,7 +318,6 @@ func parsePublishMetadata(req *pubsub.PublishRequest, schema schemaMetadata) ( case jsonProtocol: var obj interface{} err = json.Unmarshal(req.Data, &obj) - if err != nil { return nil, err } @@ -332,7 +331,6 @@ func parsePublishMetadata(req *pubsub.PublishRequest, schema schemaMetadata) ( } err = avro.Unmarshal(avroSchema, req.Data, &obj) - if err != nil { return nil, err } diff --git a/pubsub/rabbitmq/metadata_test.go b/pubsub/rabbitmq/metadata_test.go index 435babeff4..6ebebe08a8 100644 --- a/pubsub/rabbitmq/metadata_test.go +++ b/pubsub/rabbitmq/metadata_test.go @@ -104,7 +104,7 @@ func TestCreateMetadata(t *testing.T) { invalidDeliveryModes := []string{"3", "10", "-1"} for _, deliveryMode := range invalidDeliveryModes { - t.Run(fmt.Sprintf("deliveryMode value=%s", deliveryMode), func(t *testing.T) { + t.Run("deliveryMode value="+deliveryMode, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -317,7 +317,7 @@ func TestCreateMetadata(t *testing.T) { }) for _, tt := range booleanFlagTests { - t.Run(fmt.Sprintf("autoAck value=%s", tt.in), func(t *testing.T) { + t.Run("autoAck value="+tt.in, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -337,7 +337,7 @@ func TestCreateMetadata(t *testing.T) { } for _, tt := range booleanFlagTests { - t.Run(fmt.Sprintf("requeueInFailure value=%s", tt.in), func(t *testing.T) { + t.Run("requeueInFailure value="+tt.in, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -357,7 +357,7 @@ func TestCreateMetadata(t *testing.T) { } for _, tt := range booleanFlagTests { - t.Run(fmt.Sprintf("deleteWhenUnused value=%s", tt.in), func(t *testing.T) { + t.Run("deleteWhenUnused value="+tt.in, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -377,7 +377,7 @@ func TestCreateMetadata(t *testing.T) { } for _, tt := range booleanFlagTests { - t.Run(fmt.Sprintf("durable value=%s", tt.in), func(t *testing.T) { + t.Run("durable value="+tt.in, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -397,7 +397,7 @@ func TestCreateMetadata(t *testing.T) { } for _, tt := range booleanFlagTests { - t.Run(fmt.Sprintf("publisherConfirm value=%s", tt.in), func(t *testing.T) { + t.Run("publisherConfirm value="+tt.in, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -417,7 +417,7 @@ func TestCreateMetadata(t *testing.T) { } for _, tt := range booleanFlagTests { - t.Run(fmt.Sprintf("enableDeadLetter value=%s", tt.in), func(t *testing.T) { + t.Run("enableDeadLetter value="+tt.in, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ @@ -438,7 +438,7 @@ func TestCreateMetadata(t *testing.T) { validExchangeKind := []string{amqp.ExchangeDirect, amqp.ExchangeTopic, amqp.ExchangeFanout, amqp.ExchangeHeaders} for _, exchangeKind := range validExchangeKind { - t.Run(fmt.Sprintf("exchangeKind value=%s", exchangeKind), func(t *testing.T) { + t.Run("exchangeKind value="+exchangeKind, func(t *testing.T) { fakeProperties := getFakeProperties() fakeMetaData := pubsub.Metadata{ diff --git a/pubsub/rabbitmq/rabbitmq.go b/pubsub/rabbitmq/rabbitmq.go index 4724fcec67..d0ddd1e3c7 100644 --- a/pubsub/rabbitmq/rabbitmq.go +++ b/pubsub/rabbitmq/rabbitmq.go @@ -134,7 +134,6 @@ func dial(protocol, uri, clientName string, heartBeat time.Duration, tlsCfg *tls } } conn, err = amqp.DialConfig(uri, cfg) - if err != nil { return nil, nil, err } @@ -272,7 +271,7 @@ func (r *rabbitMQ) publishSync(ctx context.Context, req *pubsub.PublishRequest) // Blocks until the server confirms ok := confirm.Wait() if !ok { - err = fmt.Errorf("did not receive confirmation of publishing") + err = errors.New("did not receive confirmation of publishing") r.logger.Errorf("%s publishing to %s failed: %v", logMessagePrefix, req.Topic, err) } } @@ -482,7 +481,7 @@ func (r *rabbitMQ) prepareSubscription(channel rabbitMQChannelBroker, req pubsub metadataRoutingKey = val } routingKeys := strings.Split(metadataRoutingKey, ",") - for i := 0; i < len(routingKeys); i++ { + for i := range len(routingKeys) { routingKey := routingKeys[i] r.logger.Debugf("%s binding queue '%s' to exchange '%s' with routing key '%s'", logMessagePrefix, q.Name, req.Topic, routingKey) err = channel.QueueBind(q.Name, routingKey, req.Topic, false, nil) @@ -521,7 +520,6 @@ func (r *rabbitMQ) subscribeForever(ctx context.Context, req pubsub.SubscribeReq ) for { channel, connectionCount, q, err = r.ensureSubscription(req, queueName) - if err != nil { errFuncName = "ensureSubscription" break diff --git a/pubsub/redis/redis.go b/pubsub/redis/redis.go index 310eaddad1..9cf61550e1 100644 --- a/pubsub/redis/redis.go +++ b/pubsub/redis/redis.go @@ -86,7 +86,7 @@ func (r *redisStreams) Init(ctx context.Context, metadata pubsub.Metadata) error } r.queue = make(chan redisMessageWrapper, int(r.clientSettings.QueueDepth)) - for i := uint(0); i < r.clientSettings.Concurrency; i++ { + for range r.clientSettings.Concurrency { r.wg.Add(1) go func() { defer r.wg.Done() diff --git a/pubsub/solace/amqp/amqp.go b/pubsub/solace/amqp/amqp.go index 11a95e1977..16c3ad58c0 100644 --- a/pubsub/solace/amqp/amqp.go +++ b/pubsub/solace/amqp/amqp.go @@ -130,7 +130,6 @@ func (a *amqpPubSub) Publish(ctx context.Context, req *pubsub.PublishRequest) er a.logger.Errorf("Unable to create link to %s", req.Topic, err) } else { err = sender.Send(ctx, m, nil) - // If the publish operation has failed, attempt to republish a maximum number of times // before giving up if err != nil { @@ -139,7 +138,6 @@ func (a *amqpPubSub) Publish(ctx context.Context, req *pubsub.PublishRequest) er // Send message err = sender.Send(ctx, m, nil) - if err != nil { a.logger.Warnf("Failed to publish a message to the broker", err) } diff --git a/pubsub/tls.go b/pubsub/tls.go index fa031696ee..cab7977aee 100644 --- a/pubsub/tls.go +++ b/pubsub/tls.go @@ -65,7 +65,7 @@ func ConvertTLSPropertiesToTLSConfig(properties TLSProperties) (*tls.Config, err if properties.CACert != "" { tlsConfig.RootCAs = x509.NewCertPool() if ok := tlsConfig.RootCAs.AppendCertsFromPEM([]byte(properties.CACert)); !ok { - return tlsConfig, fmt.Errorf("unable to load CA certificate") + return tlsConfig, errors.New("unable to load CA certificate") } } diff --git a/secretstores/alicloud/parameterstore/parameterstore_test.go b/secretstores/alicloud/parameterstore/parameterstore_test.go index 530dc5965c..5760121c49 100644 --- a/secretstores/alicloud/parameterstore/parameterstore_test.go +++ b/secretstores/alicloud/parameterstore/parameterstore_test.go @@ -15,7 +15,7 @@ package parameterstore import ( "context" - "fmt" + "errors" "testing" oos "github.com/alibabacloud-go/oos-20190601/client" @@ -62,11 +62,11 @@ func (m *mockedParameterStore) GetSecretParametersByPathWithOptions(request *oos type mockedParameterStoreReturnError struct{} func (m *mockedParameterStoreReturnError) GetSecretParameterWithOptions(request *oos.GetSecretParameterRequest, runtime *util.RuntimeOptions) (*oos.GetSecretParameterResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } func (m *mockedParameterStoreReturnError) GetSecretParametersByPathWithOptions(request *oos.GetSecretParametersByPathRequest, runtime *util.RuntimeOptions) (*oos.GetSecretParametersByPathResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } func TestInit(t *testing.T) { diff --git a/secretstores/aws/parameterstore/parameterstore_test.go b/secretstores/aws/parameterstore/parameterstore_test.go index 9747f58b2a..8d9bcf6065 100644 --- a/secretstores/aws/parameterstore/parameterstore_test.go +++ b/secretstores/aws/parameterstore/parameterstore_test.go @@ -16,6 +16,7 @@ package parameterstore import ( "context" + "errors" "fmt" "strings" "testing" @@ -154,7 +155,7 @@ func TestGetSecret(t *testing.T) { s := ssmSecretStore{ client: &mockedSSM{ GetParameterFn: func(ctx context.Context, input *ssm.GetParameterInput, option ...request.Option) (*ssm.GetParameterOutput, error) { - return nil, fmt.Errorf("failed due to any reason") + return nil, errors.New("failed due to any reason") }, }, } @@ -253,7 +254,7 @@ func TestGetBulkSecrets(t *testing.T) { }}, nil }, GetParameterFn: func(ctx context.Context, input *ssm.GetParameterInput, option ...request.Option) (*ssm.GetParameterOutput, error) { - return nil, fmt.Errorf("failed due to any reason") + return nil, errors.New("failed due to any reason") }, }, } @@ -268,7 +269,7 @@ func TestGetBulkSecrets(t *testing.T) { s := ssmSecretStore{ client: &mockedSSM{ DescribeParametersFn: func(context.Context, *ssm.DescribeParametersInput, ...request.Option) (*ssm.DescribeParametersOutput, error) { - return nil, fmt.Errorf("failed due to any reason") + return nil, errors.New("failed due to any reason") }, }, } diff --git a/secretstores/aws/secretmanager/secretmanager_test.go b/secretstores/aws/secretmanager/secretmanager_test.go index 1a38452d94..85918237a3 100644 --- a/secretstores/aws/secretmanager/secretmanager_test.go +++ b/secretstores/aws/secretmanager/secretmanager_test.go @@ -16,7 +16,7 @@ package secretmanager import ( "context" - "fmt" + "errors" "testing" "github.com/aws/aws-sdk-go/aws/request" @@ -141,7 +141,7 @@ func TestGetSecret(t *testing.T) { s := smSecretStore{ client: &mockedSM{ GetSecretValueFn: func(ctx context.Context, input *secretsmanager.GetSecretValueInput, option ...request.Option) (*secretsmanager.GetSecretValueOutput, error) { - return nil, fmt.Errorf("failed due to any reason") + return nil, errors.New("failed due to any reason") }, }, } diff --git a/secretstores/gcp/secretmanager/secretmanager.go b/secretstores/gcp/secretmanager/secretmanager.go index 619c8ea201..19c795204c 100644 --- a/secretstores/gcp/secretmanager/secretmanager.go +++ b/secretstores/gcp/secretmanager/secretmanager.go @@ -16,6 +16,7 @@ package secretmanager import ( "context" "encoding/json" + "errors" "fmt" "reflect" @@ -103,11 +104,11 @@ func (s *Store) GetSecret(ctx context.Context, req secretstores.GetSecretRequest res := secretstores.GetSecretResponse{Data: nil} if s.client == nil { - return res, fmt.Errorf("client is not initialized") + return res, errors.New("client is not initialized") } if req.Name == "" { - return res, fmt.Errorf("missing secret name in request") + return res, errors.New("missing secret name in request") } secretName := fmt.Sprintf("projects/%s/secrets/%s", s.ProjectID, req.Name) @@ -131,11 +132,11 @@ func (s *Store) BulkGetSecret(ctx context.Context, req secretstores.BulkGetSecre response := map[string]map[string]string{} if s.client == nil { - return secretstores.BulkGetSecretResponse{Data: nil}, fmt.Errorf("client is not initialized") + return secretstores.BulkGetSecretResponse{Data: nil}, errors.New("client is not initialized") } request := &secretmanagerpb.ListSecretsRequest{ - Parent: fmt.Sprintf("projects/%s", s.ProjectID), + Parent: "projects/" + s.ProjectID, } it := s.client.ListSecrets(ctx, request) @@ -183,16 +184,16 @@ func (s *Store) parseSecretManagerMetadata(metadataRaw secretstores.Metadata) (* } if meta.Type == "" { - return nil, fmt.Errorf("missing property `type` in metadata") + return nil, errors.New("missing property `type` in metadata") } if meta.ProjectID == "" { - return nil, fmt.Errorf("missing property `project_id` in metadata") + return nil, errors.New("missing property `project_id` in metadata") } if meta.PrivateKey == "" { - return nil, fmt.Errorf("missing property `private_key` in metadata") + return nil, errors.New("missing property `private_key` in metadata") } if meta.ClientEmail == "" { - return nil, fmt.Errorf("missing property `client_email` in metadata") + return nil, errors.New("missing property `client_email` in metadata") } return &meta, nil diff --git a/secretstores/gcp/secretmanager/secretmanager_test.go b/secretstores/gcp/secretmanager/secretmanager_test.go index ce125ab49b..10db5d49d3 100644 --- a/secretstores/gcp/secretmanager/secretmanager_test.go +++ b/secretstores/gcp/secretmanager/secretmanager_test.go @@ -15,7 +15,7 @@ package secretmanager import ( "context" - "fmt" + "errors" "testing" secretmanager "cloud.google.com/go/secretmanager/apiv1" @@ -71,7 +71,7 @@ func TestInit(t *testing.T) { err := sm.Init(ctx, m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("failed to setup secretmanager client: google: could not parse key: private key should be a PEM or plain PKCS1 or PKCS8; parse error: asn1: syntax error: truncated tag or length")) + assert.Equal(t, err, errors.New("failed to setup secretmanager client: google: could not parse key: private key should be a PEM or plain PKCS1 or PKCS8; parse error: asn1: syntax error: truncated tag or length")) }) t.Run("Init with missing `type` metadata", func(t *testing.T) { @@ -80,7 +80,7 @@ func TestInit(t *testing.T) { } err := sm.Init(ctx, m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing property `type` in metadata")) + assert.Equal(t, err, errors.New("missing property `type` in metadata")) }) t.Run("Init with missing `project_id` metadata", func(t *testing.T) { @@ -89,7 +89,7 @@ func TestInit(t *testing.T) { } err := sm.Init(ctx, m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing property `project_id` in metadata")) + assert.Equal(t, err, errors.New("missing property `project_id` in metadata")) }) } @@ -100,7 +100,7 @@ func TestGetSecret(t *testing.T) { t.Run("Get Secret - without Init", func(t *testing.T) { v, err := sm.GetSecret(context.Background(), secretstores.GetSecretRequest{Name: "test"}) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("client is not initialized")) + assert.Equal(t, err, errors.New("client is not initialized")) assert.Equal(t, secretstores.GetSecretResponse{Data: nil}, v) }) @@ -154,7 +154,7 @@ func TestBulkGetSecret(t *testing.T) { t.Run("Bulk Get Secret - without Init", func(t *testing.T) { v, err := sm.BulkGetSecret(context.Background(), secretstores.BulkGetSecretRequest{}) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("client is not initialized")) + assert.Equal(t, err, errors.New("client is not initialized")) assert.Equal(t, secretstores.BulkGetSecretResponse{Data: nil}, v) }) diff --git a/secretstores/hashicorp/vault/vault.go b/secretstores/hashicorp/vault/vault.go index ffb02bd470..beab8cc7eb 100644 --- a/secretstores/hashicorp/vault/vault.go +++ b/secretstores/hashicorp/vault/vault.go @@ -400,12 +400,12 @@ func (v *vaultSecretStore) isSecretPath(key string) bool { func (v *vaultSecretStore) initVaultToken() error { // Test that at least one of them are set if not return error if v.vaultToken == "" && v.vaultTokenMountPath == "" { - return fmt.Errorf("token mount path and token not set") + return errors.New("token mount path and token not set") } // Test that both are not set. If so return error if v.vaultToken != "" && v.vaultTokenMountPath != "" { - return fmt.Errorf("token mount path and token both set") + return errors.New("token mount path and token both set") } if v.vaultToken != "" { @@ -464,7 +464,7 @@ func (v *vaultSecretStore) getRootCAsPools(vaultCAPem string, vaultCAPath string certPool := x509.NewCertPool() cert := []byte(vaultCAPem) if ok := certPool.AppendCertsFromPEM(cert); !ok { - return nil, fmt.Errorf("couldn't read PEM") + return nil, errors.New("couldn't read PEM") } return certPool, nil @@ -505,7 +505,7 @@ func readCertificateFile(certPool *x509.CertPool, path string) error { } if ok := certPool.AppendCertsFromPEM(pemFile); !ok { - return fmt.Errorf("couldn't read PEM") + return errors.New("couldn't read PEM") } return nil diff --git a/secretstores/huaweicloud/csms/csms_test.go b/secretstores/huaweicloud/csms/csms_test.go index 93dd6d9e8e..a1e2eb15ad 100644 --- a/secretstores/huaweicloud/csms/csms_test.go +++ b/secretstores/huaweicloud/csms/csms_test.go @@ -15,7 +15,7 @@ package csms import ( "context" - "fmt" + "errors" "testing" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/csms/v1/model" @@ -72,17 +72,17 @@ func (m *mockedCsmsSecretStoreReturnError) ListSecrets(request *model.ListSecret } func (m *mockedCsmsSecretStoreReturnError) ShowSecretVersion(request *model.ShowSecretVersionRequest) (*model.ShowSecretVersionResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } type mockedCsmsSecretStoreBothReturnError struct{} func (m *mockedCsmsSecretStoreBothReturnError) ListSecrets(request *model.ListSecretsRequest) (*model.ListSecretsResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } func (m *mockedCsmsSecretStoreBothReturnError) ShowSecretVersion(request *model.ShowSecretVersionRequest) (*model.ShowSecretVersionResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } func TestGetSecret(t *testing.T) { diff --git a/secretstores/local/file/filestore.go b/secretstores/local/file/filestore.go index 09e183237d..e52e49dbd4 100644 --- a/secretstores/local/file/filestore.go +++ b/secretstores/local/file/filestore.go @@ -196,7 +196,7 @@ func (j *localSecretStore) visitPrimitive(context string) error { } func (j *localSecretStore) visitArray(array []interface{}) error { - for i := 0; i < len(array); i++ { + for i := range len(array) { j.enterContext(strconv.Itoa(i)) err := j.visitProperty(array[i]) if err != nil { @@ -244,7 +244,7 @@ func (j *localSecretStore) getLocalSecretStoreMetadata(spec secretstores.Metadat } if meta.SecretsFile == "" { - return nil, fmt.Errorf("missing local secrets file in metadata") + return nil, errors.New("missing local secrets file in metadata") } return &meta, nil diff --git a/secretstores/local/file/filestore_test.go b/secretstores/local/file/filestore_test.go index 374d8c8001..54df50e939 100644 --- a/secretstores/local/file/filestore_test.go +++ b/secretstores/local/file/filestore_test.go @@ -17,6 +17,7 @@ package file import ( "context" "encoding/json" + "errors" "fmt" "testing" @@ -52,7 +53,7 @@ func TestInit(t *testing.T) { } err := s.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing local secrets file in metadata")) + assert.Equal(t, err, errors.New("missing local secrets file in metadata")) }) } diff --git a/secretstores/secret_store.go b/secretstores/secret_store.go index 6214c568cd..89875cf8aa 100644 --- a/secretstores/secret_store.go +++ b/secretstores/secret_store.go @@ -15,7 +15,7 @@ package secretstores import ( "context" - "fmt" + "errors" "io" "github.com/dapr/components-contrib/health" @@ -43,6 +43,6 @@ func Ping(ctx context.Context, secretStore SecretStore) error { if secretStoreWithPing, ok := secretStore.(health.Pinger); ok { return secretStoreWithPing.Ping(ctx) } else { - return fmt.Errorf("ping is not implemented by this secret store") + return errors.New("ping is not implemented by this secret store") } } diff --git a/secretstores/tencentcloud/ssm/ssm_test.go b/secretstores/tencentcloud/ssm/ssm_test.go index 9ca94965ee..187ec48234 100644 --- a/secretstores/tencentcloud/ssm/ssm_test.go +++ b/secretstores/tencentcloud/ssm/ssm_test.go @@ -15,7 +15,7 @@ package ssm import ( "context" - "fmt" + "errors" "testing" "github.com/stretchr/testify/assert" @@ -77,17 +77,17 @@ func (m *mockedSsmSecretStoreReturnError) ListSecretsWithContext(ctx context.Con } func (m *mockedSsmSecretStoreReturnError) GetSecretValueWithContext(ctx context.Context, request *ssm.GetSecretValueRequest) (*ssm.GetSecretValueResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } type mockedSsmSecretStoreBothReturnError struct{} func (m *mockedSsmSecretStoreBothReturnError) ListSecretsWithContext(ctx context.Context, request *ssm.ListSecretsRequest) (*ssm.ListSecretsResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } func (m *mockedSsmSecretStoreBothReturnError) GetSecretValueWithContext(ctx context.Context, request *ssm.GetSecretValueRequest) (*ssm.GetSecretValueResponse, error) { - return nil, fmt.Errorf("mocked error") + return nil, errors.New("mocked error") } func TestGetSecret(t *testing.T) { diff --git a/state/aws/dynamodb/dynamodb_test.go b/state/aws/dynamodb/dynamodb_test.go index 238fcd6919..d1f98b70ba 100644 --- a/state/aws/dynamodb/dynamodb_test.go +++ b/state/aws/dynamodb/dynamodb_test.go @@ -18,7 +18,6 @@ package dynamodb import ( "context" "errors" - "fmt" "testing" "time" @@ -109,7 +108,7 @@ func TestInit(t *testing.T) { } err := s.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing dynamodb table name")) + assert.Equal(t, err, errors.New("missing dynamodb table name")) }) t.Run("Init with valid table", func(t *testing.T) { @@ -267,7 +266,7 @@ func TestGet(t *testing.T) { ss := StateStore{ client: &mockedDynamoDB{ GetItemWithContextFn: func(ctx context.Context, input *dynamodb.GetItemInput, op ...request.Option) (output *dynamodb.GetItemOutput, err error) { - return nil, fmt.Errorf("failed to retrieve data") + return nil, errors.New("failed to retrieve data") }, }, } @@ -606,7 +605,7 @@ func TestSet(t *testing.T) { } ss.client = &mockedDynamoDB{ PutItemWithContextFn: func(ctx context.Context, input *dynamodb.PutItemInput, op ...request.Option) (output *dynamodb.PutItemOutput, err error) { - return nil, fmt.Errorf("unable to put item") + return nil, errors.New("unable to put item") }, } req := &state.SetRequest{ @@ -790,7 +789,7 @@ func TestDelete(t *testing.T) { ss := StateStore{ client: &mockedDynamoDB{ DeleteItemWithContextFn: func(ctx context.Context, input *dynamodb.DeleteItemInput, op ...request.Option) (output *dynamodb.DeleteItemOutput, err error) { - return nil, fmt.Errorf("unable to delete item") + return nil, errors.New("unable to delete item") }, }, } diff --git a/state/azure/blobstorage/internal/blobstorage.go b/state/azure/blobstorage/internal/blobstorage.go index 69f1fa047a..cd4399068f 100644 --- a/state/azure/blobstorage/internal/blobstorage.go +++ b/state/azure/blobstorage/internal/blobstorage.go @@ -148,7 +148,6 @@ func (r *StateStore) writeFile(ctx context.Context, req *state.SetRequest) error blockBlobClient := r.containerClient.NewBlockBlobClient(r.getFileNameFn(req.Key)) _, err = blockBlobClient.UploadBuffer(ctx, r.marshal(req), &uploadOptions) - if err != nil { // Check if the error is due to ETag conflict if req.HasETag() && isETagConflictError(err) { diff --git a/state/azure/blobstorage/internal/blobstorage_test.go b/state/azure/blobstorage/internal/blobstorage_test.go index 233b24e028..d4814b490b 100644 --- a/state/azure/blobstorage/internal/blobstorage_test.go +++ b/state/azure/blobstorage/internal/blobstorage_test.go @@ -15,7 +15,7 @@ package internal import ( "context" - "fmt" + "errors" "testing" "github.com/stretchr/testify/assert" @@ -37,6 +37,6 @@ func TestInit(t *testing.T) { } err := s.Init(context.Background(), m) require.Error(t, err) - assert.Equal(t, err, fmt.Errorf("missing or empty accountName field from metadata")) + assert.Equal(t, err, errors.New("missing or empty accountName field from metadata")) }) } diff --git a/state/azure/cosmosdb/cosmosdb_query.go b/state/azure/cosmosdb/cosmosdb_query.go index 0495827f25..6e25104814 100644 --- a/state/azure/cosmosdb/cosmosdb_query.go +++ b/state/azure/cosmosdb/cosmosdb_query.go @@ -277,9 +277,8 @@ func (q *Query) execute(ctx context.Context, client *azcosmos.ContainerClient) ( token := "" for queryPager.More() { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, defaultTimeout) - queryResponse, innerErr := queryPager.NextPage(ctx) + ctxWithTimeout, cancel := context.WithTimeout(ctx, defaultTimeout) + queryResponse, innerErr := queryPager.NextPage(ctxWithTimeout) cancel() if innerErr != nil { return nil, "", innerErr diff --git a/state/azure/tablestorage/tablestorage.go b/state/azure/tablestorage/tablestorage.go index 7e87f71386..9a4af2ac2a 100644 --- a/state/azure/tablestorage/tablestorage.go +++ b/state/azure/tablestorage/tablestorage.go @@ -258,7 +258,6 @@ func (r *StateStore) writeRow(ctx context.Context, req *state.SetRequest) error // InsertOrReplace does not support ETag concurrency, therefore we will use Insert to check for key existence // and then use Update to update the key if it exists with the specified ETag _, err = r.client.AddEntity(writeContext, marshalledEntity, nil) - if err != nil { // If Insert failed because item already exists, try to Update instead per Upsert semantics if isEntityAlreadyExistsError(err) { diff --git a/state/bulk.go b/state/bulk.go index 3d7d8ac503..a71eca1e46 100644 --- a/state/bulk.go +++ b/state/bulk.go @@ -102,7 +102,7 @@ func DoBulkGet(ctx context.Context, req []GetRequest, opts BulkGetOpts, getFn fu } // We can detect that all goroutines are done when limitCh is completely empty - for i := 0; i < opts.Parallelism; i++ { + for range opts.Parallelism { limitCh <- struct{}{} } @@ -149,7 +149,7 @@ func DoBulkSetDelete[T stateRequestConstraint](ctx context.Context, req []T, met } errs := make([]error, len(req)) - for i := 0; i < len(req); i++ { + for i := range len(req) { errs[i] = <-errCh } diff --git a/state/bulk_test.go b/state/bulk_test.go index 0b2e47011e..7d94dabdda 100644 --- a/state/bulk_test.go +++ b/state/bulk_test.go @@ -80,7 +80,7 @@ func TestBulkStore(t *testing.T) { require.True(t, ok) errs := merr.Unwrap() require.Len(t, errs, 2) - for i := 0; i < 2; i++ { + for i := range 2 { var bse BulkStoreError require.ErrorAs(t, errs[i], &bse) assert.True(t, bse.key == "error-key1" || bse.key == "error-key2") diff --git a/state/cassandra/cassandra.go b/state/cassandra/cassandra.go index 370e9d6385..d1cf277252 100644 --- a/state/cassandra/cassandra.go +++ b/state/cassandra/cassandra.go @@ -196,7 +196,7 @@ func getCassandraMetadata(meta state.Metadata) (*cassandraMetadata, error) { } if m.Hosts == nil || len(m.Hosts) == 0 { - return nil, fmt.Errorf("missing or empty hosts field from metadata") + return nil, errors.New("missing or empty hosts field from metadata") } if val, ok := meta.Properties[port]; ok && val != "" { diff --git a/state/cockroachdb/cockroachdb_integration_test.go b/state/cockroachdb/cockroachdb_integration_test.go index 9969da3285..d72138bc3f 100644 --- a/state/cockroachdb/cockroachdb_integration_test.go +++ b/state/cockroachdb/cockroachdb_integration_test.go @@ -213,7 +213,7 @@ func testCreateTable(t *testing.T, db *pgxpool.Pool) { func dropTable(t *testing.T, db *pgxpool.Pool, tableName string) { t.Helper() - _, err := db.Exec(context.Background(), fmt.Sprintf("DROP TABLE %s", tableName)) + _, err := db.Exec(context.Background(), "DROP TABLE "+tableName) require.NoError(t, err) } @@ -237,9 +237,9 @@ func deleteItemThatDoesNotExist(t *testing.T, pgs *postgresql.PostgreSQL) { func multiWithSetOnly(t *testing.T, pgs *postgresql.PostgreSQL) { t.Helper() - var operations []state.TransactionalStateOperation - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), @@ -270,9 +270,9 @@ func multiWithSetOnly(t *testing.T, pgs *postgresql.PostgreSQL) { func multiWithDeleteOnly(t *testing.T, pgs *postgresql.PostgreSQL) { t.Helper() - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{ Key: randomKey(), ETag: nil, @@ -307,9 +307,9 @@ func multiWithDeleteOnly(t *testing.T, pgs *postgresql.PostgreSQL) { func multiWithDeleteAndSet(t *testing.T, pgs *postgresql.PostgreSQL) { t.Helper() - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{ Key: randomKey(), ETag: nil, @@ -331,8 +331,8 @@ func multiWithDeleteAndSet(t *testing.T, pgs *postgresql.PostgreSQL) { } // Create the set requests. - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), diff --git a/state/couchbase/couchbase.go b/state/couchbase/couchbase.go index 15060e47d0..c088a39c7a 100644 --- a/state/couchbase/couchbase.go +++ b/state/couchbase/couchbase.go @@ -15,6 +15,7 @@ package couchbase import ( "context" + "errors" "fmt" "reflect" "strconv" @@ -85,19 +86,19 @@ func parseAndValidateMetadata(meta state.Metadata) (*couchbaseMetadata, error) { } if m.CouchbaseURL == "" { - return nil, fmt.Errorf("couchbase URL is missing") + return nil, errors.New("couchbase URL is missing") } if m.Username == "" { - return nil, fmt.Errorf("couchbase username is missing") + return nil, errors.New("couchbase username is missing") } if m.Password == "" { - return nil, fmt.Errorf("couchbase password is missing") + return nil, errors.New("couchbase password is missing") } if m.BucketName == "" { - return nil, fmt.Errorf("couchbase bucket name is missing") + return nil, errors.New("couchbase bucket name is missing") } v := meta.Properties[numReplicasDurableReplication] diff --git a/state/gcp/firestore/firestore.go b/state/gcp/firestore/firestore.go index 5b94e76b9f..2e4b8eb62e 100644 --- a/state/gcp/firestore/firestore.go +++ b/state/gcp/firestore/firestore.go @@ -149,7 +149,6 @@ func (f *Firestore) Set(ctx context.Context, req *state.SetRequest) error { key := datastore.NameKey(f.entityKind, req.Key, nil) _, err = f.client.Put(ctx, key, entity) - if err != nil { return err } diff --git a/state/hazelcast/hazelcast.go b/state/hazelcast/hazelcast.go index 12b45ae67a..2fe56f0488 100644 --- a/state/hazelcast/hazelcast.go +++ b/state/hazelcast/hazelcast.go @@ -86,7 +86,6 @@ func (store *Hazelcast) Init(_ context.Context, metadata state.Metadata) error { return err } store.hzMap, err = client.GetMap(meta.HazelcastMap) - if err != nil { return err } @@ -117,7 +116,6 @@ func (store *Hazelcast) Set(ctx context.Context, req *state.SetRequest) error { } } _, err = store.hzMap.Put(req.Key, value) - if err != nil { return fmt.Errorf("failed to set key %s: %w", req.Key, err) } diff --git a/state/memcached/memcached.go b/state/memcached/memcached.go index 8d91508f5d..9998cc5fdf 100644 --- a/state/memcached/memcached.go +++ b/state/memcached/memcached.go @@ -117,7 +117,7 @@ func getMemcachedMetadata(meta state.Metadata) (*memcachedMetadata, error) { if val, ok := meta.Properties[maxIdleConnections]; ok && val != "" { p, err := strconv.Atoi(val) if err != nil { - return nil, fmt.Errorf("error parsing maxIdleConnections") + return nil, errors.New("error parsing maxIdleConnections") } m.MaxIdleConnections = p } @@ -125,7 +125,7 @@ func getMemcachedMetadata(meta state.Metadata) (*memcachedMetadata, error) { if val, ok := meta.Properties[timeout]; ok && val != "" { p, err := strconv.Atoi(val) if err != nil { - return nil, fmt.Errorf("error parsing timeout") + return nil, errors.New("error parsing timeout") } m.Timeout = p } diff --git a/state/mongodb/mongodb_query.go b/state/mongodb/mongodb_query.go index 27d132eed2..019f0ed24a 100644 --- a/state/mongodb/mongodb_query.go +++ b/state/mongodb/mongodb_query.go @@ -102,7 +102,7 @@ func (q *Query) VisitIN(f *query.IN) (string, error) { } str := fmt.Sprintf(`{ "value.%s": { "$in": [ `, f.Key) - for i := 0; i < len(f.Vals); i++ { + for i := range len(f.Vals) { if i > 0 { str += ", " } diff --git a/state/mysql/mySQLFactory.go b/state/mysql/mySQLFactory.go index 5cec7c9582..3776b10013 100644 --- a/state/mysql/mySQLFactory.go +++ b/state/mysql/mySQLFactory.go @@ -17,7 +17,7 @@ import ( "crypto/tls" "crypto/x509" "database/sql" - "fmt" + "errors" "os" "github.com/go-sql-driver/mysql" @@ -56,7 +56,7 @@ func (m *mySQLFactory) RegisterTLSConfig(pemPath string) error { ok := rootCertPool.AppendCertsFromPEM(pem) if !ok { - return fmt.Errorf("failed to append PEM") + return errors.New("failed to append PEM") } mysql.RegisterTLSConfig("custom", &tls.Config{RootCAs: rootCertPool, MinVersion: tls.VersionTLS12}) diff --git a/state/mysql/mysql.go b/state/mysql/mysql.go index 8bf90b814f..513373abe5 100644 --- a/state/mysql/mysql.go +++ b/state/mysql/mysql.go @@ -189,7 +189,7 @@ func (m *MySQL) parseMetadata(md map[string]string) error { if meta.ConnectionString == "" { m.logger.Error("Missing MySql connection string") - return fmt.Errorf(errMissingConnectionString) + return errors.New(errMissingConnectionString) } m.connectionString = meta.ConnectionString @@ -328,7 +328,6 @@ func (m *MySQL) ensureStateSchema(ctx context.Context) error { // Close the connection we used to confirm and or create the schema err = m.db.Close() - if err != nil { return err } @@ -463,7 +462,7 @@ func (m *MySQL) Delete(ctx context.Context, req *state.DeleteRequest) error { // logic to state.DeleteWithRetries as a func. func (m *MySQL) deleteValue(parentCtx context.Context, querier querier, req *state.DeleteRequest) error { if req.Key == "" { - return fmt.Errorf("missing key in delete operation") + return errors.New("missing key in delete operation") } var ( @@ -636,7 +635,6 @@ func (m *MySQL) setValue(parentCtx context.Context, querier querier, req *state. ctx, cancel := context.WithTimeout(parentCtx, m.timeout) defer cancel() result, err = querier.ExecContext(ctx, query, params...) - if err != nil { return err } @@ -831,7 +829,7 @@ func validIdentifier(v string) bool { // Loop through the string as byte slice as we only care about ASCII characters b := []byte(v) - for i := 0; i < len(b); i++ { + for i := range len(b) { if (b[i] >= '0' && b[i] <= '9') || (b[i] >= 'a' && b[i] <= 'z') || (b[i] >= 'A' && b[i] <= 'Z') || diff --git a/state/mysql/mysql_integration_test.go b/state/mysql/mysql_integration_test.go index 22052ad5e8..4bce423ba2 100644 --- a/state/mysql/mysql_integration_test.go +++ b/state/mysql/mysql_integration_test.go @@ -454,7 +454,7 @@ func TestMySQLIntegration(t *testing.T) { var operations []state.TransactionalStateOperation var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database @@ -469,7 +469,7 @@ func TestMySQLIntegration(t *testing.T) { // Create the set requests var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), @@ -498,7 +498,7 @@ func TestMySQLIntegration(t *testing.T) { var operations []state.TransactionalStateOperation var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database @@ -526,7 +526,7 @@ func TestMySQLIntegration(t *testing.T) { var operations []state.TransactionalStateOperation var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), diff --git a/state/mysql/mysql_test.go b/state/mysql/mysql_test.go index 0dacfaf158..4b6ea3da93 100644 --- a/state/mysql/mysql_test.go +++ b/state/mysql/mysql_test.go @@ -21,7 +21,6 @@ import ( "encoding/base64" "encoding/json" "errors" - "fmt" "testing" "time" @@ -65,7 +64,7 @@ func TestFinishInitHandlesSchemaExistsError(t *testing.T) { m, _ := mockDatabase(t) defer m.mySQL.Close() - expectedErr := fmt.Errorf("existsError") + expectedErr := errors.New("existsError") m.mock1.ExpectQuery("SELECT EXISTS").WillReturnError(expectedErr) // Act @@ -84,7 +83,7 @@ func TestFinishInitHandlesDatabaseCreateError(t *testing.T) { rows := sqlmock.NewRows([]string{"exists"}).AddRow(0) m.mock1.ExpectQuery("SELECT EXISTS").WillReturnRows(rows) - expectedErr := fmt.Errorf("createDatabaseError") + expectedErr := errors.New("createDatabaseError") m.mock1.ExpectExec("CREATE DATABASE").WillReturnError(expectedErr) // Act @@ -108,7 +107,7 @@ func TestFinishInitHandlesPingError(t *testing.T) { m.mock1.ExpectClose() - expectedErr := fmt.Errorf("pingError") + expectedErr := errors.New("pingError") m.mock2.ExpectPing().WillReturnError(expectedErr) // Act @@ -137,7 +136,7 @@ func TestFinishInitHandlesTableExistsError(t *testing.T) { // Execute use command m.mock2.ExpectPing() - m.mock2.ExpectQuery("SELECT EXISTS").WillReturnError(fmt.Errorf("tableExistsError")) + m.mock2.ExpectQuery("SELECT EXISTS").WillReturnError(errors.New("tableExistsError")) // Act err := m.mySQL.finishInit(context.Background(), m.mySQL.db) @@ -391,7 +390,7 @@ func TestGetHandlesGenericError(t *testing.T) { m, _ := mockDatabase(t) defer m.mySQL.Close() - m.mock1.ExpectQuery("").WillReturnError(fmt.Errorf("generic error")) + m.mock1.ExpectQuery("").WillReturnError(errors.New("generic error")) request := &state.GetRequest{ Key: "UnitTest", @@ -479,7 +478,7 @@ func TestEnsureStateTableHandlesCreateTableError(t *testing.T) { rows := sqlmock.NewRows([]string{"exists"}).AddRow(0) m.mock1.ExpectQuery("SELECT EXISTS").WillReturnRows(rows) - m.mock1.ExpectExec("CREATE TABLE").WillReturnError(fmt.Errorf("CreateTableError")) + m.mock1.ExpectExec("CREATE TABLE").WillReturnError(errors.New("CreateTableError")) // Act err := m.mySQL.ensureStateTable(context.Background(), "dapr_state_store", "state") @@ -550,7 +549,7 @@ func TestInitHandlesRegisterTLSConfigError(t *testing.T) { // Arrange t.Parallel() m, _ := mockDatabase(t) - m.factory.registerErr = fmt.Errorf("registerTLSConfigError") + m.factory.registerErr = errors.New("registerTLSConfigError") metadata := &state.Metadata{ Base: metadata.Base{ diff --git a/state/oci/objectstorage/objectstorage.go b/state/oci/objectstorage/objectstorage.go index 11d8903eaf..d2d87accb1 100644 --- a/state/oci/objectstorage/objectstorage.go +++ b/state/oci/objectstorage/objectstorage.go @@ -16,6 +16,7 @@ package objectstorage import ( "bytes" "context" + "errors" "fmt" "io" "net/http" @@ -256,11 +257,11 @@ func getIdentityAuthenticationDetails(meta objectStoreMetadata) (err error) { // functions that bridge from the Dapr State API to the OCI ObjectStorage Client. func (r *StateStore) writeDocument(ctx context.Context, req *state.SetRequest) error { if len(req.Key) == 0 || req.Key == "" { - return fmt.Errorf("key for value to set was missing from request") + return errors.New("key for value to set was missing from request") } if req.Options.Concurrency == state.FirstWrite && (req.ETag == nil || len(*req.ETag) == 0) { r.logger.Debugf("when FirstWrite is to be enforced, a value must be provided for the ETag") - return fmt.Errorf("when FirstWrite is to be enforced, a value must be provided for the ETag") + return errors.New("when FirstWrite is to be enforced, a value must be provided for the ETag") } metadata := (map[string]string{"category": daprStateStoreMetaLabel}) @@ -299,7 +300,7 @@ func (r *StateStore) convertTTLtoExpiryTime(req *state.SetRequest, metadata map[ func (r *StateStore) readDocument(ctx context.Context, req *state.GetRequest) ([]byte, *string, error) { if len(req.Key) == 0 || req.Key == "" { - return nil, nil, fmt.Errorf("key for value to get was missing from request") + return nil, nil, errors.New("key for value to get was missing from request") } objectName := getFileName(req.Key) content, etag, meta, err := r.client.getObject(ctx, objectName) @@ -331,7 +332,7 @@ func (r *StateStore) pingBucket(ctx context.Context) error { func (r *StateStore) deleteDocument(ctx context.Context, req *state.DeleteRequest) error { if len(req.Key) == 0 || req.Key == "" { - return fmt.Errorf("key for value to delete was missing from request") + return errors.New("key for value to delete was missing from request") } objectName := getFileName(req.Key) @@ -341,7 +342,7 @@ func (r *StateStore) deleteDocument(ctx context.Context, req *state.DeleteReques } if req.Options.Concurrency == state.FirstWrite && (etag == nil || len(*etag) == 0) { r.logger.Debugf("when FirstWrite is to be enforced, a value must be provided for the ETag") - return fmt.Errorf("when FirstWrite is to be enforced, a value must be provided for the ETag") + return errors.New("when FirstWrite is to be enforced, a value must be provided for the ETag") } err := r.client.deleteObject(ctx, objectName, etag) if err != nil { diff --git a/state/oci/objectstorage/objectstorage_integration_test.go b/state/oci/objectstorage/objectstorage_integration_test.go index 5ae2317eeb..c963fada2f 100644 --- a/state/oci/objectstorage/objectstorage_integration_test.go +++ b/state/oci/objectstorage/objectstorage_integration_test.go @@ -5,7 +5,7 @@ package objectstorage import ( "context" - "fmt" + "errors" "os" "testing" "time" @@ -159,7 +159,7 @@ func testSet(t *testing.T, ociProperties map[string]string) { err := statestore.Init(context.Background(), meta) require.NoError(t, err) err = statestore.Set(context.Background(), &state.SetRequest{Value: []byte("test-value")}) - assert.Equal(t, err, fmt.Errorf("key for value to set was missing from request"), "Lacking Key results in error") + assert.Equal(t, err, errors.New("key for value to set was missing from request"), "Lacking Key results in error") }) t.Run("Regular Set Operation", func(t *testing.T) { testKey := "local-test-key" @@ -235,7 +235,7 @@ func testDelete(t *testing.T, ociProperties map[string]string) { err := s.Init(context.Background(), m) require.NoError(t, err) err = s.Delete(context.Background(), &state.DeleteRequest{}) - assert.Equal(t, err, fmt.Errorf("key for value to delete was missing from request"), "Lacking Key results in error") + assert.Equal(t, err, errors.New("key for value to delete was missing from request"), "Lacking Key results in error") }) t.Run("Regular Delete Operation", func(t *testing.T) { testKey := "test-key" diff --git a/state/oci/objectstorage/objectstorage_test.go b/state/oci/objectstorage/objectstorage_test.go index 5f40a6ec00..b1ef3ddfb7 100644 --- a/state/oci/objectstorage/objectstorage_test.go +++ b/state/oci/objectstorage/objectstorage_test.go @@ -15,7 +15,7 @@ package objectstorage import ( "context" - "fmt" + "errors" "io" "testing" "time" @@ -55,42 +55,42 @@ func TestInit(t *testing.T) { meta.Properties[regionKey] = "" err := statestore.Init(context.Background(), meta) require.Error(t, err) - assert.Equal(t, fmt.Errorf("missing or empty region field from metadata"), err, "Lacking configuration property should be spotted") + assert.Equal(t, errors.New("missing or empty region field from metadata"), err, "Lacking configuration property should be spotted") }) t.Run("Init with missing tenancyOCID", func(t *testing.T) { meta.Properties = getDummyOCIObjectStorageConfiguration() meta.Properties["tenancyOCID"] = "" err := statestore.Init(context.Background(), meta) require.Error(t, err) - assert.Equal(t, fmt.Errorf("missing or empty tenancyOCID field from metadata"), err, "Lacking configuration property should be spotted") + assert.Equal(t, errors.New("missing or empty tenancyOCID field from metadata"), err, "Lacking configuration property should be spotted") }) t.Run("Init with missing userOCID", func(t *testing.T) { meta.Properties = getDummyOCIObjectStorageConfiguration() meta.Properties[userKey] = "" err := statestore.Init(context.Background(), meta) require.Error(t, err) - assert.Equal(t, fmt.Errorf("missing or empty userOCID field from metadata"), err, "Lacking configuration property should be spotted") + assert.Equal(t, errors.New("missing or empty userOCID field from metadata"), err, "Lacking configuration property should be spotted") }) t.Run("Init with missing compartmentOCID", func(t *testing.T) { meta.Properties = getDummyOCIObjectStorageConfiguration() meta.Properties[compartmentKey] = "" err := statestore.Init(context.Background(), meta) require.Error(t, err) - assert.Equal(t, fmt.Errorf("missing or empty compartmentOCID field from metadata"), err, "Lacking configuration property should be spotted") + assert.Equal(t, errors.New("missing or empty compartmentOCID field from metadata"), err, "Lacking configuration property should be spotted") }) t.Run("Init with missing fingerprint", func(t *testing.T) { meta.Properties = getDummyOCIObjectStorageConfiguration() meta.Properties[fingerPrintKey] = "" err := statestore.Init(context.Background(), meta) require.Error(t, err) - assert.Equal(t, fmt.Errorf("missing or empty fingerPrint field from metadata"), err, "Lacking configuration property should be spotted") + assert.Equal(t, errors.New("missing or empty fingerPrint field from metadata"), err, "Lacking configuration property should be spotted") }) t.Run("Init with missing private key", func(t *testing.T) { meta.Properties = getDummyOCIObjectStorageConfiguration() meta.Properties[privateKeyKey] = "" err := statestore.Init(context.Background(), meta) require.Error(t, err) - assert.Equal(t, fmt.Errorf("missing or empty privateKey field from metadata"), err, "Lacking configuration property should be spotted") + assert.Equal(t, errors.New("missing or empty privateKey field from metadata"), err, "Lacking configuration property should be spotted") }) t.Run("Init with incorrect value for instancePrincipalAuthentication", func(t *testing.T) { meta.Properties = getDummyOCIObjectStorageConfiguration() @@ -202,10 +202,10 @@ func (c *mockedObjectStoreClient) getObject(ctx context.Context, objectname stri func (c *mockedObjectStoreClient) deleteObject(ctx context.Context, objectname string, etag *string) (err error) { c.deleteIsCalled = true if objectname == "unknownKey" { - return fmt.Errorf("failed to delete object that does not exist - HTTP status code 404") + return errors.New("failed to delete object that does not exist - HTTP status code 404") } if etag != nil && *etag == "notTheCorrectETag" { - return fmt.Errorf("failed to delete object because of incorrect etag-value ") + return errors.New("failed to delete object because of incorrect etag-value ") } return nil } @@ -213,7 +213,7 @@ func (c *mockedObjectStoreClient) deleteObject(ctx context.Context, objectname s func (c *mockedObjectStoreClient) putObject(ctx context.Context, objectname string, contentLen int64, content io.ReadCloser, metadata map[string]string, etag *string) error { c.putIsCalled = true if etag != nil && *etag == "notTheCorrectETag" { - return fmt.Errorf("failed to delete object because of incorrect etag-value ") + return errors.New("failed to delete object because of incorrect etag-value ") } if etag != nil && *etag == "correctETag" { return nil @@ -290,7 +290,7 @@ func TestSetWithMockClient(t *testing.T) { statestore.client = mockClient t.Run("Set without a key", func(t *testing.T) { err := statestore.Set(context.Background(), &state.SetRequest{Value: []byte("test-value")}) - assert.Equal(t, err, fmt.Errorf("key for value to set was missing from request"), "Lacking Key results in error") + assert.Equal(t, err, errors.New("key for value to set was missing from request"), "Lacking Key results in error") }) t.Run("Regular Set Operation", func(t *testing.T) { testKey := "test-key" @@ -349,7 +349,7 @@ func TestDeleteWithMockClient(t *testing.T) { s.client = mockClient t.Run("Delete without a key", func(t *testing.T) { err := s.Delete(context.Background(), &state.DeleteRequest{}) - assert.Equal(t, err, fmt.Errorf("key for value to delete was missing from request"), "Lacking Key results in error") + assert.Equal(t, err, errors.New("key for value to delete was missing from request"), "Lacking Key results in error") }) t.Run("Delete with an unknown key", func(t *testing.T) { err := s.Delete(context.Background(), &state.DeleteRequest{Key: "unknownKey"}) diff --git a/state/oracledatabase/oracledatabase_integration_test.go b/state/oracledatabase/oracledatabase_integration_test.go index 27dd4d6769..aef87e6ef7 100644 --- a/state/oracledatabase/oracledatabase_integration_test.go +++ b/state/oracledatabase/oracledatabase_integration_test.go @@ -199,7 +199,7 @@ func testCreateTable(t *testing.T, dba *oracleDatabaseAccess) { } func dropTable(t *testing.T, db *sql.DB, tableName string) { - _, err := db.Exec(fmt.Sprintf("DROP TABLE %s", tableName)) + _, err := db.Exec("DROP TABLE " + tableName) require.NoError(t, err) } @@ -213,9 +213,9 @@ func deleteItemThatDoesNotExist(t *testing.T, ods state.Store) { } func multiWithSetOnly(t *testing.T, ods state.Store) { - var operations []state.TransactionalStateOperation - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), @@ -238,9 +238,9 @@ func multiWithSetOnly(t *testing.T, ods state.Store) { } func multiWithDeleteOnly(t *testing.T, ods state.Store) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database. @@ -265,9 +265,9 @@ func multiWithDeleteOnly(t *testing.T, ods state.Store) { } func multiWithDeleteAndSet(t *testing.T, ods state.Store) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database. @@ -281,8 +281,8 @@ func multiWithDeleteAndSet(t *testing.T, ods state.Store) { } // Create the set requests. - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), diff --git a/state/postgresql/v1/postgresql_integration_test.go b/state/postgresql/v1/postgresql_integration_test.go index e69dbef081..31fb148005 100644 --- a/state/postgresql/v1/postgresql_integration_test.go +++ b/state/postgresql/v1/postgresql_integration_test.go @@ -170,9 +170,9 @@ func deleteItemThatDoesNotExist(t *testing.T, pgs *postgresql.PostgreSQL) { } func multiWithSetOnly(t *testing.T, pgs *postgresql.PostgreSQL) { - var operations []state.TransactionalStateOperation - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), @@ -193,9 +193,9 @@ func multiWithSetOnly(t *testing.T, pgs *postgresql.PostgreSQL) { } func multiWithDeleteOnly(t *testing.T, pgs *postgresql.PostgreSQL) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database @@ -219,9 +219,9 @@ func multiWithDeleteOnly(t *testing.T, pgs *postgresql.PostgreSQL) { } func multiWithDeleteAndSet(t *testing.T, pgs *postgresql.PostgreSQL) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database @@ -235,8 +235,8 @@ func multiWithDeleteAndSet(t *testing.T, pgs *postgresql.PostgreSQL) { } // Create the set requests - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), diff --git a/state/postgresql/v2/postgresql_integration_test.go b/state/postgresql/v2/postgresql_integration_test.go index 1705b61848..23252d88a0 100644 --- a/state/postgresql/v2/postgresql_integration_test.go +++ b/state/postgresql/v2/postgresql_integration_test.go @@ -167,9 +167,9 @@ func deleteItemThatDoesNotExist(t *testing.T, pgs *postgresql.PostgreSQL) { } func multiWithSetOnly(t *testing.T, pgs *postgresql.PostgreSQL) { - var operations []state.TransactionalStateOperation - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), @@ -190,9 +190,9 @@ func multiWithSetOnly(t *testing.T, pgs *postgresql.PostgreSQL) { } func multiWithDeleteOnly(t *testing.T, pgs *postgresql.PostgreSQL) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database @@ -216,9 +216,9 @@ func multiWithDeleteOnly(t *testing.T, pgs *postgresql.PostgreSQL) { } func multiWithDeleteAndSet(t *testing.T, pgs *postgresql.PostgreSQL) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database @@ -232,8 +232,8 @@ func multiWithDeleteAndSet(t *testing.T, pgs *postgresql.PostgreSQL) { } // Create the set requests - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), diff --git a/state/query/filter.go b/state/query/filter.go index 2b0e64f8cb..9b10b20f9c 100644 --- a/state/query/filter.go +++ b/state/query/filter.go @@ -14,6 +14,7 @@ limitations under the License. package query import ( + "errors" "fmt" ) @@ -25,10 +26,10 @@ type Filter interface { func ParseFilter(obj interface{}) (Filter, error) { m, ok := obj.(map[string]interface{}) if !ok { - return nil, fmt.Errorf("filter unit must be a map") + return nil, errors.New("filter unit must be a map") } if len(m) != 1 { - return nil, fmt.Errorf("filter unit must have a single element") + return nil, errors.New("filter unit must have a single element") } for k, v := range m { switch k { @@ -93,10 +94,10 @@ type EQ struct { func (f *EQ) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("EQ filter must be a map") + return errors.New("EQ filter must be a map") } if len(m) != 1 { - return fmt.Errorf("EQ filter must contain a single key/value pair") + return errors.New("EQ filter must contain a single key/value pair") } for k, v := range m { f.Key = k @@ -114,10 +115,10 @@ type NEQ struct { func (f *NEQ) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("NEQ filter must be a map") + return errors.New("NEQ filter must be a map") } if len(m) != 1 { - return fmt.Errorf("NEQ filter must contain a single key/value pair") + return errors.New("NEQ filter must contain a single key/value pair") } for k, v := range m { f.Key = k @@ -135,10 +136,10 @@ type GT struct { func (f *GT) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("GT filter must be a map") + return errors.New("GT filter must be a map") } if len(m) != 1 { - return fmt.Errorf("GT filter must contain a single key/value pair") + return errors.New("GT filter must contain a single key/value pair") } for k, v := range m { f.Key = k @@ -156,10 +157,10 @@ type GTE struct { func (f *GTE) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("GTE filter must be a map") + return errors.New("GTE filter must be a map") } if len(m) != 1 { - return fmt.Errorf("GTE filter must contain a single key/value pair") + return errors.New("GTE filter must contain a single key/value pair") } for k, v := range m { f.Key = k @@ -177,10 +178,10 @@ type LT struct { func (f *LT) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("LT filter must be a map") + return errors.New("LT filter must be a map") } if len(m) != 1 { - return fmt.Errorf("LT filter must contain a single key/value pair") + return errors.New("LT filter must contain a single key/value pair") } for k, v := range m { f.Key = k @@ -198,10 +199,10 @@ type LTE struct { func (f *LTE) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("LTE filter must be a map") + return errors.New("LTE filter must be a map") } if len(m) != 1 { - return fmt.Errorf("LTE filter must contain a single key/value pair") + return errors.New("LTE filter must contain a single key/value pair") } for k, v := range m { f.Key = k @@ -219,15 +220,15 @@ type IN struct { func (f *IN) Parse(obj interface{}) error { m, ok := obj.(map[string]interface{}) if !ok { - return fmt.Errorf("IN filter must be a map") + return errors.New("IN filter must be a map") } if len(m) != 1 { - return fmt.Errorf("IN filter must contain a single key/value pair") + return errors.New("IN filter must contain a single key/value pair") } for k, v := range m { f.Key = k if f.Vals, ok = v.([]interface{}); !ok { - return fmt.Errorf("IN filter value must be an array") + return errors.New("IN filter value must be an array") } } diff --git a/state/redis/redis.go b/state/redis/redis.go index 318e4ea129..79249a81ea 100644 --- a/state/redis/redis.go +++ b/state/redis/redis.go @@ -281,7 +281,7 @@ func (r *StateStore) getJSON(ctx context.Context, req *state.GetRequest) (*state str, ok := res.(string) if !ok { - return nil, fmt.Errorf("invalid result") + return nil, errors.New("invalid result") } var entry jsonEntry @@ -481,7 +481,7 @@ func (r *StateStore) getKeyVersion(vals []interface{}) (data string, version *st } } if !seenData || !seenVersion { - return "", nil, fmt.Errorf("required hash field 'data' or 'version' was not found") + return "", nil, errors.New("required hash field 'data' or 'version' was not found") } return data, version, nil diff --git a/state/redis/redis_query.go b/state/redis/redis_query.go index 7647cb9ed0..d54c0f8adb 100644 --- a/state/redis/redis_query.go +++ b/state/redis/redis_query.go @@ -168,7 +168,7 @@ func (q *Query) VisitIN(f *query.IN) (string, error) { return "", err } vals := make([]string, n) - for i := 0; i < n; i++ { + for i := range n { vals[i] = f.Vals[i].(string) } str := fmt.Sprintf("@%s:(%s)", alias, strings.Join(vals, "|")) @@ -179,7 +179,7 @@ func (q *Query) VisitIN(f *query.IN) (string, error) { or := &query.OR{ Filters: make([]query.Filter, n), } - for i := 0; i < n; i++ { + for i := range n { or.Filters[i] = &query.EQ{ Key: f.Key, Val: f.Vals[i], @@ -335,19 +335,19 @@ func parseQueryResponsePost28(ret any) ([]state.QueryItem, bool, error) { return nil, false, nil } - var res []state.QueryItem + var res []state.QueryItem //nolint:prealloc arr := aarr["results"].([]any) if len(arr) == 0 { return nil, false, errors.New("invalid output") } - for i := 0; i < len(arr); i++ { + for i := range len(arr) { inner, ok := arr[i].(map[any]any) if !ok { - return nil, false, fmt.Errorf("invalid output") + return nil, false, errors.New("invalid output") } exattr, ok := inner["extra_attributes"].(map[any]any) if !ok { - return nil, false, fmt.Errorf("invalid output") + return nil, false, errors.New("invalid output") } item := state.QueryItem{ Key: inner["id"].(string), @@ -380,7 +380,7 @@ func parseQueryResponsePre28(ret any) ([]state.QueryItem, error) { // arr[2n+1][2] = "$.version" // arr[2n+1][3] = etag if len(arr)%2 != 1 { - return nil, fmt.Errorf("invalid output") + return nil, errors.New("invalid output") } var res []state.QueryItem diff --git a/state/redis/redis_query_schema.go b/state/redis/redis_query_schema.go index aec60f054b..56075a1cc3 100644 --- a/state/redis/redis_query_schema.go +++ b/state/redis/redis_query_schema.go @@ -15,6 +15,7 @@ package redis import ( "encoding/json" + "errors" "fmt" ) @@ -48,7 +49,7 @@ func parseQuerySchemas(content string) (querySchemas, error) { ret := querySchemas{} for _, schema := range schemas { if len(schema.Name) == 0 { - return nil, fmt.Errorf("empty query schema name") + return nil, errors.New("empty query schema name") } if _, ok := ret[schema.Name]; ok { return nil, fmt.Errorf("duplicate schema name %s", schema.Name) @@ -63,7 +64,7 @@ func parseQuerySchemas(content string) (querySchemas, error) { } alias := fmt.Sprintf("var%d", id) elem.keys[indx.Key] = alias - elem.schema = append(elem.schema, fmt.Sprintf("$.data.%s", indx.Key), "AS", alias, indx.Type, "SORTABLE") + elem.schema = append(elem.schema, "$.data."+indx.Key, "AS", alias, indx.Type, "SORTABLE") } ret[schema.Name] = elem } diff --git a/state/requests.go b/state/requests.go index 22dbe226df..af2c566a6f 100644 --- a/state/requests.go +++ b/state/requests.go @@ -14,7 +14,7 @@ limitations under the License. package state import ( - "fmt" + "errors" "strings" "github.com/dapr/components-contrib/state/query" @@ -77,7 +77,7 @@ type DeleteWithPrefixRequest struct { func (r *DeleteWithPrefixRequest) Validate() error { if r.Prefix == "" || r.Prefix == "||" { - return fmt.Errorf("a prefix is required for deleteWithPrefix request") + return errors.New("a prefix is required for deleteWithPrefix request") } if !strings.HasSuffix(r.Prefix, "||") { r.Prefix += "||" diff --git a/state/rethinkdb/rethinkdb_test.go b/state/rethinkdb/rethinkdb_test.go index 088878d0dc..329b1fbfcf 100644 --- a/state/rethinkdb/rethinkdb_test.go +++ b/state/rethinkdb/rethinkdb_test.go @@ -167,7 +167,7 @@ func TestRethinkDBStateStoreRongRun(t *testing.T) { } defer require.NoError(t, db.Close()) - for i := 0; i < 1000; i++ { + for i := range 1000 { testBulk(t, db, i) } } diff --git a/state/sqlite/sqlite_dbaccess.go b/state/sqlite/sqlite_dbaccess.go index cb40627ac3..9f58d192f0 100644 --- a/state/sqlite/sqlite_dbaccess.go +++ b/state/sqlite/sqlite_dbaccess.go @@ -479,7 +479,7 @@ func (a *sqliteDBAccess) doDelete(parentCtx context.Context, db querier, req *st } if req.Key == "" { - return fmt.Errorf("missing key in delete operation") + return errors.New("missing key in delete operation") } ctx, cancel := context.WithTimeout(parentCtx, a.metadata.Timeout) diff --git a/state/sqlite/sqlite_integration_test.go b/state/sqlite/sqlite_integration_test.go index 837aadcaa2..81e78fcee5 100644 --- a/state/sqlite/sqlite_integration_test.go +++ b/state/sqlite/sqlite_integration_test.go @@ -192,9 +192,9 @@ func deleteItemThatDoesNotExist(t *testing.T, s state.Store) { } func multiWithSetOnly(t *testing.T, s state.Store) { - var operations []state.TransactionalStateOperation - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), @@ -215,9 +215,9 @@ func multiWithSetOnly(t *testing.T, s state.Store) { } func multiWithDeleteOnly(t *testing.T, s state.Store) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database. @@ -241,9 +241,9 @@ func multiWithDeleteOnly(t *testing.T, s state.Store) { } func multiWithDeleteAndSet(t *testing.T, s state.Store) { - var operations []state.TransactionalStateOperation - var deleteRequests []state.DeleteRequest - for i := 0; i < 3; i++ { + var operations []state.TransactionalStateOperation //nolint:prealloc + var deleteRequests []state.DeleteRequest //nolint:prealloc + for range 3 { req := state.DeleteRequest{Key: randomKey()} // Add the item to the database. @@ -257,8 +257,8 @@ func multiWithDeleteAndSet(t *testing.T, s state.Store) { } // Create the set requests. - var setRequests []state.SetRequest - for i := 0; i < 3; i++ { + var setRequests []state.SetRequest //nolint:prealloc + for range 3 { req := state.SetRequest{ Key: randomKey(), Value: randomJSON(), diff --git a/state/sqlserver/metadata.go b/state/sqlserver/metadata.go index 98efdb63fc..eeb2fdda4c 100644 --- a/state/sqlserver/metadata.go +++ b/state/sqlserver/metadata.go @@ -77,10 +77,10 @@ func (m *sqlServerMetadata) Parse(meta map[string]string) error { // Validate and sanitize more values if !sqlserverAuth.IsValidSQLName(m.TableName) { - return fmt.Errorf("invalid table name, accepted characters are (A-Z, a-z, 0-9, _)") + return errors.New("invalid table name, accepted characters are (A-Z, a-z, 0-9, _)") } if !sqlserverAuth.IsValidSQLName(m.MetadataTableName) { - return fmt.Errorf("invalid metadata table name, accepted characters are (A-Z, a-z, 0-9, _)") + return errors.New("invalid metadata table name, accepted characters are (A-Z, a-z, 0-9, _)") } err = m.setKeyType() @@ -174,15 +174,15 @@ func (m *sqlServerMetadata) validateIndexedProperties(indexedProperties []Indexe } if !sqlserverAuth.IsValidSQLName(p.ColumnName) { - return fmt.Errorf("invalid indexed property column name, accepted characters are (A-Z, a-z, 0-9, _)") + return errors.New("invalid indexed property column name, accepted characters are (A-Z, a-z, 0-9, _)") } if !isValidIndexedPropertyName(p.Property) { - return fmt.Errorf("invalid indexed property name, accepted characters are (A-Z, a-z, 0-9, _, ., [, ])") + return errors.New("invalid indexed property name, accepted characters are (A-Z, a-z, 0-9, _, ., [, ])") } if !isValidIndexedPropertyType(p.Type) { - return fmt.Errorf("invalid indexed property type, accepted characters are (A-Z, a-z, 0-9, _, (, ))") + return errors.New("invalid indexed property type, accepted characters are (A-Z, a-z, 0-9, _, (, ))") } } diff --git a/state/sqlserver/migration.go b/state/sqlserver/migration.go index 3f60ca3578..38e14d0e1a 100644 --- a/state/sqlserver/migration.go +++ b/state/sqlserver/migration.go @@ -46,7 +46,7 @@ func newMigration(metadata *sqlServerMetadata) migrator { func (m *migration) newMigrationResult() migrationResult { r := migrationResult{ itemRefTableTypeName: fmt.Sprintf("[%s].%s_Table", m.metadata.SchemaName, m.metadata.TableName), - upsertProcName: fmt.Sprintf("sp_Upsert_v5_%s", m.metadata.TableName), + upsertProcName: "sp_Upsert_v5_" + m.metadata.TableName, getCommand: fmt.Sprintf("SELECT [Data], [RowVersion], [ExpireDate] FROM [%s].[%s] WHERE [Key] = @Key AND ([ExpireDate] IS NULL OR [ExpireDate] > GETDATE())", m.metadata.SchemaName, m.metadata.TableName), deleteWithETagCommand: fmt.Sprintf(`DELETE [%s].[%s] WHERE [Key]=@Key AND [RowVersion]=@RowVersion`, m.metadata.SchemaName, m.metadata.TableName), deleteWithoutETagCommand: fmt.Sprintf(`DELETE [%s].[%s] WHERE [Key]=@Key`, m.metadata.SchemaName, m.metadata.TableName), diff --git a/state/sqlserver/sqlserver_integration_test.go b/state/sqlserver/sqlserver_integration_test.go index 44becc0bf8..a4671ad744 100644 --- a/state/sqlserver/sqlserver_integration_test.go +++ b/state/sqlserver/sqlserver_integration_test.go @@ -81,7 +81,7 @@ func TestIntegrationCases(t *testing.T) { // Run concurrent set tests 10 times const executions = 10 - for i := 0; i < executions; i++ { + for i := range executions { t.Run(fmt.Sprintf("Concurrent sets, try #%d", i+1), testConcurrentSets) } } @@ -90,7 +90,7 @@ func getUniqueDBSchema(t *testing.T) string { b := make([]byte, 4) _, err := io.ReadFull(rand.Reader, b) require.NoError(t, err) - return fmt.Sprintf("v%s", hex.EncodeToString(b)) + return "v" + hex.EncodeToString(b) } func createMetadata(schema string, kt KeyType, indexedProperties string) state.Metadata { @@ -548,7 +548,7 @@ func testConcurrentSets(t *testing.T) { start := make(chan bool, parallelism) totalErrors := int32(0) totalSucceeds := int32(0) - for i := 0; i < parallelism; i++ { + for range parallelism { wc.Add(1) go func(id, etag string, start <-chan bool, wc *sync.WaitGroup, store *SQLServer) { <-start diff --git a/tests/conformance/pubsub/pubsub.go b/tests/conformance/pubsub/pubsub.go index 55f54ed968..84fb7cdf90 100644 --- a/tests/conformance/pubsub/pubsub.go +++ b/tests/conformance/pubsub/pubsub.go @@ -508,7 +508,7 @@ func ConformanceTests(t *testing.T, props map[string]string, ps pubsub.PubSub, c close(allSentCh) }() - for i := 0; i < 3; i++ { + for i := range 3 { t.Logf("Starting iteration %d", i) switch i { case 1: // On iteration 1, close the first subscriber diff --git a/tests/conformance/state/state.go b/tests/conformance/state/state.go index ef9dd51828..25de650cf9 100644 --- a/tests/conformance/state/state.go +++ b/tests/conformance/state/state.go @@ -101,139 +101,139 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St scenarios := []scenario{ { - key: fmt.Sprintf("%s-int", key), + key: key + "-int", value: 123, }, { - key: fmt.Sprintf("%s-bool", key), + key: key + "-bool", value: true, }, { - key: fmt.Sprintf("%s-bytes", key), + key: key + "-bytes", value: []byte{0x1}, }, { - key: fmt.Sprintf("%s-string-with-json", key), + key: key + "-string-with-json", value: `{"a":"b"}`, }, { - key: fmt.Sprintf("%s-string", key), + key: key + "-string", value: "hello world", }, { - key: fmt.Sprintf("%s-empty-string", key), + key: key + "-empty-string", value: "", }, { - key: fmt.Sprintf("%s-struct", key), - value: ValueType{Message: fmt.Sprintf("test%s", key)}, + key: key + "-struct", + value: ValueType{Message: "test" + key}, contentType: contenttype.JSONContentType, }, { - key: fmt.Sprintf("%s-struct-operations", key), + key: key + "-struct-operations", value: StructType{Product: struct { Value int `json:"value"` - }{Value: 15}, Status: "ACTIVE", Message: fmt.Sprintf("%smessage", key)}, + }{Value: 15}, Status: "ACTIVE", Message: key + "message"}, contentType: contenttype.JSONContentType, }, { - key: fmt.Sprintf("%s-struct-operations-inactive", key), + key: key + "-struct-operations-inactive", value: StructType{Product: struct { Value int `json:"value"` - }{Value: 12}, Status: "INACTIVE", Message: fmt.Sprintf("%smessage", key)}, + }{Value: 12}, Status: "INACTIVE", Message: key + "message"}, contentType: contenttype.JSONContentType, }, { - key: fmt.Sprintf("%s-struct-2", key), - value: ValueType{Message: fmt.Sprintf("%stest", key)}, + key: key + "-struct-2", + value: ValueType{Message: key + "test"}, contentType: contenttype.JSONContentType, }, { - key: fmt.Sprintf("%s-struct-with-int", key), + key: key + "-struct-with-int", value: intValueType{Message: 42}, contentType: contenttype.JSONContentType, }, { - key: fmt.Sprintf("%s-to-be-deleted", key), + key: key + "-to-be-deleted", value: "to be deleted", toBeDeleted: true, }, { - key: fmt.Sprintf("%s-bulk-int", key), + key: key + "-bulk-int", value: 123, bulkOnly: true, }, { - key: fmt.Sprintf("%s-bulk-bool", key), + key: key + "-bulk-bool", value: true, bulkOnly: true, }, { - key: fmt.Sprintf("%s-bulk-bytes", key), + key: key + "-bulk-bytes", value: []byte{0x1}, bulkOnly: true, }, { - key: fmt.Sprintf("%s-bulk-string", key), + key: key + "-bulk-string", value: "hello world", bulkOnly: true, }, { - key: fmt.Sprintf("%s-bulk-struct", key), + key: key + "-bulk-struct", value: ValueType{Message: "test"}, bulkOnly: true, }, { - key: fmt.Sprintf("%s-bulk-to-be-deleted", key), + key: key + "-bulk-to-be-deleted", value: "to be deleted", toBeDeleted: true, bulkOnly: true, }, { - key: fmt.Sprintf("%s-bulk-to-be-deleted-too", key), + key: key + "-bulk-to-be-deleted-too", value: "to be deleted too", toBeDeleted: true, bulkOnly: true, }, { - key: fmt.Sprintf("%s-trx-int", key), + key: key + "-trx-int", value: 123, transactionOnly: true, transactionGroup: 1, }, { - key: fmt.Sprintf("%s-trx-bool", key), + key: key + "-trx-bool", value: true, transactionOnly: true, transactionGroup: 1, }, { - key: fmt.Sprintf("%s-trx-bytes", key), + key: key + "-trx-bytes", value: []byte{0x1}, transactionOnly: true, transactionGroup: 1, }, { - key: fmt.Sprintf("%s-trx-string", key), + key: key + "-trx-string", value: "hello world", transactionOnly: true, transactionGroup: 1, }, { - key: fmt.Sprintf("%s-trx-struct", key), + key: key + "-trx-struct", value: ValueType{Message: "test"}, transactionOnly: true, transactionGroup: 2, }, { - key: fmt.Sprintf("%s-trx-to-be-deleted", key), + key: key + "-trx-to-be-deleted", value: "to be deleted", toBeDeleted: true, transactionOnly: true, transactionGroup: 1, }, { - key: fmt.Sprintf("%s-trx-to-be-deleted-too", key), + key: key + "-trx-to-be-deleted-too", value: "to be deleted too", toBeDeleted: true, transactionOnly: true, @@ -259,7 +259,7 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St `, results: []state.QueryItem{ { - Key: fmt.Sprintf("%s-struct", key), + Key: key + "-struct", Data: []byte(fmt.Sprintf(`{"message":"test%s"}`, key)), }, }, @@ -287,7 +287,7 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St `, results: []state.QueryItem{ { - Key: fmt.Sprintf("%s-struct-operations", key), + Key: key + "-struct-operations", Data: []byte(fmt.Sprintf(`{"product":{"value":15}, "status":"ACTIVE","message":"%smessage"}`, key)), }, }, @@ -329,7 +329,7 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St `, results: []state.QueryItem{ { - Key: fmt.Sprintf("%s-struct-operations-inactive", key), + Key: key + "-struct-operations-inactive", Data: []byte(fmt.Sprintf(`{"product":{"value":12}, "status":"INACTIVE","message":"%smessage"}`, key)), }, }, @@ -354,11 +354,11 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St // Return 2 item from 2 different partitionKey (-struct and -struct-2), for default the partitionKey is equals to key results: []state.QueryItem{ { - Key: fmt.Sprintf("%s-struct", key), + Key: key + "-struct", Data: []byte(fmt.Sprintf(`{"message":"test%s"}`, key)), }, { - Key: fmt.Sprintf("%s-struct-2", key), + Key: key + "-struct-2", Data: []byte(fmt.Sprintf(`{"message":"%stest"}`, key)), }, }, @@ -381,13 +381,13 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St } `, metadata: map[string]string{ - "partitionKey": fmt.Sprintf("%s-struct-2", key), + "partitionKey": key + "-struct-2", }, partitionOnly: true, // The same query from previous test but return only item having the same partitionKey value (%s-struct-2) given in the metadata results: []state.QueryItem{ { - Key: fmt.Sprintf("%s-struct-2", key), + Key: key + "-struct-2", Data: []byte(fmt.Sprintf(`{"message":"%stest"}`, key)), }, }, @@ -841,7 +841,7 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St }, state.BulkGetOpts{}) require.NoError(t, err) require.Len(t, bulkRes, 3) - for i := 0; i < 3; i++ { + for i := range 3 { require.NotNil(t, bulkRes[i].ETag) require.NotEmpty(t, *bulkRes[i].ETag) assertDataEquals(t, firstValue, bulkRes[i].Data) @@ -931,7 +931,7 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St }, state.BulkGetOpts{}) require.NoError(t, err) require.Len(t, bulkRes, 2) - for i := 0; i < 2; i++ { + for i := range 2 { require.NotNil(t, bulkRes[i].ETag) require.NotEmpty(t, *bulkRes[i].ETag) assertDataEquals(t, thirdValue, bulkRes[i].Data) @@ -1015,7 +1015,7 @@ func ConformanceTests(t *testing.T, props map[string]string, statestore state.St require.NoError(t, err) require.Len(t, bulkRes, 2) foundKeys := []string{} - for i := 0; i < 2; i++ { + for i := range 2 { require.Empty(t, bulkRes[i].Data) require.Empty(t, bulkRes[i].ETag) foundKeys = append(foundKeys, bulkRes[i].Key) diff --git a/tests/utils/configupdater/postgres/postgres.go b/tests/utils/configupdater/postgres/postgres.go index ba487a5cf1..ed37a66e0c 100644 --- a/tests/utils/configupdater/postgres/postgres.go +++ b/tests/utils/configupdater/postgres/postgres.go @@ -2,6 +2,7 @@ package postgres import ( "context" + "errors" "fmt" "strconv" "strings" @@ -105,7 +106,7 @@ func (r *ConfigUpdater) Init(props map[string]string) error { if tbl, ok := props["table"]; ok && tbl != "" { r.configTable = tbl } else { - return fmt.Errorf("missing postgreSQL configuration table name") + return errors.New("missing postgreSQL configuration table name") } config, err := md.GetPgxPoolConfig() @@ -134,7 +135,7 @@ func buildAddQuery(items map[string]*configuration.Item, configTable string) (st paramWildcard := make([]string, 0, len(items)) params := make([]interface{}, 0, 4*len(items)) if len(items) == 0 { - return query, params, fmt.Errorf("empty list of items") + return query, params, errors.New("empty list of items") } var queryBuilder strings.Builder queryBuilder.WriteString("INSERT INTO " + configTable + " (KEY, VALUE, VERSION, METADATA) VALUES ") @@ -164,7 +165,7 @@ func (r *ConfigUpdater) AddKey(items map[string]*configuration.Item) error { func (r *ConfigUpdater) UpdateKey(items map[string]*configuration.Item) error { if len(items) == 0 { - return fmt.Errorf("empty list of items") + return errors.New("empty list of items") } for key, item := range items { var params []interface{} @@ -180,7 +181,7 @@ func (r *ConfigUpdater) UpdateKey(items map[string]*configuration.Item) error { func (r *ConfigUpdater) DeleteKey(keys []string) error { if len(keys) == 0 { - return fmt.Errorf("empty list of items") + return errors.New("empty list of items") } for _, key := range keys { var params []interface{} From 41d902cb6c56216223a17de80972f1d1077713c0 Mon Sep 17 00:00:00 2001 From: Elena Kolevska Date: Thu, 24 Oct 2024 14:32:01 +0100 Subject: [PATCH 11/11] Applying new linter rules Signed-off-by: Elena Kolevska --- bindings/alicloud/sls/sls.go | 1 + bindings/http/http.go | 2 +- bindings/mqtt3/mqtt.go | 2 +- common/authentication/postgresql/metadata.go | 2 +- common/authentication/sqlite/metadata.go | 2 +- common/component/azure/servicebus/publisher.go | 2 +- common/component/kafka/kafka.go | 2 +- common/component/kafka/kafka_test.go | 2 +- common/component/kafka/metadata.go | 2 +- common/component/redis/redis.go | 4 ++-- common/component/redis/v8client.go | 4 ++-- common/component/redis/v9client.go | 6 +++--- common/wasm/wasm.go | 2 +- configuration/azure/appconfig/appconfig.go | 2 +- configuration/redis/redis.go | 2 +- crypto/azure/keyvault/jwk.go | 2 +- crypto/subtlecrypto.go | 2 ++ metadata/utils.go | 1 + nameresolution/consul/configuration.go | 6 +++--- nameresolution/consul/watcher.go | 2 +- nameresolution/mdns/mdns.go | 3 ++- pubsub/envelope_test.go | 2 +- pubsub/jetstream/metadata.go | 2 +- pubsub/rabbitmq/rabbitmq.go | 2 +- pubsub/redis/redis.go | 5 +++-- pubsub/rocketmq/rocketmq.go | 2 +- secretstores/local/file/filestore.go | 2 +- state/aerospike/aerospike.go | 1 + state/bulk.go | 2 +- state/memcached/memcached.go | 2 +- state/mysql/mysql.go | 2 +- state/redis/redis.go | 1 + state/redis/redis_query.go | 2 +- state/zookeeper/zk_test.go | 3 +-- 34 files changed, 44 insertions(+), 37 deletions(-) diff --git a/bindings/alicloud/sls/sls.go b/bindings/alicloud/sls/sls.go index 7c80174a09..42d7b4a55c 100644 --- a/bindings/alicloud/sls/sls.go +++ b/bindings/alicloud/sls/sls.go @@ -96,6 +96,7 @@ func (s *AliCloudSlsLogstorage) parseLog(req *bindings.InvokeRequest) (*sls.Log, if err != nil { return nil, err } + //nolint:gosec return producer.GenerateLog(uint32(time.Now().Unix()), logInfo), nil } diff --git a/bindings/http/http.go b/bindings/http/http.go index e79de5964a..6e401308cb 100644 --- a/bindings/http/http.go +++ b/bindings/http/http.go @@ -354,7 +354,7 @@ func (h *HTTPSource) Invoke(parentCtx context.Context, req *bindings.InvokeReque } // Create an error for non-200 status codes unless suppressed. - if errorIfNot2XX && resp.StatusCode/100 != 2 { //nolint:usestdlibvars + if errorIfNot2XX && resp.StatusCode/100 != 2 { err = fmt.Errorf("received status code %d", resp.StatusCode) } diff --git a/bindings/mqtt3/mqtt.go b/bindings/mqtt3/mqtt.go index df7fcaa68b..401f18e236 100644 --- a/bindings/mqtt3/mqtt.go +++ b/bindings/mqtt3/mqtt.go @@ -299,7 +299,7 @@ func (m *MQTT) handleMessage() func(client mqtt.Client, mqttMsg mqtt.Message) { return func(client mqtt.Client, mqttMsg mqtt.Message) { bo := m.backOff if m.metadata.BackOffMaxRetries >= 0 { - bo = backoff.WithMaxRetries(bo, uint64(m.metadata.BackOffMaxRetries)) + bo = backoff.WithMaxRetries(bo, uint64(m.metadata.BackOffMaxRetries)) //nolint:gosec } err := retry.NotifyRecover( diff --git a/common/authentication/postgresql/metadata.go b/common/authentication/postgresql/metadata.go index ce86ca2eee..7cacecfaa4 100644 --- a/common/authentication/postgresql/metadata.go +++ b/common/authentication/postgresql/metadata.go @@ -109,7 +109,7 @@ func (m *PostgresAuthMetadata) GetPgxPoolConfig() (*pgxpool.Config, error) { config.MaxConnIdleTime = m.ConnectionMaxIdleTime } if m.MaxConns > 1 { - config.MaxConns = int32(m.MaxConns) + config.MaxConns = int32(m.MaxConns) //nolint:gosec } if m.QueryExecMode != "" { diff --git a/common/authentication/sqlite/metadata.go b/common/authentication/sqlite/metadata.go index f182750d12..e0a4a436a5 100644 --- a/common/authentication/sqlite/metadata.go +++ b/common/authentication/sqlite/metadata.go @@ -190,7 +190,7 @@ func ValidIdentifier(v string) bool { // Loop through the string as byte slice as we only care about ASCII characters b := []byte(v) - for i := range len(b) { + for i := range b { if (b[i] >= '0' && b[i] <= '9') || (b[i] >= 'a' && b[i] <= 'z') || (b[i] >= 'A' && b[i] <= 'Z') || diff --git a/common/component/azure/servicebus/publisher.go b/common/component/azure/servicebus/publisher.go index 372cc1f1f2..26b4ac22a4 100644 --- a/common/component/azure/servicebus/publisher.go +++ b/common/component/azure/servicebus/publisher.go @@ -191,7 +191,7 @@ func (c *Client) PublishBinding(ctx context.Context, req *bindings.InvokeRequest func (c *Client) publishBackOff(ctx context.Context) (bo backoff.BackOff) { ebo := backoff.NewExponentialBackOff() ebo.InitialInterval = time.Duration(c.metadata.PublishInitialRetryIntervalInMs) * time.Millisecond - bo = backoff.WithMaxRetries(ebo, uint64(c.metadata.PublishMaxRetries)) + bo = backoff.WithMaxRetries(ebo, uint64(c.metadata.PublishMaxRetries)) //nolint:gosec bo = backoff.WithContext(bo, ctx) return bo } diff --git a/common/component/kafka/kafka.go b/common/component/kafka/kafka.go index 97e714ef4d..2f3b67be0d 100644 --- a/common/component/kafka/kafka.go +++ b/common/component/kafka/kafka.go @@ -387,7 +387,7 @@ func (k *Kafka) SerializeValue(topic string, data []byte, metadata map[string]st return nil, err } schemaIDBytes := make([]byte, 4) - binary.BigEndian.PutUint32(schemaIDBytes, uint32(schema.ID())) + binary.BigEndian.PutUint32(schemaIDBytes, uint32(schema.ID())) //nolint:gosec recordValue := make([]byte, 0, len(schemaIDBytes)+len(valueBytes)+1) recordValue = append(recordValue, byte(0)) diff --git a/common/component/kafka/kafka_test.go b/common/component/kafka/kafka_test.go index 2e9ac3fbe7..3fbe8c7a2e 100644 --- a/common/component/kafka/kafka_test.go +++ b/common/component/kafka/kafka_test.go @@ -65,7 +65,7 @@ func TestDeserializeValue(t *testing.T) { } schemaIDBytes := make([]byte, 4) - binary.BigEndian.PutUint32(schemaIDBytes, uint32(schema.ID())) + binary.BigEndian.PutUint32(schemaIDBytes, uint32(schema.ID())) //nolint:gosec valJSON, _ := json.Marshal(testValue1) codec, _ := goavro.NewCodecForStandardJSONFull(testSchema1) diff --git a/common/component/kafka/metadata.go b/common/component/kafka/metadata.go index 020d61d52b..c4d0a6bb56 100644 --- a/common/component/kafka/metadata.go +++ b/common/component/kafka/metadata.go @@ -290,7 +290,7 @@ func (k *Kafka) getKafkaMetadata(meta map[string]string) (*KafkaMetadata, error) if err != nil { return nil, fmt.Errorf("kafka error: invalid value for '%s' attribute: %w", consumeRetryInterval, err) } - m.ConsumeRetryInterval = time.Duration(intVal) * time.Millisecond + m.ConsumeRetryInterval = time.Duration(intVal) * time.Millisecond //nolint:gosec } } diff --git a/common/component/redis/redis.go b/common/component/redis/redis.go index de098891a5..818a4e6a1a 100644 --- a/common/component/redis/redis.go +++ b/common/component/redis/redis.go @@ -151,7 +151,7 @@ func ParseClientFromProperties(properties map[string]string, componentType metad if processingTimeoutMs, parseErr := strconv.ParseUint(val, 10, 64); parseErr == nil { // because of legacy reasons, we need to interpret a number as milliseconds // the library would default to seconds otherwise - settings.ProcessingTimeout = time.Duration(processingTimeoutMs) * time.Millisecond + settings.ProcessingTimeout = time.Duration(processingTimeoutMs) * time.Millisecond //nolint:gosec } // if there was an error we would try to interpret it as a duration string, which was already done in Decode() } @@ -160,7 +160,7 @@ func ParseClientFromProperties(properties map[string]string, componentType metad if redeliverIntervalMs, parseErr := strconv.ParseUint(val, 10, 64); parseErr == nil { // because of legacy reasons, we need to interpret a number as milliseconds // the library would default to seconds otherwise - settings.RedeliverInterval = time.Duration(redeliverIntervalMs) * time.Millisecond + settings.RedeliverInterval = time.Duration(redeliverIntervalMs) * time.Millisecond //nolint:gosec } // if there was an error we would try to interpret it as a duration string, which was already done in Decode() } diff --git a/common/component/redis/v8client.go b/common/component/redis/v8client.go index ffce3f56d9..16571489f5 100644 --- a/common/component/redis/v8client.go +++ b/common/component/redis/v8client.go @@ -400,7 +400,7 @@ func newV8Client(s *Settings) (RedisClient, error) { /* #nosec */ if s.EnableTLS { options.TLSConfig = &tls.Config{ - InsecureSkipVerify: s.EnableTLS, //nolint:gosec + InsecureSkipVerify: s.EnableTLS, } err := s.SetCertificate(func(cert *tls.Certificate) { options.TLSConfig.Certificates = []tls.Certificate{*cert} @@ -440,7 +440,7 @@ func newV8Client(s *Settings) (RedisClient, error) { /* #nosec */ if s.EnableTLS { options.TLSConfig = &tls.Config{ - InsecureSkipVerify: s.EnableTLS, //nolint:gosec + InsecureSkipVerify: s.EnableTLS, } err := s.SetCertificate(func(cert *tls.Certificate) { options.TLSConfig.Certificates = []tls.Certificate{*cert} diff --git a/common/component/redis/v9client.go b/common/component/redis/v9client.go index 53c65b4c1a..f1e2d318b2 100644 --- a/common/component/redis/v9client.go +++ b/common/component/redis/v9client.go @@ -348,7 +348,7 @@ func newV9FailoverClient(s *Settings) (RedisClient, error) { /* #nosec */ if s.EnableTLS { opts.TLSConfig = &tls.Config{ - InsecureSkipVerify: s.EnableTLS, //nolint:gosec + InsecureSkipVerify: s.EnableTLS, } err := s.SetCertificate(func(cert *tls.Certificate) { opts.TLSConfig.Certificates = []tls.Certificate{*cert} @@ -404,7 +404,7 @@ func newV9Client(s *Settings) (RedisClient, error) { if s.EnableTLS { /* #nosec */ options.TLSConfig = &tls.Config{ - InsecureSkipVerify: s.EnableTLS, //nolint:gosec + InsecureSkipVerify: s.EnableTLS, } err := s.SetCertificate(func(cert *tls.Certificate) { options.TLSConfig.Certificates = []tls.Certificate{*cert} @@ -444,7 +444,7 @@ func newV9Client(s *Settings) (RedisClient, error) { if s.EnableTLS { /* #nosec */ options.TLSConfig = &tls.Config{ - InsecureSkipVerify: s.EnableTLS, //nolint:gosec + InsecureSkipVerify: s.EnableTLS, } err := s.SetCertificate(func(cert *tls.Certificate) { options.TLSConfig.Certificates = []tls.Certificate{*cert} diff --git a/common/wasm/wasm.go b/common/wasm/wasm.go index f4da0d740f..de7f643073 100644 --- a/common/wasm/wasm.go +++ b/common/wasm/wasm.go @@ -141,6 +141,6 @@ func newFakeWalltime() sys.Walltime { t := time.Now().Unix() * int64(time.Second) return func() (sec int64, nsec int32) { wt := atomic.AddInt64(&t, int64(time.Millisecond)) - return wt / 1e9, int32(wt % 1e9) + return wt / 1e9, int32(wt % 1e9) //nolint:gosec } } diff --git a/configuration/azure/appconfig/appconfig.go b/configuration/azure/appconfig/appconfig.go index 580f98a43a..906a92a8a6 100644 --- a/configuration/azure/appconfig/appconfig.go +++ b/configuration/azure/appconfig/appconfig.go @@ -93,7 +93,7 @@ func (r *ConfigurationStore) Init(_ context.Context, md configuration.Metadata) ApplicationID: "dapr-" + logger.DaprVersion, }, Retry: policy.RetryOptions{ - MaxRetries: int32(r.metadata.MaxRetries), + MaxRetries: int32(r.metadata.MaxRetries), //nolint:gosec RetryDelay: r.metadata.MaxRetryDelay, MaxRetryDelay: r.metadata.MaxRetryDelay, }, diff --git a/configuration/redis/redis.go b/configuration/redis/redis.go index c6c3e43697..0ca12a971f 100644 --- a/configuration/redis/redis.go +++ b/configuration/redis/redis.go @@ -102,7 +102,7 @@ func (r *ConfigurationStore) parseConnectedSlaves(res string) int { for _, info := range infos { if strings.Contains(info, connectedSlavesReplicas) { parsedReplicas, _ := strconv.ParseUint(info[len(connectedSlavesReplicas):], 10, 32) - return int(parsedReplicas) + return int(parsedReplicas) //nolint:gosec } } diff --git a/crypto/azure/keyvault/jwk.go b/crypto/azure/keyvault/jwk.go index 8c2185c7e3..eda8325b8a 100644 --- a/crypto/azure/keyvault/jwk.go +++ b/crypto/azure/keyvault/jwk.go @@ -92,7 +92,7 @@ func (key JSONWebKey) publicRSA() (*rsa.PublicKey, error) { if len(key.E) == 0 { return nil, errors.New("property e is empty") } - res.E = int(big.NewInt(0).SetBytes(key.E).Uint64()) + res.E = int(big.NewInt(0).SetBytes(key.E).Uint64()) //nolint:gosec return res, nil } diff --git a/crypto/subtlecrypto.go b/crypto/subtlecrypto.go index 34c435e576..181e3cf6d2 100644 --- a/crypto/subtlecrypto.go +++ b/crypto/subtlecrypto.go @@ -23,6 +23,8 @@ import ( ) // SubtleCrypto offers an interface to perform low-level ("subtle") cryptographic operations with keys stored in a vault. +// +//nolint:interfacebloat type SubtleCrypto interface { metadata.ComponentWithMetadata diff --git a/metadata/utils.go b/metadata/utils.go index f1ba5b1365..6c2ddd445d 100644 --- a/metadata/utils.go +++ b/metadata/utils.go @@ -86,6 +86,7 @@ func TryGetPriority(props map[string]string) (uint8, bool, error) { return 0, false, fmt.Errorf("%s value must be a valid integer: actual is '%s'", PriorityMetadataKey, val) } + //nolint:gosec priority := uint8(intVal) if intVal < 0 { priority = 0 diff --git a/nameresolution/consul/configuration.go b/nameresolution/consul/configuration.go index 8c1de3b382..ccf4e58010 100644 --- a/nameresolution/consul/configuration.go +++ b/nameresolution/consul/configuration.go @@ -140,7 +140,7 @@ func mapChecks(config []*AgentServiceCheck) []*consul.AgentServiceCheck { mapped := []*consul.AgentServiceCheck{} - for i := range len(config) { + for i := range config { mapped = append(mapped, mapCheck(config[i])) } @@ -232,7 +232,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ mapped := []consul.Upstream{} - for i := range len(config) { + for i := range config { tmp := consul.Upstream{ DestinationType: consul.UpstreamDestType(config[i].DestinationType), DestinationNamespace: config[i].DestinationNamespace, @@ -273,7 +273,7 @@ func mapAdvancedRegistration(config *AgentServiceRegistration) *consul.AgentServ mapped := consul.AgentServiceChecks{} - for i := range len(config) { + for i := range config { mapped = append(mapped, mapCheck(config[i])) } diff --git a/nameresolution/consul/watcher.go b/nameresolution/consul/watcher.go index 050acfa5c6..bf7a38c7f2 100644 --- a/nameresolution/consul/watcher.go +++ b/nameresolution/consul/watcher.go @@ -298,7 +298,7 @@ watchLoop: // generate set of keys serviceKeys := make(map[string]any) - for i := range len(services) { + for i := range services { serviceKeys[services[i]] = nil } diff --git a/nameresolution/mdns/mdns.go b/nameresolution/mdns/mdns.go index e0ced9f620..b9e699e20b 100644 --- a/nameresolution/mdns/mdns.go +++ b/nameresolution/mdns/mdns.go @@ -113,6 +113,7 @@ func (a *addressList) next() *string { a.mu.RLock() defer a.mu.RUnlock() + //nolint:gosec l := uint32(len(a.addresses)) if l == 0 { return nil @@ -299,7 +300,7 @@ func (m *Resolver) getZeroconfResolver() (resolver *zeroconf.Resolver, err error zeroconf.SelectIPTraffic(zeroconf.IPv4), zeroconf.SelectIPTraffic(zeroconf.IPv6), } - for i := range len(opts) { + for i := range opts { resolver, err = zeroconf.NewResolver(opts[i]) if err == nil { break diff --git a/pubsub/envelope_test.go b/pubsub/envelope_test.go index ff8bab7c90..c00b268b78 100644 --- a/pubsub/envelope_test.go +++ b/pubsub/envelope_test.go @@ -376,7 +376,7 @@ func TestCreateFromCloudEventsProtobufPayload(t *testing.T) { contenttypes := []string{contribContenttype.CloudEventProtobufContentType, contribContenttype.ProtobufContentType} - for i := range len(contenttypes) { + for i := range contenttypes { envelope := NewCloudEventsEnvelope("", "", "", "", "", "", contenttypes[i], ceProtoBytes, "trace", "") diff --git a/pubsub/jetstream/metadata.go b/pubsub/jetstream/metadata.go index f78eb0592f..8969dfdde5 100644 --- a/pubsub/jetstream/metadata.go +++ b/pubsub/jetstream/metadata.go @@ -95,7 +95,7 @@ func parseMetadata(psm pubsub.Metadata) (metadata, error) { } if m.StartTime != nil { - m.internalStartTime = time.Unix(int64(*m.StartTime), 0) + m.internalStartTime = time.Unix(int64(*m.StartTime), 0) //nolint:gosec } switch m.DeliverPolicy { diff --git a/pubsub/rabbitmq/rabbitmq.go b/pubsub/rabbitmq/rabbitmq.go index d0ddd1e3c7..b696082ed5 100644 --- a/pubsub/rabbitmq/rabbitmq.go +++ b/pubsub/rabbitmq/rabbitmq.go @@ -481,7 +481,7 @@ func (r *rabbitMQ) prepareSubscription(channel rabbitMQChannelBroker, req pubsub metadataRoutingKey = val } routingKeys := strings.Split(metadataRoutingKey, ",") - for i := range len(routingKeys) { + for i := range routingKeys { routingKey := routingKeys[i] r.logger.Debugf("%s binding queue '%s' to exchange '%s' with routing key '%s'", logMessagePrefix, q.Name, req.Topic, routingKey) err = channel.QueueBind(q.Name, routingKey, req.Topic, false, nil) diff --git a/pubsub/redis/redis.go b/pubsub/redis/redis.go index 9cf61550e1..7df54777f8 100644 --- a/pubsub/redis/redis.go +++ b/pubsub/redis/redis.go @@ -84,7 +84,7 @@ func (r *redisStreams) Init(ctx context.Context, metadata pubsub.Metadata) error if _, err = r.client.PingResult(ctx); err != nil { return fmt.Errorf("redis streams: error connecting to redis at %s: %s", r.clientSettings.Host, err) } - r.queue = make(chan redisMessageWrapper, int(r.clientSettings.QueueDepth)) + r.queue = make(chan redisMessageWrapper, int(r.clientSettings.QueueDepth)) //nolint:gosec for range r.clientSettings.Concurrency { r.wg.Add(1) @@ -268,6 +268,7 @@ func (r *redisStreams) pollNewMessagesLoop(ctx context.Context, stream string, h } // Read messages + //nolint:gosec streams, err := r.client.XReadGroupResult(ctx, r.clientSettings.ConsumerID, r.clientSettings.ConsumerID, []string{stream, ">"}, int64(r.clientSettings.QueueDepth), time.Duration(r.clientSettings.ReadTimeout)) if err != nil { if !errors.Is(err, r.client.GetNilValueError()) && err != context.Canceled { @@ -323,7 +324,7 @@ func (r *redisStreams) reclaimPendingMessages(ctx context.Context, stream string r.clientSettings.ConsumerID, "-", "+", - int64(r.clientSettings.QueueDepth), + int64(r.clientSettings.QueueDepth), //nolint:gosec ) if err != nil && !errors.Is(err, r.client.GetNilValueError()) { r.logger.Errorf("error retrieving pending Redis messages: %v", err) diff --git a/pubsub/rocketmq/rocketmq.go b/pubsub/rocketmq/rocketmq.go index f02f51abe5..f235910365 100644 --- a/pubsub/rocketmq/rocketmq.go +++ b/pubsub/rocketmq/rocketmq.go @@ -219,7 +219,7 @@ func (r *rocketMQ) setUpConsumer() (mq.PushConsumer, error) { if r.metadata.PullBatchSize > 0 { opts = append(opts, mqc.WithPullBatchSize(r.metadata.PullBatchSize)) } else if r.metadata.ConsumerBatchSize > 0 { - r.metadata.PullBatchSize = int32(r.metadata.ConsumerBatchSize) + r.metadata.PullBatchSize = int32(r.metadata.ConsumerBatchSize) //nolint:gosec opts = append(opts, mqc.WithPullBatchSize(r.metadata.PullBatchSize)) r.logger.Warn("set the number of msg pulled from the broker at a time, " + "please use pullBatchSize instead of consumerBatchSize") diff --git a/secretstores/local/file/filestore.go b/secretstores/local/file/filestore.go index e52e49dbd4..27bc71cfbe 100644 --- a/secretstores/local/file/filestore.go +++ b/secretstores/local/file/filestore.go @@ -196,7 +196,7 @@ func (j *localSecretStore) visitPrimitive(context string) error { } func (j *localSecretStore) visitArray(array []interface{}) error { - for i := range len(array) { + for i := range array { j.enterContext(strconv.Itoa(i)) err := j.visitProperty(array[i]) if err != nil { diff --git a/state/aerospike/aerospike.go b/state/aerospike/aerospike.go index 27206519b6..fc1bd00cf9 100644 --- a/state/aerospike/aerospike.go +++ b/state/aerospike/aerospike.go @@ -261,6 +261,7 @@ func parseHosts(hostsMeta string) ([]*as.Host, error) { if err != nil { return nil, errInvalidHosts } + //nolint:gosec hostPorts = append(hostPorts, as.NewHost(host, int(port))) } diff --git a/state/bulk.go b/state/bulk.go index a71eca1e46..b07d57387f 100644 --- a/state/bulk.go +++ b/state/bulk.go @@ -149,7 +149,7 @@ func DoBulkSetDelete[T stateRequestConstraint](ctx context.Context, req []T, met } errs := make([]error, len(req)) - for i := range len(req) { + for i := range req { errs[i] = <-errCh } diff --git a/state/memcached/memcached.go b/state/memcached/memcached.go index 9998cc5fdf..81378439fc 100644 --- a/state/memcached/memcached.go +++ b/state/memcached/memcached.go @@ -145,7 +145,7 @@ func (m *Memcached) parseTTL(req *state.SetRequest) (*int32, error) { // If ttl is more than 30 days, convert it to unix timestamp. // https://github.com/memcached/memcached/wiki/Commands#standard-protocol if parsedInt >= 60*60*24*30 { - parsedInt = int32(m.clock.Now().Unix()) + parsedInt + parsedInt = int32(m.clock.Now().Unix()) + parsedInt //nolint:gosec } // Notice that for Dapr, -1 means "persist with no TTL". diff --git a/state/mysql/mysql.go b/state/mysql/mysql.go index 513373abe5..d963d483ac 100644 --- a/state/mysql/mysql.go +++ b/state/mysql/mysql.go @@ -829,7 +829,7 @@ func validIdentifier(v string) bool { // Loop through the string as byte slice as we only care about ASCII characters b := []byte(v) - for i := range len(b) { + for i := range b { if (b[i] >= '0' && b[i] <= '9') || (b[i] >= 'a' && b[i] <= 'z') || (b[i] >= 'A' && b[i] <= 'Z') || diff --git a/state/redis/redis.go b/state/redis/redis.go index 79249a81ea..0a87f40c5c 100644 --- a/state/redis/redis.go +++ b/state/redis/redis.go @@ -189,6 +189,7 @@ func (r *StateStore) parseConnectedSlaves(res string) int { if strings.Contains(info, connectedSlavesReplicas) { parsedReplicas, _ := strconv.ParseUint(info[len(connectedSlavesReplicas):], 10, 32) + //nolint:gosec return int(parsedReplicas) } } diff --git a/state/redis/redis_query.go b/state/redis/redis_query.go index d54c0f8adb..e6cd91dcd5 100644 --- a/state/redis/redis_query.go +++ b/state/redis/redis_query.go @@ -340,7 +340,7 @@ func parseQueryResponsePost28(ret any) ([]state.QueryItem, bool, error) { if len(arr) == 0 { return nil, false, errors.New("invalid output") } - for i := range len(arr) { + for i := range arr { inner, ok := arr[i].(map[any]any) if !ok { return nil, false, errors.New("invalid output") diff --git a/state/zookeeper/zk_test.go b/state/zookeeper/zk_test.go index ee74668929..2598a82724 100644 --- a/state/zookeeper/zk_test.go +++ b/state/zookeeper/zk_test.go @@ -15,7 +15,6 @@ package zookeeper import ( "context" - "fmt" "testing" "time" @@ -38,7 +37,7 @@ func TestNewConfig(t *testing.T) { "sessionTimeout": "5s", } cp, err := newConfig(properties) - require.NoError(t, err, fmt.Sprintf("Unexpected error: %v", err)) + require.NoError(t, err, "Unexpected error: %v", err) assert.NotNil(t, cp, "failed to respond to missing data field") assert.Equal(t, []string{ "127.0.0.1:3000", "127.0.0.1:3001", "127.0.0.1:3002",