Skip to content

Commit

Permalink
Merge branch 'main' into sftp-component
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanmusta authored Oct 4, 2024
2 parents fe4a6a8 + 9012bdc commit 8c116fc
Show file tree
Hide file tree
Showing 98 changed files with 1,047 additions and 340 deletions.
4 changes: 2 additions & 2 deletions .build-tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dapr/components-contrib/build-tools

go 1.22.5
go 1.23

require (
github.com/dapr/components-contrib v0.0.0
Expand All @@ -12,7 +12,7 @@ require (
)

require (
github.com/dapr/kit v0.13.1-0.20240402103809-0c7cfce53d9e // indirect
github.com/dapr/kit v0.13.1-0.20240909215017-3823663aa4bb // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions .build-tools/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/dapr/kit v0.13.1-0.20240402103809-0c7cfce53d9e h1:mLvqfGuppb6uhsijmwTlF5sZVtGvig+Ua5ESKF17SxA=
github.com/dapr/kit v0.13.1-0.20240402103809-0c7cfce53d9e/go.mod h1:dons8V2bF6MPR2yFdxtTa86PfaE7EJtKAOkZ9hOavBQ=
github.com/dapr/kit v0.13.1-0.20240909215017-3823663aa4bb h1:ahLO7pMmX6HAuT6/RxYWBY4AN2fXQJcYlU1msY6Kt7U=
github.com/dapr/kit v0.13.1-0.20240909215017-3823663aa4bb/go.mod h1:Hz1W2LmWfA4UX/12MdA+brsf+np6f/1dJt6C6F63cjI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ package metadataschema

import (
"fmt"
"strings"
)

// Built-in authentication profiles
var BuiltinAuthenticationProfiles map[string][]AuthenticationProfile

// ParseBuiltinAuthenticationProfile returns an AuthenticationProfile(s) from a given BuiltinAuthenticationProfile.
func ParseBuiltinAuthenticationProfile(bi BuiltinAuthenticationProfile) ([]AuthenticationProfile, error) {
func ParseBuiltinAuthenticationProfile(bi BuiltinAuthenticationProfile, componentTitle string) ([]AuthenticationProfile, error) {
profiles, ok := BuiltinAuthenticationProfiles[bi.Name]
if !ok {
return nil, fmt.Errorf("built-in authentication profile %s does not exist", bi.Name)
Expand All @@ -30,7 +31,14 @@ func ParseBuiltinAuthenticationProfile(bi BuiltinAuthenticationProfile) ([]Authe
res := make([]AuthenticationProfile, len(profiles))
for i, profile := range profiles {
res[i] = profile

res[i].Metadata = mergedMetadata(bi.Metadata, res[i].Metadata...)

// If component is PostgreSQL, filter out duplicated aws profile fields
if strings.ToLower(componentTitle) == "postgresql" && bi.Name == "aws" {
res[i].Metadata = filterOutDuplicateFields(res[i].Metadata)
}

}
return res, nil
}
Expand All @@ -45,3 +53,29 @@ func mergedMetadata(base []Metadata, add ...Metadata) []Metadata {
res = append(res, add...)
return res
}

// filterOutDuplicateFields removes specific duplicated fields from the metadata
func filterOutDuplicateFields(metadata []Metadata) []Metadata {
duplicateFields := map[string]int{
"awsRegion": 0,
"accessKey": 0,
"secretKey": 0,
}

filteredMetadata := []Metadata{}

for _, field := range metadata {
if _, exists := duplicateFields[field.Name]; !exists {
filteredMetadata = append(filteredMetadata, field)
} else {
if field.Name == "awsRegion" && duplicateFields["awsRegion"] == 0 {
filteredMetadata = append(filteredMetadata, field)
duplicateFields["awsRegion"]++
} else if field.Name != "awsRegion" {
continue
}
}
}

return filteredMetadata
}
2 changes: 1 addition & 1 deletion .build-tools/pkg/metadataschema/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (c *ComponentMetadata) IsValid() error {

// Append built-in authentication profiles
for _, profile := range c.BuiltInAuthenticationProfiles {
appendProfiles, err := ParseBuiltinAuthenticationProfile(profile)
appendProfiles, err := ParseBuiltinAuthenticationProfile(profile, c.Title)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/certification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ jobs:
set +e
gotestsum --jsonfile ${{ env.TEST_OUTPUT_FILE_PREFIX }}_certification.json \
--junitfile ${{ env.TEST_OUTPUT_FILE_PREFIX }}_certification.xml --format standard-quiet -- \
-coverprofile=cover.out -covermode=set -tags=certtests -timeout=30m -coverpkg=${{ matrix.source-pkg }}
-coverprofile=cover.out -covermode=set -tags=certtests,unit -timeout=30m -coverpkg=${{ matrix.source-pkg }}
status=$?
echo "Completed certification tests for ${{ matrix.component }} ... "
if test $status -ne 0; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/components-contrib-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
GOLANGCI_LINT_VER: "v1.59.1"
GOLANGCI_LINT_VER: "v1.61.0"
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/components-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
GOLANGCI_LINT_VER: "v1.59.1"
GOLANGCI_LINT_VER: "v1.61.0"
steps:
- name: Check out code into the Go module directory
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ verify-linter-version:
echo "[!] Yours: $(INSTALLED_LINT_VERSION)"; \
echo "[!] Theirs: $(GH_LINT_VERSION)"; \
echo "[!] Upgrade: curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin $(GH_LINT_VERSION)"; \
GOLANGCI_LINT=$(go env GOPATH)/bin/$(GOLANGCI_LINT) \
sleep 3; \
fi;

Expand Down
4 changes: 4 additions & 0 deletions bindings/alicloud/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ func (s *AliCloudOSS) GetComponentMetadata() (metadataInfo metadata.MetadataMap)
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (s *AliCloudOSS) Close() error {
return nil
}
8 changes: 8 additions & 0 deletions bindings/alicloud/sls/sls.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ func (s *AliCloudSlsLogstorage) GetComponentMetadata() (metadataInfo metadata.Me
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (s *AliCloudSlsLogstorage) Close() error {
if s.producer != nil {
return s.producer.Close(time.Second.Milliseconds() * 5)
}

return nil
}
4 changes: 4 additions & 0 deletions bindings/alicloud/tablestore/tablestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,7 @@ func (s *AliCloudTableStore) GetComponentMetadata() (metadataInfo contribMetadat
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
return
}

func (s *AliCloudTableStore) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/apns/apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,7 @@ func (a *APNS) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap)
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
return
}

func (a *APNS) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/aws/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,7 @@ func (d *DynamoDB) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (d *DynamoDB) Close() error {
return nil
}
3 changes: 1 addition & 2 deletions bindings/aws/kinesis/kinesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/kinesis"
"github.com/cenkalti/backoff/v4"
Expand Down Expand Up @@ -129,7 +128,7 @@ func (a *AWSKinesis) Init(ctx context.Context, metadata bindings.Metadata) error
if m.KinesisConsumerMode == SharedThroughput {
kclConfig := config.NewKinesisClientLibConfigWithCredential(m.ConsumerName,
m.StreamName, m.Region, m.ConsumerName,
credentials.NewStaticCredentials(m.AccessKey, m.SecretKey, ""))
client.Config.Credentials)
a.workerConfig = kclConfig
}

Expand Down
4 changes: 4 additions & 0 deletions bindings/aws/ses/ses.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ func (a *AWSSES) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMa
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
return
}

func (a *AWSSES) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/aws/sns/sns.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,7 @@ func (a *AWSSNS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (a *AWSSNS) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/azure/blobstorage/blobstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,7 @@ func (a *AzureBlobStorage) GetComponentMetadata() (metadataInfo contribMetadata.
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
return
}

func (a *AzureBlobStorage) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/azure/cosmosdb/cosmosdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,7 @@ func (c *CosmosDB) GetComponentMetadata() (metadataInfo contribMetadata.Metadata
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
return
}

func (c *CosmosDB) Close() error {
return nil
}
13 changes: 10 additions & 3 deletions bindings/azure/cosmosdbgremlinapi/cosmosdbgremlinapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
// CosmosDBGremlinAPI allows performing state operations on collections.
type CosmosDBGremlinAPI struct {
metadata *cosmosDBGremlinAPICredentials
client *gremcos.Cosmos
client gremcos.Cosmos
logger logger.Logger
}

Expand Down Expand Up @@ -77,7 +77,7 @@ func (c *CosmosDBGremlinAPI) Init(_ context.Context, metadata bindings.Metadata)
return errors.New("CosmosDBGremlinAPI Error: failed to create the Cosmos Graph DB connector")
}

c.client = &client
c.client = client

return nil
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func (c *CosmosDBGremlinAPI) Invoke(_ context.Context, req *bindings.InvokeReque
respStartTimeKey: startTime.Format(time.RFC3339Nano),
},
}
d, err := (*c.client).Execute(gq)
d, err := c.client.Execute(gq)
if err != nil {
return nil, errors.New("CosmosDBGremlinAPI Error:error excuting gremlin")
}
Expand All @@ -136,3 +136,10 @@ func (c *CosmosDBGremlinAPI) GetComponentMetadata() (metadataInfo metadata.Metad
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (c *CosmosDBGremlinAPI) Close() error {
if c.client != nil {
return c.client.Stop()
}
return nil
}
4 changes: 4 additions & 0 deletions bindings/azure/signalr/signalr.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,7 @@ func (s *SignalR) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (s *SignalR) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/dubbo/dubbo_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ func (out *DubboOutputBinding) Operations() []bindings.OperationKind {
func (out *DubboOutputBinding) GetComponentMetadata() metadata.MetadataMap {
return metadata.MetadataMap{}
}

func (out *DubboOutputBinding) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,7 @@ func (gql *GraphQL) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (gql *GraphQL) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,7 @@ func (h *HTTPSource) GetComponentMetadata() (metadataInfo metadata.MetadataMap)
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (h *HTTPSource) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/http/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 7 additions & 0 deletions bindings/huawei/obs/obs.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,10 @@ func (o *HuaweiOBS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (o *HuaweiOBS) Close() error {
if o.service != nil {
o.service.Close()
}
return nil
}
5 changes: 5 additions & 0 deletions bindings/huawei/obs/obs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type HuaweiOBSAPI interface {
GetObject(ctx context.Context, input *obs.GetObjectInput) (output *obs.GetObjectOutput, err error)
DeleteObject(ctx context.Context, input *obs.DeleteObjectInput) (output *obs.DeleteObjectOutput, err error)
ListObjects(ctx context.Context, input *obs.ListObjectsInput) (output *obs.ListObjectsOutput, err error)
Close()
}

// HuaweiOBSService is a service layer which wraps the actual OBS SDK client to provide the API functions
Expand Down Expand Up @@ -54,3 +55,7 @@ func (s *HuaweiOBSService) DeleteObject(ctx context.Context, input *obs.DeleteOb
func (s *HuaweiOBSService) ListObjects(ctx context.Context, input *obs.ListObjectsInput) (output *obs.ListObjectsOutput, err error) {
return s.client.ListObjects(input, obs.WithRequestContext(ctx))
}

func (s *HuaweiOBSService) Close() {
s.client.Close()
}
2 changes: 2 additions & 0 deletions bindings/huawei/obs/obs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func (m *MockHuaweiOBSService) ListObjects(ctx context.Context, input *obs.ListO
return m.ListObjectsFn(ctx, input)
}

func (m *MockHuaweiOBSService) Close() {}

func TestParseMetadata(t *testing.T) {
obs := NewHuaweiOBS(logger.NewLogger("test")).(*HuaweiOBS)

Expand Down
4 changes: 4 additions & 0 deletions bindings/kitex/kitex_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ func (out *kitexOutputBinding) Operations() []bindings.OperationKind {
func (out *kitexOutputBinding) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
return
}

func (out *kitexOutputBinding) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/localstorage/localstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,7 @@ func (ls *LocalStorage) GetComponentMetadata() (metadataInfo metadata.MetadataMa
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (ls *LocalStorage) Close() error {
return nil
}
2 changes: 2 additions & 0 deletions bindings/output_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package bindings
import (
"context"
"fmt"
"io"

"github.com/dapr/components-contrib/health"
"github.com/dapr/components-contrib/metadata"
Expand All @@ -28,6 +29,7 @@ type OutputBinding interface {
Init(ctx context.Context, metadata Metadata) error
Invoke(ctx context.Context, req *InvokeRequest) (*InvokeResponse, error)
Operations() []OperationKind
io.Closer
}

func PingOutBinding(ctx context.Context, outputBinding OutputBinding) error {
Expand Down
4 changes: 4 additions & 0 deletions bindings/postmark/postmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,7 @@ func (p *Postmark) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (p *Postmark) Close() error {
return nil
}
4 changes: 4 additions & 0 deletions bindings/smtp/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,7 @@ func (s *Mailer) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
return
}

func (s *Mailer) Close() error {
return nil
}
Loading

0 comments on commit 8c116fc

Please sign in to comment.