From 25656c175d4d568bbbe9a78b290129c5a990e9f9 Mon Sep 17 00:00:00 2001 From: Yash Nisar Date: Tue, 1 Aug 2023 19:28:19 -0500 Subject: [PATCH 1/3] Add metadata for dequeued message in bindings.azure.storagequeues (#3028) Signed-off-by: Yash Nisar --- bindings/azure/storagequeues/storagequeues.go | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/bindings/azure/storagequeues/storagequeues.go b/bindings/azure/storagequeues/storagequeues.go index babfb2feab..d637d16685 100644 --- a/bindings/azure/storagequeues/storagequeues.go +++ b/bindings/azure/storagequeues/storagequeues.go @@ -38,6 +38,12 @@ const ( defaultTTL = 10 * time.Minute defaultVisibilityTimeout = 30 * time.Second defaultPollingInterval = 10 * time.Second + dequeueCount = "dequeueCount" + insertionTime = "insertionTime" + expirationTime = "expirationTime" + nextVisibleTime = "nextVisibleTime" + popReceipt = "popReceipt" + messageID = "messageID" ) type consumer struct { @@ -177,9 +183,30 @@ func (d *AzureQueueHelper) Read(ctx context.Context, consumer *consumer) error { } } + metadata := make(map[string]string, 6) + + if res.Messages[0].MessageID != nil { + metadata[messageID] = *res.Messages[0].MessageID + } + if res.Messages[0].PopReceipt != nil { + metadata[popReceipt] = *res.Messages[0].PopReceipt + } + if res.Messages[0].InsertionTime != nil { + metadata[insertionTime] = res.Messages[0].InsertionTime.Format(time.RFC3339) + } + if res.Messages[0].ExpirationTime != nil { + metadata[expirationTime] = res.Messages[0].ExpirationTime.Format(time.RFC3339) + } + if res.Messages[0].TimeNextVisible != nil { + metadata[nextVisibleTime] = res.Messages[0].TimeNextVisible.Format(time.RFC3339) + } + if res.Messages[0].DequeueCount != nil { + metadata[dequeueCount] = strconv.FormatInt(*res.Messages[0].DequeueCount, 10) + } + _, err = consumer.callback(ctx, &bindings.ReadResponse{ Data: data, - Metadata: map[string]string{}, + Metadata: metadata, }) if err != nil { return err From c2dbb03069d92ee666011ed638c6fe72d6439753 Mon Sep 17 00:00:00 2001 From: Roberto Rojas Date: Wed, 2 Aug 2023 13:59:27 -0400 Subject: [PATCH 2/3] [AWS SSM Parameter SecretStore] Adds Component Metadata Schema (#2938) Signed-off-by: Roberto J Rojas Signed-off-by: Roberto Rojas --- secretstores/aws/parameterstore/metadata.yaml | 34 +++++++++++++++++++ .../aws/parameterstore/parameterstore.go | 4 +-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 secretstores/aws/parameterstore/metadata.yaml diff --git a/secretstores/aws/parameterstore/metadata.yaml b/secretstores/aws/parameterstore/metadata.yaml new file mode 100644 index 0000000000..e8b40d6441 --- /dev/null +++ b/secretstores/aws/parameterstore/metadata.yaml @@ -0,0 +1,34 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: secretstores +name: aws.parameterstore +version: v1 +status: alpha +title: "AWS SSM Parameter Store" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-secret-stores/aws-parameter-store/ +builtinAuthenticationProfiles: + - name: "aws" +metadata: + - name: region + required: true + description: | + The specific AWS region the AWS SSM Parameter Store instance is deployed in. + example: '"us-east-1"' + type: string + - name: sessionToken + required: false + sensitive: true + description: | + AWS session token to use. A session token is only required if you are using + temporary security credentials. + example: '"TOKEN"' + type: string + - name: prefix + required: false + description: | + The SSM Parameter Store prefix to be specified. If specified, it will be + used as the 'BeginsWith' as part of the 'ParameterStringFilter'. + example: '"myprefix"' + type: string \ No newline at end of file diff --git a/secretstores/aws/parameterstore/parameterstore.go b/secretstores/aws/parameterstore/parameterstore.go index fef4294f32..5a62804b01 100644 --- a/secretstores/aws/parameterstore/parameterstore.go +++ b/secretstores/aws/parameterstore/parameterstore.go @@ -42,8 +42,8 @@ func NewParameterStore(logger logger.Logger) secretstores.SecretStore { type ParameterStoreMetaData struct { Region string `json:"region"` - AccessKey string `json:"accessKey"` - SecretKey string `json:"secretKey"` + AccessKey string `json:"accessKey" mapstructure:"accessKey" mdignore:"true"` + SecretKey string `json:"secretKey" mapstructure:"secretKey" mdignore:"true"` SessionToken string `json:"sessionToken"` Prefix string `json:"prefix"` } From 60322a1f1c1c5cbadbd8f7b7e00baa9ce5c5681a Mon Sep 17 00:00:00 2001 From: Roberto Rojas Date: Wed, 2 Aug 2023 16:50:40 -0400 Subject: [PATCH 3/3] [AWS State DynamoDB] Adds Component Metadata Schema (#2906) Signed-off-by: Roberto J Rojas Signed-off-by: Roberto Rojas Co-authored-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> Co-authored-by: Artur Souza --- state/aws/dynamodb/dynamodb.go | 8 +++-- state/aws/dynamodb/metadata.yaml | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 state/aws/dynamodb/metadata.yaml diff --git a/state/aws/dynamodb/dynamodb.go b/state/aws/dynamodb/dynamodb.go index ba7c3ab96b..33592d5706 100644 --- a/state/aws/dynamodb/dynamodb.go +++ b/state/aws/dynamodb/dynamodb.go @@ -46,11 +46,13 @@ type StateStore struct { } type dynamoDBMetadata struct { + // Ignored by metadata parser because included in built-in authentication profile + AccessKey string `json:"accessKey" mapstructure:"accessKey" mdignore:"true"` + SecretKey string `json:"secretKey" mapstructure:"secretKey" mdignore:"true"` + SessionToken string `json:"sessionToken" mapstructure:"sessionToken" mdignore:"true"` + Region string `json:"region"` Endpoint string `json:"endpoint"` - AccessKey string `json:"accessKey"` - SecretKey string `json:"secretKey"` - SessionToken string `json:"sessionToken"` Table string `json:"table"` TTLAttributeName string `json:"ttlAttributeName"` PartitionKey string `json:"partitionKey"` diff --git a/state/aws/dynamodb/metadata.yaml b/state/aws/dynamodb/metadata.yaml new file mode 100644 index 0000000000..ed0c9a3fbc --- /dev/null +++ b/state/aws/dynamodb/metadata.yaml @@ -0,0 +1,59 @@ +# yaml-language-server: $schema=../../../component-metadata-schema.json +schemaVersion: v1 +type: state +name: aws.dynamodb +version: v1 +status: stable +title: "AWS DynamoDB" +urls: + - title: Reference + url: https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-dynamodb/ +capabilities: + - crud + - transactional + - etag + - ttl + - actorStateStore +builtinAuthenticationProfiles: + - name: "aws" +metadata: + - name: table + required: true + description: | + The name of the DynamoDB table to use. + example: '"Contracts"' + type: string + - name: region + required: false + description: | + The AWS region to use. Ensure that DynamoDB is available in that region. + See the `Amazon DynamoDB endpoints and quotas` documentation. + url: + title: Amazon DynamoDB endpoints and quotas + url: https://docs.aws.amazon.com/general/latest/gr/ddb.html + example: '"us-east-1"' + type: string + - name: endpoint + required: false + description: | + AWS endpoint for the component to use. Only used for local development. + The endpoint is not necessary when running against production AWS. + example: '"http://localhost:4566"' + type: string + - name: ttlAttributeName + required: false + description: | + The table attribute name which should be used for TTL. + example: '"expiresAt"' + type: string + - name: partitionKey + required: false + description: | + The table primary key or partition key attribute name. + This field is used to replace the default primary key attribute name "key". + url: + title: More details + url: https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-dynamodb/#partition-keys + example: '"ContractID"' + type: string + \ No newline at end of file