Skip to content

Commit dae3211

Browse files
elena-kolevskasicoyleartursouzayaron2antontroshin
authored
Merge 1.14 into master (#3579)
Signed-off-by: Samantha Coyle <[email protected]> Signed-off-by: Elena Kolevska <[email protected]> Signed-off-by: yaron2 <[email protected]> Signed-off-by: Artur Souza <[email protected]> Signed-off-by: Anton Troshin <[email protected]> Co-authored-by: Sam <[email protected]> Co-authored-by: Artur Souza <[email protected]> Co-authored-by: yaron2 <[email protected]> Co-authored-by: Anton Troshin <[email protected]> Co-authored-by: Bernd Verst <[email protected]>
1 parent 4ca04db commit dae3211

File tree

156 files changed

+580
-498
lines changed

Some content is hidden

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

156 files changed

+580
-498
lines changed

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ linters-settings:
261261
allow-case-traling-whitespace: true
262262
# Allow declarations (var) to be cuddled.
263263
allow-cuddle-declarations: false
264+
testifylint:
265+
disable:
266+
- float-compare
267+
- negative-positive
268+
- go-require
264269

265270
linters:
266271
fast: false
@@ -317,3 +322,5 @@ linters:
317322
- goconst
318323
- tagalign
319324
- inamedparam
325+
- canonicalheader
326+
- fatcontext

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ test:
119119
lint: verify-linter-installed verify-linter-version
120120
ifdef LINT_BASE
121121
@echo "LINT_BASE is set to "$(LINT_BASE)". Linter will only check diff."
122-
$(GOLANGCI_LINT) run --timeout=20m --new-from-rev $(shell git rev-parse $(LINT_BASE))
122+
$(GOLANGCI_LINT) run --timeout=20m --max-same-issues 0 --max-issues-per-linter 0 --new-from-rev $(shell git rev-parse $(LINT_BASE))
123123
else
124-
$(GOLANGCI_LINT) run --timeout=20m
124+
$(GOLANGCI_LINT) run --timeout=20m --max-same-issues 0 --max-issues-per-linter 0
125125
endif
126126

127127
################################################################################

bindings/alicloud/sls/sls.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sls
33
import (
44
"context"
55
"encoding/json"
6-
"fmt"
6+
"errors"
77
"reflect"
88
"time"
99

@@ -61,16 +61,16 @@ func NewAliCloudSlsLogstorage(logger logger.Logger) bindings.OutputBinding {
6161
func (s *AliCloudSlsLogstorage) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bindings.InvokeResponse, error) {
6262
// verify the metadata property
6363
if logProject := req.Metadata["project"]; logProject == "" {
64-
return nil, fmt.Errorf("SLS binding error: project property not supplied")
64+
return nil, errors.New("SLS binding error: project property not supplied")
6565
}
6666
if logstore := req.Metadata["logstore"]; logstore == "" {
67-
return nil, fmt.Errorf("SLS binding error: logstore property not supplied")
67+
return nil, errors.New("SLS binding error: logstore property not supplied")
6868
}
6969
if topic := req.Metadata["topic"]; topic == "" {
70-
return nil, fmt.Errorf("SLS binding error: topic property not supplied")
70+
return nil, errors.New("SLS binding error: topic property not supplied")
7171
}
7272
if source := req.Metadata["source"]; source == "" {
73-
return nil, fmt.Errorf("SLS binding error: source property not supplied")
73+
return nil, errors.New("SLS binding error: source property not supplied")
7474
}
7575

7676
log, err := s.parseLog(req)
@@ -96,6 +96,7 @@ func (s *AliCloudSlsLogstorage) parseLog(req *bindings.InvokeRequest) (*sls.Log,
9696
if err != nil {
9797
return nil, err
9898
}
99+
//nolint:gosec
99100
return producer.GenerateLog(uint32(time.Now().Unix()), logInfo), nil
100101
}
101102

bindings/alicloud/tablestore/tablestore.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ func (s *AliCloudTableStore) create(req *bindings.InvokeRequest, resp *bindings.
271271
}
272272

273273
_, err = s.client.PutRow(putRequest)
274-
275274
if err != nil {
276275
return err
277276
}
@@ -302,7 +301,6 @@ func (s *AliCloudTableStore) delete(req *bindings.InvokeRequest, resp *bindings.
302301
change.SetCondition(tablestore.RowExistenceExpectation_IGNORE) //nolint:nosnakecase
303302
deleteReq := &tablestore.DeleteRowRequest{DeleteRowChange: change}
304303
_, err = s.client.DeleteRow(deleteReq)
305-
306304
if err != nil {
307305
return err
308306
}

bindings/aws/kinesis/kinesis.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ func (a *AWSKinesis) registerConsumer(ctx context.Context, streamARN *string) (*
300300
ConsumerName: &a.metadata.ConsumerName,
301301
StreamARN: streamARN,
302302
})
303-
304303
if err != nil {
305304
return nil, err
306305
}

bindings/aws/s3/s3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (s *AWSS3) get(ctx context.Context, req *bindings.InvokeRequest) (*bindings
313313
if err != nil {
314314
var awsErr awserr.Error
315315
if errors.As(err, &awsErr) && awsErr.Code() == s3.ErrCodeNoSuchKey {
316-
return nil, fmt.Errorf("object not found")
316+
return nil, errors.New("object not found")
317317
}
318318
return nil, fmt.Errorf("s3 binding error: error downloading S3 object: %w", err)
319319
}
@@ -348,7 +348,7 @@ func (s *AWSS3) delete(ctx context.Context, req *bindings.InvokeRequest) (*bindi
348348
if err != nil {
349349
var awsErr awserr.Error
350350
if errors.As(err, &awsErr) && awsErr.Code() == s3.ErrCodeNoSuchKey {
351-
return nil, fmt.Errorf("object not found")
351+
return nil, errors.New("object not found")
352352
}
353353
return nil, fmt.Errorf("s3 binding error: delete operation failed: %w", err)
354354
}

bindings/aws/ses/ses.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package ses
1515

1616
import (
1717
"context"
18+
"errors"
1819
"fmt"
1920
"reflect"
2021
"strconv"
@@ -92,13 +93,13 @@ func (a *AWSSES) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bind
9293
metadata := a.metadata.mergeWithRequestMetadata(req)
9394

9495
if metadata.EmailFrom == "" {
95-
return nil, fmt.Errorf("SES binding error: emailFrom property not supplied in configuration- or request-metadata")
96+
return nil, errors.New("SES binding error: emailFrom property not supplied in configuration- or request-metadata")
9697
}
9798
if metadata.EmailTo == "" {
98-
return nil, fmt.Errorf("SES binding error: emailTo property not supplied in configuration- or request-metadata")
99+
return nil, errors.New("SES binding error: emailTo property not supplied in configuration- or request-metadata")
99100
}
100101
if metadata.Subject == "" {
101-
return nil, fmt.Errorf("SES binding error: subject property not supplied in configuration- or request-metadata")
102+
return nil, errors.New("SES binding error: subject property not supplied in configuration- or request-metadata")
102103
}
103104

104105
body, err := strconv.Unquote(string(req.Data))

bindings/azure/blobstorage/blobstorage.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ func (a *AzureBlobStorage) create(ctx context.Context, req *bindings.InvokeReque
154154

155155
blockBlobClient := a.containerClient.NewBlockBlobClient(blobName)
156156
_, err = blockBlobClient.UploadBuffer(ctx, req.Data, &uploadOptions)
157-
158157
if err != nil {
159158
return nil, fmt.Errorf("error uploading az blob: %w", err)
160159
}
@@ -192,7 +191,7 @@ func (a *AzureBlobStorage) get(ctx context.Context, req *bindings.InvokeRequest)
192191
blobDownloadResponse, err := blockBlobClient.DownloadStream(ctx, &downloadOptions)
193192
if err != nil {
194193
if bloberror.HasCode(err, bloberror.BlobNotFound) {
195-
return nil, fmt.Errorf("blob not found")
194+
return nil, errors.New("blob not found")
196195
}
197196
return nil, fmt.Errorf("error downloading az blob: %w", err)
198197
}
@@ -261,7 +260,7 @@ func (a *AzureBlobStorage) delete(ctx context.Context, req *bindings.InvokeReque
261260
_, err := blockBlobClient.Delete(ctx, &deleteOptions)
262261

263262
if bloberror.HasCode(err, bloberror.BlobNotFound) {
264-
return nil, fmt.Errorf("blob not found")
263+
return nil, errors.New("blob not found")
265264
}
266265

267266
return nil, err

bindings/azure/cosmosdb/cosmosdb.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package cosmosdb
1616
import (
1717
"context"
1818
"encoding/json"
19+
"errors"
1920
"fmt"
2021
"reflect"
2122
"strings"
@@ -158,7 +159,7 @@ func (c *CosmosDB) getPartitionKeyValue(key string, obj interface{}) (string, er
158159
}
159160
val, ok := valI.(string)
160161
if !ok {
161-
return "", fmt.Errorf("partition key is not a string")
162+
return "", errors.New("partition key is not a string")
162163
}
163164

164165
if val == "" {
@@ -172,7 +173,7 @@ func (c *CosmosDB) lookup(m map[string]interface{}, ks []string) (val interface{
172173
var ok bool
173174

174175
if len(ks) == 0 {
175-
return nil, fmt.Errorf("needs at least one key")
176+
return nil, errors.New("needs at least one key")
176177
}
177178

178179
if val, ok = m[ks[0]]; !ok {

bindings/azure/signalr/signalr.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (s *SignalR) parseMetadata(md map[string]string) (err error) {
156156
s.accessKey = connectionValue[i+1:]
157157
case "AuthType":
158158
if connectionValue[i+1:] != "aad" {
159-
return fmt.Errorf("invalid value for AuthType in the connection string; only 'aad' is supported")
159+
return errors.New("invalid value for AuthType in the connection string; only 'aad' is supported")
160160
}
161161
useAAD = true
162162
case "ClientId", "ClientSecret", "TenantId":
@@ -171,14 +171,14 @@ func (s *SignalR) parseMetadata(md map[string]string) (err error) {
171171
}
172172
}
173173
} else if len(connectionValue) != 0 {
174-
return fmt.Errorf("the connection string is invalid or malformed")
174+
return errors.New("the connection string is invalid or malformed")
175175
}
176176
}
177177

178178
// Check here because if we use a connection string, we'd have an explicit "AuthType=aad" option
179179
// We would otherwise catch this issue later, but here we can be more explicit with the error
180180
if s.accessKey == "" && !useAAD {
181-
return fmt.Errorf("missing AccessKey in the connection string")
181+
return errors.New("missing AccessKey in the connection string")
182182
}
183183
}
184184

@@ -198,7 +198,7 @@ func (s *SignalR) parseMetadata(md map[string]string) (err error) {
198198

199199
// Check for required values
200200
if s.endpoint == "" {
201-
return fmt.Errorf("missing endpoint in the metadata or connection string")
201+
return errors.New("missing endpoint in the metadata or connection string")
202202
}
203203

204204
return nil
@@ -333,7 +333,7 @@ func (s *SignalR) GetAadClientAccessToken(ctx context.Context, hub string, user
333333

334334
u := fmt.Sprintf("%s/api/hubs/%s/:generateToken?api-version=%s", s.endpoint, hub, apiVersion)
335335
if user != "" {
336-
u += fmt.Sprintf("&userId=%s", url.QueryEscape(user))
336+
u += "&userId=" + url.QueryEscape(user)
337337
}
338338

339339
body, err := s.sendRequestToSignalR(ctx, u, aadToken, nil)

0 commit comments

Comments
 (0)