[Metadata] Update validator and some other fixes (#2984)
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Co-authored-by: Bernd Verst <github@bernd.dev>
This commit is contained in:
parent
aa4d073cd5
commit
ec05809ee6
|
|
@ -0,0 +1,97 @@
|
|||
aws:
|
||||
- title: "AWS: Access Key ID and Secret Access Key"
|
||||
description: |
|
||||
Authenticate using an Access Key ID and Secret Access Key included in the metadata
|
||||
metadata:
|
||||
- name: accessKey
|
||||
description: AWS access key associated with an IAM account
|
||||
required: true
|
||||
sensitive: true
|
||||
example: '"AKIAIOSFODNN7EXAMPLE"'
|
||||
- name: secretKey
|
||||
description: The secret key associated with the access key
|
||||
required: true
|
||||
sensitive: true
|
||||
example: '"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"'
|
||||
- title: "AWS: Credentials from Environment Variables"
|
||||
description: Use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from the environment
|
||||
|
||||
azuread:
|
||||
- title: "Azure AD: Managed identity"
|
||||
description: Authenticate using Azure AD and a managed identity.
|
||||
metadata:
|
||||
- name: azureClientId
|
||||
description: |
|
||||
Client ID (application ID). Required if the service has multiple identities assigned.
|
||||
example: '"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"'
|
||||
- name: azureEnvironment
|
||||
description: |
|
||||
Optional name for the Azure environment if using a different Azure cloud
|
||||
default: AzurePublicCloud
|
||||
example: '"AzurePublicCloud"'
|
||||
allowedValues:
|
||||
- AzurePublicCloud
|
||||
- AzureChinaCloud
|
||||
- AzureUSGovernmentCloud
|
||||
- title: "Azure AD: Client credentials"
|
||||
description: |
|
||||
Authenticate using Azure AD with client credentials, also known as "service principals".
|
||||
metadata:
|
||||
- name: azureTenantId
|
||||
description: ID of the Azure AD tenant
|
||||
required: true
|
||||
example: '"cd4b2887-304c-47e1-b4d5-65447fdd542a"'
|
||||
- name: azureClientId
|
||||
description: Client ID (application ID)
|
||||
required: true
|
||||
example: '"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"'
|
||||
- name: azureClientSecret
|
||||
description: Client secret (application password)
|
||||
required: true
|
||||
sensitive: true
|
||||
example: '"Ecy3XG7zVZK3/vl/a2NSB+a1zXLa8RnMum/IgD0E"'
|
||||
- name: azureEnvironment
|
||||
description: |
|
||||
Optional name for the Azure environment if using a different Azure cloud
|
||||
default: AzurePublicCloud
|
||||
example: '"AzurePublicCloud"'
|
||||
allowedValues:
|
||||
- AzurePublicCloud
|
||||
- AzureChinaCloud
|
||||
- AzureUSGovernmentCloud
|
||||
- title: "Azure AD: Client certificate"
|
||||
description: |
|
||||
Authenticate using Azure AD with a client certificate. One of "azureCertificate" and "azureCertificateFile" is required.
|
||||
metadata:
|
||||
- name: azureTenantId
|
||||
description: ID of the Azure AD tenant
|
||||
required: true
|
||||
example: '"cd4b2887-304c-47e1-b4d5-65447fdd542a"'
|
||||
- name: azureClientId
|
||||
description: Client ID (application ID)
|
||||
required: true
|
||||
example: '"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"'
|
||||
- name: azureCertificate
|
||||
description: |
|
||||
Certificate and private key (in either a PEM file containing both the certificate and key, or in PFX/PKCS#12 format)
|
||||
sensitive: true
|
||||
example: |
|
||||
"-----BEGIN PRIVATE KEY-----\n MIIEvgI... \n -----END PRIVATE KEY-----
|
||||
\n -----BEGIN CERTIFICATE----- \n MIICoTC... \n -----END CERTIFICATE----- \n"
|
||||
- name: azureCertificateFile
|
||||
description: |
|
||||
Path to PEM or PFX/PKCS#12 file on disk, containing the certificate and private key.
|
||||
example: '"/path/to/file.pem"'
|
||||
- name: azureCertificatePassword
|
||||
description: Password for the certificate if encrypted.
|
||||
sensitive: true
|
||||
example: '"password"'
|
||||
- name: azureEnvironment
|
||||
description: |
|
||||
Optional name for the Azure environment if using a different Azure cloud
|
||||
default: AzurePublicCloud
|
||||
example: '"AzurePublicCloud"'
|
||||
allowedValues:
|
||||
- AzurePublicCloud
|
||||
- AzureChinaCloud
|
||||
- AzureUSGovernmentCloud
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"componentFolders": [
|
||||
"bindings",
|
||||
"configuration",
|
||||
"crypto",
|
||||
"lock",
|
||||
"middleware/http",
|
||||
"nameresolution",
|
||||
"pubsub",
|
||||
"secretstores",
|
||||
"state",
|
||||
"workflows"
|
||||
],
|
||||
"excludeFolders": [
|
||||
"bindings/alicloud",
|
||||
"bindings/aws",
|
||||
"bindings/azure",
|
||||
"bindings/gcp",
|
||||
"bindings/huawei",
|
||||
"bindings/rethinkdb",
|
||||
"bindings/twilio",
|
||||
"bindings/zeebe",
|
||||
"configuration/azure",
|
||||
"configuration/redis/internal",
|
||||
"crypto/azure",
|
||||
"crypto/kubernetes",
|
||||
"pubsub/aws",
|
||||
"pubsub/azure",
|
||||
"pubsub/azure/servicebus",
|
||||
"pubsub/gcp",
|
||||
"secretstores/alicloud",
|
||||
"secretstores/aws",
|
||||
"secretstores/azure",
|
||||
"secretstores/gcp",
|
||||
"secretstores/hashicorp",
|
||||
"secretstores/huaweicloud",
|
||||
"secretstores/local",
|
||||
"state/alicloud",
|
||||
"state/aws",
|
||||
"state/azure",
|
||||
"state/gcp",
|
||||
"state/hashicorp",
|
||||
"state/oci",
|
||||
"state/utils"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
componentFolders:
|
||||
- bindings
|
||||
- configuration
|
||||
- crypto
|
||||
- lock
|
||||
- middleware/http
|
||||
- nameresolution
|
||||
- pubsub
|
||||
- secretstores
|
||||
- state
|
||||
- workflows
|
||||
|
||||
excludeFolders:
|
||||
- bindings/alicloud
|
||||
- bindings/aws
|
||||
- bindings/azure
|
||||
- bindings/gcp
|
||||
- bindings/huawei
|
||||
- bindings/rethinkdb
|
||||
- bindings/twilio
|
||||
- bindings/zeebe
|
||||
- configuration/azure
|
||||
- configuration/redis/internal
|
||||
- crypto/azure
|
||||
- crypto/kubernetes
|
||||
- pubsub/aws
|
||||
- pubsub/azure
|
||||
- pubsub/azure/servicebus
|
||||
- pubsub/gcp
|
||||
- secretstores/alicloud
|
||||
- secretstores/aws
|
||||
- secretstores/azure
|
||||
- secretstores/gcp
|
||||
- secretstores/hashicorp
|
||||
- secretstores/huaweicloud
|
||||
- secretstores/local
|
||||
- state/alicloud
|
||||
- state/aws
|
||||
- state/azure
|
||||
- state/gcp
|
||||
- state/hashicorp
|
||||
- state/oci
|
||||
- state/utils
|
||||
|
|
@ -8,6 +8,7 @@ require (
|
|||
github.com/spf13/cobra v1.6.1
|
||||
github.com/xeipuuv/gojsonschema v1.2.1-0.20201027075954-b076d39a02e5
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
sigs.k8s.io/yaml v1.3.0
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,28 +15,39 @@ package main
|
|||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/dapr/components-contrib/build-tools/cmd"
|
||||
"github.com/dapr/components-contrib/build-tools/pkg/metadataschema"
|
||||
)
|
||||
|
||||
//go:embed component-folders.json
|
||||
var componentFoldersJSON []byte
|
||||
var (
|
||||
//go:embed component-folders.yaml
|
||||
componentFoldersYAML []byte
|
||||
//go:embed builtin-authentication-profiles.yaml
|
||||
builtinAuthenticationProfilesYAML []byte
|
||||
)
|
||||
|
||||
func init() {
|
||||
parsed := struct {
|
||||
ComponentFolders []string `json:"componentFolders"`
|
||||
ExcludeFolders []string `json:"excludeFolders"`
|
||||
func main() {
|
||||
// Parse component-folders.json
|
||||
parsedComponentFolders := struct {
|
||||
ComponentFolders []string `json:"componentFolders" yaml:"componentFolders"`
|
||||
ExcludeFolders []string `json:"excludeFolders" yaml:"excludeFolders"`
|
||||
}{}
|
||||
err := json.Unmarshal(componentFoldersJSON, &parsed)
|
||||
err := yaml.Unmarshal(componentFoldersYAML, &parsedComponentFolders)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cmd.ComponentFolders = parsed.ComponentFolders
|
||||
cmd.ExcludeFolders = parsed.ExcludeFolders
|
||||
}
|
||||
cmd.ComponentFolders = parsedComponentFolders.ComponentFolders
|
||||
cmd.ExcludeFolders = parsedComponentFolders.ExcludeFolders
|
||||
|
||||
// Parse builtin-authentication-profiles.yaml
|
||||
err = yaml.Unmarshal(builtinAuthenticationProfilesYAML, &metadataschema.BuiltinAuthenticationProfiles)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/dapr/kit/logger"
|
||||
mdutils "github.com/dapr/components-contrib/metadata"
|
||||
|
|
@ -17,24 +17,24 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Please provide the path to the components-contrib root as an argument")
|
||||
os.Exit(1)
|
||||
}
|
||||
basePath := os.Args[1]
|
||||
log := logger.NewLogger("metadata")
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Please provide the path to the components-contrib root as an argument")
|
||||
os.Exit(1)
|
||||
}
|
||||
basePath := os.Args[1]
|
||||
log := logger.NewLogger("metadata")
|
||||
|
||||
var (
|
||||
var (
|
||||
yamlMetadata *map[string]string
|
||||
missing map[string]string
|
||||
missing []string
|
||||
unexpected []string
|
||||
)
|
||||
missingByComponent := make(map[string]map[string]string)
|
||||
missingByComponent := make(map[string][]string)
|
||||
unexpectedByComponent := make(map[string][]string)
|
||||
|
||||
{{range $fullpkg, $val := .Pkgs}}
|
||||
instanceOf_{{index $val 0}} := {{index $val 0}}.{{index $val 1}}(log)
|
||||
metadataFor_{{index $val 0}} := instanceOf_{{index $val 0}}.GetComponentMetadata()
|
||||
metadataFor_{{index $val 0}} := instanceOf_{{index $val 0}}.(mdutils.ComponentWithMetadata).GetComponentMetadata()
|
||||
yamlMetadata = getYamlMetadata(basePath, "{{$fullpkg}}")
|
||||
missing = checkMissingMetadata(yamlMetadata, metadataFor_{{index $val 0}})
|
||||
if len(missing) > 0 {
|
||||
|
|
@ -127,14 +127,17 @@ func getYamlMetadata(basePath string, pkg string) *map[string]string {
|
|||
return &names
|
||||
}
|
||||
|
||||
func checkMissingMetadata(yamlMetadata *map[string]string, componentMetadata map[string]string) map[string]string {
|
||||
missingMetadata := make(map[string]string)
|
||||
func checkMissingMetadata(yamlMetadata *map[string]string, componentMetadata mdutils.MetadataMap) []string {
|
||||
missingMetadata := make([]string, 0)
|
||||
// if there is no yaml metadata, then we are not missing anything yet
|
||||
if yamlMetadata != nil && len(*yamlMetadata) > 0 {
|
||||
for key := range componentMetadata {
|
||||
for key, md := range componentMetadata {
|
||||
if md.Ignored {
|
||||
continue
|
||||
}
|
||||
lowerKey := strings.ToLower(key)
|
||||
if _, ok := (*yamlMetadata)[lowerKey]; !ok {
|
||||
missingMetadata[lowerKey] = componentMetadata[key]
|
||||
missingMetadata = append(missingMetadata, key)
|
||||
}
|
||||
// todo - check if the metadata is the same data type
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,131 +17,22 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// Built-in authentication profiles
|
||||
var BuiltinAuthenticationProfiles map[string][]AuthenticationProfile
|
||||
|
||||
// ParseBuiltinAuthenticationProfile returns an AuthenticationProfile(s) from a given BuiltinAuthenticationProfile.
|
||||
func ParseBuiltinAuthenticationProfile(bi BuiltinAuthenticationProfile) ([]AuthenticationProfile, error) {
|
||||
switch bi.Name {
|
||||
case "aws":
|
||||
return []AuthenticationProfile{
|
||||
{
|
||||
Title: "AWS: Access Key ID and Secret Access Key",
|
||||
Description: "Authenticate using an Access Key ID and Secret Access Key included in the metadata",
|
||||
Metadata: []Metadata{
|
||||
{
|
||||
Name: "accessKey",
|
||||
Required: true,
|
||||
Sensitive: true,
|
||||
Description: "AWS access key associated with an IAM account",
|
||||
Example: `"AKIAIOSFODNN7EXAMPLE"`,
|
||||
},
|
||||
{
|
||||
Name: "secretKey",
|
||||
Required: true,
|
||||
Sensitive: true,
|
||||
Description: "The secret key associated with the access key",
|
||||
Example: `"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"`,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Title: "AWS: Credentials from Environment Variables",
|
||||
Description: "Use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from the environment",
|
||||
Metadata: []Metadata{},
|
||||
},
|
||||
}, nil
|
||||
case "azuread":
|
||||
azureEnvironmentMetadata := Metadata{
|
||||
Name: "azureEnvironment",
|
||||
Required: false,
|
||||
Description: "Optional name for the Azure environment if using a different Azure cloud",
|
||||
Example: `"AzurePublicCloud"`,
|
||||
Default: "AzurePublicCloud",
|
||||
AllowedValues: []string{"AzurePublicCloud", "AzureChinaCloud", "AzureUSGovernmentCloud"},
|
||||
}
|
||||
profiles := []AuthenticationProfile{
|
||||
{
|
||||
Title: "Azure AD: Managed identity",
|
||||
Description: "Authenticate using Azure AD and a managed identity.",
|
||||
Metadata: mergedMetadata(bi.Metadata,
|
||||
Metadata{
|
||||
Name: "azureClientId",
|
||||
Description: "Client ID (application ID). Required if the service has multiple identities assigned.",
|
||||
Example: `"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"`,
|
||||
Required: false,
|
||||
},
|
||||
azureEnvironmentMetadata,
|
||||
),
|
||||
},
|
||||
{
|
||||
Title: "Azure AD: Client credentials",
|
||||
Description: "Authenticate using Azure AD with client credentials, also known as \"service principals\".",
|
||||
Metadata: mergedMetadata(bi.Metadata,
|
||||
Metadata{
|
||||
Name: "azureTenantId",
|
||||
Description: "ID of the Azure AD tenant",
|
||||
Example: `"cd4b2887-304c-47e1-b4d5-65447fdd542a"`,
|
||||
Required: true,
|
||||
},
|
||||
Metadata{
|
||||
Name: "azureClientId",
|
||||
Description: "Client ID (application ID)",
|
||||
Example: `"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"`,
|
||||
Required: true,
|
||||
},
|
||||
Metadata{
|
||||
Name: "azureClientSecret",
|
||||
Description: "Client secret (application password)",
|
||||
Example: `"Ecy3XG7zVZK3/vl/a2NSB+a1zXLa8RnMum/IgD0E"`,
|
||||
Required: true,
|
||||
Sensitive: true,
|
||||
},
|
||||
azureEnvironmentMetadata,
|
||||
),
|
||||
},
|
||||
{
|
||||
Title: "Azure AD: Client certificate",
|
||||
Description: `Authenticate using Azure AD with a client certificate. One of "azureCertificate" and "azureCertificateFile" is required.`,
|
||||
Metadata: mergedMetadata(bi.Metadata,
|
||||
Metadata{
|
||||
Name: "azureTenantId",
|
||||
Description: "ID of the Azure AD tenant",
|
||||
Example: `"cd4b2887-304c-47e1-b4d5-65447fdd542a"`,
|
||||
Required: true,
|
||||
},
|
||||
Metadata{
|
||||
Name: "azureClientId",
|
||||
Description: "Client ID (application ID)",
|
||||
Example: `"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"`,
|
||||
Required: true,
|
||||
},
|
||||
Metadata{
|
||||
Name: "azureCertificate",
|
||||
Description: "Certificate and private key (in either a PEM file containing both the certificate and key, or in PFX/PKCS#12 format)",
|
||||
Example: `"-----BEGIN PRIVATE KEY-----\n MIIEvgI... \n -----END PRIVATE KEY----- \n -----BEGIN CERTIFICATE----- \n MIICoTC... \n -----END CERTIFICATE----- \n"`,
|
||||
Required: false,
|
||||
Sensitive: true,
|
||||
},
|
||||
Metadata{
|
||||
Name: "azureCertificateFile",
|
||||
Description: "Path to PEM or PFX/PKCS#12 file on disk, containing the certificate and private key.",
|
||||
Example: `"/path/to/file.pem"`,
|
||||
Required: false,
|
||||
Sensitive: false,
|
||||
},
|
||||
Metadata{
|
||||
Name: "azureCertificatePassword",
|
||||
Description: "Password for the certificate if encrypted.",
|
||||
Example: `"password"`,
|
||||
Required: false,
|
||||
Sensitive: true,
|
||||
},
|
||||
azureEnvironmentMetadata,
|
||||
),
|
||||
},
|
||||
}
|
||||
return profiles, nil
|
||||
default:
|
||||
profiles, ok := BuiltinAuthenticationProfiles[bi.Name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("built-in authentication profile %s does not exist", bi.Name)
|
||||
}
|
||||
|
||||
res := make([]AuthenticationProfile, len(profiles))
|
||||
for i, profile := range profiles {
|
||||
res[i] = profile
|
||||
res[i].Metadata = mergedMetadata(bi.Metadata, res[i].Metadata...)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func mergedMetadata(base []Metadata, add ...Metadata) []Metadata {
|
||||
|
|
|
|||
|
|
@ -18,116 +18,113 @@ package metadataschema
|
|||
// ComponentMetadata is the schema for the metadata.yaml / metadata.json files.
|
||||
type ComponentMetadata struct {
|
||||
// Version of the component metadata schema.
|
||||
SchemaVersion string `json:"schemaVersion" jsonschema:"enum=v1"`
|
||||
SchemaVersion string `json:"schemaVersion" yaml:"schemaVersion" jsonschema:"enum=v1"`
|
||||
// Component type, of one of the allowed values.
|
||||
Type string `json:"type" jsonschema:"enum=bindings,enum=state,enum=secretstores,enum=pubsub,enum=workflows,enum=configuration,enum=lock,enum=middleware"`
|
||||
Type string `json:"type" yaml:"type" jsonschema:"enum=bindings,enum=state,enum=secretstores,enum=pubsub,enum=workflows,enum=configuration,enum=lock,enum=middleware"`
|
||||
// Name of the component (without the inital type, e.g. "http" instead of "bindings.http").
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Version of the component, with the leading "v", e.g. "v1".
|
||||
Version string `json:"version"`
|
||||
Version string `json:"version" yaml:"version"`
|
||||
// Component status.
|
||||
Status string `json:"status" jsonschema:"enum=stable,enum=beta,enum=alpha,enum=development-only"`
|
||||
Status string `json:"status" yaml:"status" jsonschema:"enum=stable,enum=beta,enum=alpha,enum=development-only"`
|
||||
// Title of the component, e.g. "HTTP".
|
||||
Title string `json:"title"`
|
||||
Title string `json:"title" yaml:"title"`
|
||||
// Additional description for the component, optional.
|
||||
Description string `json:"description,omitempty"`
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
// URLs with additional resources for the component, such as docs.
|
||||
URLs []URL `json:"urls"`
|
||||
URLs []URL `json:"urls" yaml:"urls"`
|
||||
// Properties for bindings only.
|
||||
// This should not present unless "type" is "bindings".
|
||||
Binding *Binding `json:"binding,omitempty"`
|
||||
Binding *Binding `json:"binding,omitempty" yaml:"binding,omitempty"`
|
||||
// Component capabilities.
|
||||
// For state stores, the presence of "actorStateStore" implies that the metadata property "actorStateStore" can be set. In that case, do not manually specify "actorStateStore" as metadata option.
|
||||
Capabilities []string `json:"capabilities,omitempty"`
|
||||
Capabilities []string `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
|
||||
// Authentication profiles for the component.
|
||||
AuthenticationProfiles []AuthenticationProfile `json:"authenticationProfiles,omitempty"`
|
||||
AuthenticationProfiles []AuthenticationProfile `json:"authenticationProfiles,omitempty" yaml:"authenticationProfiles,omitempty"`
|
||||
// Built-in authentication profiles to import.
|
||||
BuiltInAuthenticationProfiles []BuiltinAuthenticationProfile `json:"builtinAuthenticationProfiles,omitempty"`
|
||||
BuiltInAuthenticationProfiles []BuiltinAuthenticationProfile `json:"builtinAuthenticationProfiles,omitempty" yaml:"builtinAuthenticationProfiles,omitempty"`
|
||||
// Metadata options for the component.
|
||||
Metadata []Metadata `json:"metadata,omitempty"`
|
||||
Metadata []Metadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// URL represents one URL with additional resources.
|
||||
type URL struct {
|
||||
// Title of the URL.
|
||||
Title string `json:"title"`
|
||||
Title string `json:"title" yaml:"title"`
|
||||
// URL.
|
||||
URL string `json:"url"`
|
||||
URL string `json:"url" yaml:"url"`
|
||||
}
|
||||
|
||||
// Binding represents properties that are specific to bindings
|
||||
type Binding struct {
|
||||
// If "true", the binding can be used as input binding.
|
||||
Input bool `json:"input,omitempty"`
|
||||
Input bool `json:"input,omitempty" yaml:"input,omitempty"`
|
||||
// If "true", the binding can be used as output binding.
|
||||
Output bool `json:"output,omitempty"`
|
||||
Output bool `json:"output,omitempty" yaml:"output,omitempty"`
|
||||
// List of operations that the output binding support.
|
||||
// Required in output bindings, and not allowed in input-only bindings.
|
||||
Operations []BindingOperation `json:"operations"`
|
||||
Operations []BindingOperation `json:"operations" yaml:"operations"`
|
||||
}
|
||||
|
||||
// BindingOperation represents an operation offered by an output binding.
|
||||
type BindingOperation struct {
|
||||
// Name of the operation, such as "create", "post", "delete", etc.
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Descrption of the operation.
|
||||
Description string `json:"description"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
}
|
||||
|
||||
// Metadata property.
|
||||
type Metadata struct {
|
||||
// Name of the metadata property.
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Description of the property.
|
||||
Description string `json:"description"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
// If "true", the property is required
|
||||
Required bool `json:"required,omitempty"`
|
||||
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
|
||||
// If "true", the property represents a sensitive value such as a password.
|
||||
Sensitive bool `json:"sensitive,omitempty"`
|
||||
Sensitive bool `json:"sensitive,omitempty" yaml:"sensitive,omitempty"`
|
||||
// Type of the property.
|
||||
// If this is empty, it's interpreted as "string".
|
||||
Type string `json:"type,omitempty" jsonschema:"enum=string,enum=number,enum=bool,enum=duration"`
|
||||
Type string `json:"type,omitempty" yaml:"type,omitempty" jsonschema:"enum=string,enum=number,enum=bool,enum=duration"`
|
||||
// Default value for the property.
|
||||
// If it's a string, don't forget to add quotes.
|
||||
Default string `json:"default,omitempty"`
|
||||
Default string `json:"default,omitempty" yaml:"default,omitempty"`
|
||||
// Example value.
|
||||
Example string `json:"example"`
|
||||
Example string `json:"example" yaml:"example"`
|
||||
// If set, forces the value to be one of those specified in this allowlist.
|
||||
AllowedValues []string `json:"allowedValues,omitempty"`
|
||||
AllowedValues []string `json:"allowedValues,omitempty" yaml:"allowedValues,omitempty"`
|
||||
// If set, specifies that the property is only applicable to bindings of the type specified below.
|
||||
// At least one of "input" and "output" must be "true".
|
||||
Binding *MetadataBinding `json:"binding,omitempty"`
|
||||
Binding *MetadataBinding `json:"binding,omitempty" yaml:"binding,omitempty"`
|
||||
// URL with additional information, such as docs.
|
||||
URL *URL `json:"url,omitempty"`
|
||||
URL *URL `json:"url,omitempty" yaml:"url,omitempty"`
|
||||
// If set, specifies that the property is deprecated and should not be used in new configurations.
|
||||
Deprecated bool `json:"deprecated,omitempty"`
|
||||
Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`
|
||||
}
|
||||
|
||||
// MetadataBinding is the type for the "binding" property in the "metadata" object.
|
||||
type MetadataBinding struct {
|
||||
// If "true", the property can be used with the binding as input binding only.
|
||||
Input bool `json:"input,omitempty"`
|
||||
Input bool `json:"input,omitempty" yaml:"input,omitempty"`
|
||||
// If "true", the property can be used with the binding as output binding only.
|
||||
Output bool `json:"output,omitempty"`
|
||||
Output bool `json:"output,omitempty" yaml:"output,omitempty"`
|
||||
}
|
||||
|
||||
// AuthenticationProfile is the type for an authentication profile.
|
||||
type AuthenticationProfile struct {
|
||||
// Title of the authentication profile.
|
||||
Title string `json:"title"`
|
||||
Title string `json:"title" yaml:"title"`
|
||||
// Additional description for the authentication profile, optional.
|
||||
Description string `json:"description"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
// Metadata options applicable when using this authentication profile.
|
||||
Metadata []Metadata `json:"metadata,omitempty"`
|
||||
Metadata []Metadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// BuiltinAuthenticationProfile is a reference to a built-in authentication profile.
|
||||
type BuiltinAuthenticationProfile struct {
|
||||
// Name of the built-in authentication profile.
|
||||
// Currently supports:
|
||||
//
|
||||
// - `azuread` (Azure AD, including Managed Identity).
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
// Additional metadata options applicable when using this authentication profile.
|
||||
Metadata []Metadata `json:"metadata,omitempty"`
|
||||
Metadata []Metadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,18 @@ func (c *ComponentMetadata) IsValid() error {
|
|||
// Remove the property builtinAuthenticationProfiles now
|
||||
c.BuiltInAuthenticationProfiles = nil
|
||||
|
||||
// Trim newlines from all descriptions
|
||||
c.Description = strings.TrimSpace(c.Description)
|
||||
for i := range c.AuthenticationProfiles {
|
||||
c.AuthenticationProfiles[i].Description = strings.TrimSpace(c.AuthenticationProfiles[i].Description)
|
||||
for j := range c.AuthenticationProfiles[i].Metadata {
|
||||
c.AuthenticationProfiles[i].Metadata[j].Description = strings.TrimSpace(c.AuthenticationProfiles[i].Metadata[j].Description)
|
||||
}
|
||||
}
|
||||
for i := range c.Metadata {
|
||||
c.Metadata[i].Description = strings.TrimSpace(c.Metadata[i].Description)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ run:
|
|||
# list of build tags, all linters use it. Default is empty list.
|
||||
build-tags:
|
||||
- certtests
|
||||
- metadata
|
||||
|
||||
# which dirs to skip: they won't be analyzed;
|
||||
# can use regexp here: generated.*, regexp is applied on full path;
|
||||
|
|
|
|||
5
Makefile
5
Makefile
|
|
@ -109,14 +109,13 @@ verify-linter-version:
|
|||
################################################################################
|
||||
.PHONY: test
|
||||
test:
|
||||
CGO_ENABLED=$(CGO) go test ./... $(COVERAGE_OPTS) $(BUILDMODE) --timeout=15m
|
||||
CGO_ENABLED=$(CGO) go test ./... $(COVERAGE_OPTS) $(BUILDMODE) -tags metadata --timeout=15m
|
||||
|
||||
################################################################################
|
||||
# Target: lint #
|
||||
################################################################################
|
||||
.PHONY: lint
|
||||
lint: verify-linter-installed verify-linter-version
|
||||
# Due to https://github.com/golangci/golangci-lint/issues/580, we need to add --fix for windows
|
||||
$(GOLANGCI_LINT) run --timeout=20m
|
||||
|
||||
################################################################################
|
||||
|
|
@ -228,7 +227,7 @@ check-component-metadata:
|
|||
go get "github.com/dapr/components-contrib@master" && \
|
||||
go mod edit -replace "github.com/dapr/components-contrib"="../" && \
|
||||
go mod tidy && \
|
||||
go build . && \
|
||||
go build -tags metadata . && \
|
||||
rm ./go.mod && rm ./go.sum && rm ./main.go && \
|
||||
./metadataanalyzer ../
|
||||
|
||||
|
|
|
|||
|
|
@ -207,11 +207,10 @@ func (t *DingTalkWebhook) sendMessage(ctx context.Context, req *bindings.InvokeR
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (t *DingTalkWebhook) GetComponentMetadata() map[string]string {
|
||||
func (t *DingTalkWebhook) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := Settings{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
||||
func getPostURL(urlPath, secret string) (string, error) {
|
||||
|
|
|
|||
|
|
@ -108,9 +108,8 @@ func (s *AliCloudOSS) getClient(metadata *ossMetadata) (*oss.Client, error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *AliCloudOSS) GetComponentMetadata() map[string]string {
|
||||
func (s *AliCloudOSS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := ossMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,9 +128,8 @@ func (callback *Callback) Fail(result *producer.Result) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *AliCloudSlsLogstorage) GetComponentMetadata() map[string]string {
|
||||
func (s *AliCloudSlsLogstorage) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := SlsLogstorageMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,9 +347,8 @@ func contains(arr []string, str string) bool {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *AliCloudTableStore) GetComponentMetadata() map[string]string {
|
||||
func (s *AliCloudTableStore) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := tablestoreMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,9 +261,8 @@ func makeErrorResponse(httpResponse *http.Response) (*bindings.InvokeResponse, e
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *APNS) GetComponentMetadata() map[string]string {
|
||||
func (a *APNS) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := APNSmetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,9 +115,8 @@ func (d *DynamoDB) getClient(metadata *dynamoDBMetadata) (*dynamodb.DynamoDB, er
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (d *DynamoDB) GetComponentMetadata() map[string]string {
|
||||
func (d *DynamoDB) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := dynamoDBMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,9 +418,8 @@ func (p *recordProcessor) Shutdown(input *interfaces.ShutdownInput) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AWSKinesis) GetComponentMetadata() map[string]string {
|
||||
func (a *AWSKinesis) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := &kinesisMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,10 +62,12 @@ type AWSS3 struct {
|
|||
}
|
||||
|
||||
type s3Metadata 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"`
|
||||
|
||||
Region string `json:"region" mapstructure:"region"`
|
||||
Endpoint string `json:"endpoint" mapstructure:"endpoint"`
|
||||
AccessKey string `json:"accessKey" mapstructure:"accessKey"`
|
||||
SecretKey string `json:"secretKey" mapstructure:"secretKey"`
|
||||
SessionToken string `json:"sessionToken" mapstructure:"sessionToken"`
|
||||
Bucket string `json:"bucket" mapstructure:"bucket"`
|
||||
DecodeBase64 bool `json:"decodeBase64,string" mapstructure:"decodeBase64"`
|
||||
|
|
@ -416,9 +418,8 @@ func (metadata s3Metadata) mergeWithRequestMetadata(req *bindings.InvokeRequest)
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *AWSS3) GetComponentMetadata() map[string]string {
|
||||
func (s *AWSS3) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := s3Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,9 +171,8 @@ func (a *AWSSES) getClient(metadata *sesMetadata) (*ses.SES, error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AWSSES) GetComponentMetadata() map[string]string {
|
||||
func (a *AWSSES) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := sesMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,9 +117,8 @@ func (a *AWSSNS) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bind
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AWSSNS) GetComponentMetadata() map[string]string {
|
||||
func (a *AWSSNS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := snsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,9 +187,8 @@ func (a *AWSSQS) getClient(metadata *sqsMetadata) (*sqs.SQS, error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AWSSQS) GetComponentMetadata() map[string]string {
|
||||
func (a *AWSSQS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := sqsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,9 +358,8 @@ func (a *AzureBlobStorage) isValidDeleteSnapshotsOptionType(accessType azblob.De
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AzureBlobStorage) GetComponentMetadata() map[string]string {
|
||||
func (a *AzureBlobStorage) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := storageinternal.BlobStorageMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,9 +192,8 @@ func (c *CosmosDB) lookup(m map[string]interface{}, ks []string) (val interface{
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (c *CosmosDB) GetComponentMetadata() map[string]string {
|
||||
func (c *CosmosDB) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := cosmosDBCredentials{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,9 +130,8 @@ func (c *CosmosDBGremlinAPI) Invoke(_ context.Context, req *bindings.InvokeReque
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (c *CosmosDBGremlinAPI) GetComponentMetadata() map[string]string {
|
||||
func (c *CosmosDBGremlinAPI) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := cosmosDBGremlinAPICredentials{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -535,9 +535,8 @@ func (a *AzureEventGrid) subscriptionNeedsUpdating(res armeventgrid.EventSubscri
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AzureEventGrid) GetComponentMetadata() map[string]string {
|
||||
func (a *AzureEventGrid) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := azureEventGridMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ metadata:
|
|||
output: false
|
||||
description: |
|
||||
The HTTPS endpoint of the webhook Event Grid sends events (formatted as
|
||||
Cloud Events) to. If you’re not re-writing URLs on ingress, it should be
|
||||
Cloud Events) to. If you're not re-writing URLs on ingress, it should be
|
||||
in the form of: `"https://[YOUR HOSTNAME]/<path>"` If testing on your
|
||||
local machine, you can use something like `ngrok` to create a public
|
||||
endpoint.
|
||||
|
|
|
|||
|
|
@ -96,9 +96,8 @@ func (a *AzureEventHubs) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AzureEventHubs) GetComponentMetadata() map[string]string {
|
||||
func (a *AzureEventHubs) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := impl.AzureEventHubsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,14 +89,6 @@ builtinAuthenticationProfiles:
|
|||
Number of partitions for the new Event Hub namespace. Used only when
|
||||
entity management is enabled.
|
||||
metadata:
|
||||
# Input and output metadata
|
||||
- name: partitionId
|
||||
type: string
|
||||
required: false
|
||||
description: |
|
||||
DEPRECATED.
|
||||
deprecated: true
|
||||
example: ""
|
||||
# Input-only metadata
|
||||
# consumerGroup is an alias for consumerId, if both are defined consumerId takes precedence.
|
||||
- name: consumerId
|
||||
|
|
|
|||
|
|
@ -318,9 +318,8 @@ func (p *AzOpenAI) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (p *AzOpenAI) GetComponentMetadata() map[string]string {
|
||||
func (p *AzOpenAI) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := openAIMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,10 +204,9 @@ func (a *AzureServiceBusQueues) Close() (err error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AzureServiceBusQueues) GetComponentMetadata() map[string]string {
|
||||
func (a *AzureServiceBusQueues) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := impl.Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
delete(metadataInfo, "consumerID") // only applies to topics, not queues
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,9 +301,8 @@ func (s *SignalR) getToken(ctx context.Context, url string) (string, error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *SignalR) GetComponentMetadata() map[string]string {
|
||||
func (s *SignalR) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := SignalRMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,9 +370,8 @@ func (a *AzureStorageQueues) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *AzureStorageQueues) GetComponentMetadata() map[string]string {
|
||||
func (a *AzureStorageQueues) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := storageQueuesMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,9 +136,8 @@ func (q *CFQueues) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (q *CFQueues) GetComponentMetadata() map[string]string {
|
||||
func (q *CFQueues) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := componentMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,9 +201,8 @@ func (ct *Binding) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (ct Binding) GetComponentMetadata() map[string]string {
|
||||
func (ct Binding) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := commercetoolsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,9 +132,8 @@ func (b *Binding) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (b *Binding) GetComponentMetadata() map[string]string {
|
||||
func (b *Binding) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import (
|
|||
dubboImpl "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl"
|
||||
|
||||
"github.com/dapr/components-contrib/bindings"
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
"github.com/dapr/kit/logger"
|
||||
)
|
||||
|
||||
|
|
@ -93,7 +94,6 @@ func (out *DubboOutputBinding) Operations() []bindings.OperationKind {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (out *DubboOutputBinding) GetComponentMetadata() map[string]string {
|
||||
metadataInfo := map[string]string{}
|
||||
return metadataInfo
|
||||
func (out *DubboOutputBinding) GetComponentMetadata() metadata.MetadataMap {
|
||||
return metadata.MetadataMap{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import (
|
|||
|
||||
"github.com/dapr/components-contrib/bindings"
|
||||
"github.com/dapr/components-contrib/internal/utils"
|
||||
contribMetadata "github.com/dapr/components-contrib/metadata"
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
"github.com/dapr/kit/logger"
|
||||
)
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ func (g *GCPStorage) Init(ctx context.Context, metadata bindings.Metadata) error
|
|||
|
||||
func (g *GCPStorage) parseMetadata(meta bindings.Metadata) (*gcpMetadata, error) {
|
||||
m := gcpMetadata{}
|
||||
err := contribMetadata.DecodeMetadata(meta.Properties, &m)
|
||||
err := metadata.DecodeMetadata(meta.Properties, &m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -311,9 +311,8 @@ func (g *GCPStorage) handleBackwardCompatibilityForMetadata(metadata map[string]
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (g *GCPStorage) GetComponentMetadata() map[string]string {
|
||||
func (g *GCPStorage) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := gcpMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,9 +151,8 @@ func (g *GCPPubSub) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (g *GCPPubSub) GetComponentMetadata() map[string]string {
|
||||
func (g *GCPPubSub) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := pubSubMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,9 +186,8 @@ func (gql *GraphQL) runRequest(ctx context.Context, requestKey string, req *bind
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (gql *GraphQL) GetComponentMetadata() map[string]string {
|
||||
func (gql *GraphQL) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := graphQLMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -338,9 +338,8 @@ func (h *HTTPSource) Invoke(parentCtx context.Context, req *bindings.InvokeReque
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (h *HTTPSource) GetComponentMetadata() map[string]string {
|
||||
func (h *HTTPSource) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := httpMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,9 +322,8 @@ func (o *HuaweiOBS) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*b
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (o *HuaweiOBS) GetComponentMetadata() map[string]string {
|
||||
func (o *HuaweiOBS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := obsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,9 +167,8 @@ func (i *Influx) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (i *Influx) GetComponentMetadata() map[string]string {
|
||||
func (i *Influx) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := influxMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,13 @@ import (
|
|||
"io"
|
||||
|
||||
"github.com/dapr/components-contrib/health"
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
)
|
||||
|
||||
// InputBinding is the interface to define a binding that triggers on incoming events.
|
||||
type InputBinding interface {
|
||||
metadata.ComponentWithMetadata
|
||||
|
||||
// Init passes connection and properties metadata to the binding implementation.
|
||||
Init(ctx context.Context, metadata Metadata) error
|
||||
// Read is a method that runs in background and triggers the callback function whenever an event arrives.
|
||||
|
|
@ -30,7 +33,6 @@ type InputBinding interface {
|
|||
// Close is a method that closes the connection to the binding. Must be
|
||||
// called when the binding is no longer needed to free up resources.
|
||||
io.Closer
|
||||
GetComponentMetadata() map[string]string
|
||||
}
|
||||
|
||||
// Handler is the handler used to invoke the app handler.
|
||||
|
|
|
|||
|
|
@ -138,9 +138,8 @@ func adaptHandler(handler bindings.Handler) kafka.EventHandler {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (b *Binding) GetComponentMetadata() map[string]string {
|
||||
func (b *Binding) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := kafka.KafkaMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/dapr/components-contrib/bindings"
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
"github.com/dapr/kit/logger"
|
||||
)
|
||||
|
||||
|
|
@ -79,7 +80,6 @@ func (out *kitexOutputBinding) Operations() []bindings.OperationKind {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (out *kitexOutputBinding) GetComponentMetadata() map[string]string {
|
||||
metadataInfo := map[string]string{}
|
||||
return metadataInfo
|
||||
func (out *kitexOutputBinding) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,9 +172,8 @@ func (k *kubeMQ) processQueueMessage(ctx context.Context, handler bindings.Handl
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (k *kubeMQ) GetComponentMetadata() map[string]string {
|
||||
func (k *kubeMQ) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := options{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,9 +202,8 @@ func (k *kubernetesInput) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (k *kubernetesInput) GetComponentMetadata() map[string]string {
|
||||
func (k *kubernetesInput) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := kubernetesMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,9 +336,8 @@ func (ls *LocalStorage) Invoke(_ context.Context, req *bindings.InvokeRequest) (
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (ls *LocalStorage) GetComponentMetadata() map[string]string {
|
||||
func (ls *LocalStorage) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -384,9 +384,8 @@ func (m *MQTT) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (m *MQTT) GetComponentMetadata() map[string]string {
|
||||
func (m *MQTT) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := mqtt3Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,9 +370,8 @@ func (m *Mysql) convert(columnTypes []*sql.ColumnType, values []any) map[string]
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (m *Mysql) GetComponentMetadata() map[string]string {
|
||||
func (m *Mysql) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := mysqlMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -457,9 +457,8 @@ func parseServerURL(s string) (*constant.ServerConfig, error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (n *Nacos) GetComponentMetadata() map[string]string {
|
||||
func (n *Nacos) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := Settings{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,16 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/dapr/components-contrib/health"
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
)
|
||||
|
||||
// OutputBinding is the interface for an output binding, allowing users to invoke remote systems with optional payloads.
|
||||
type OutputBinding interface {
|
||||
metadata.ComponentWithMetadata
|
||||
|
||||
Init(ctx context.Context, metadata Metadata) error
|
||||
Invoke(ctx context.Context, req *InvokeRequest) (*InvokeResponse, error)
|
||||
Operations() []OperationKind
|
||||
GetComponentMetadata() map[string]string
|
||||
}
|
||||
|
||||
func PingOutBinding(ctx context.Context, outputBinding OutputBinding) error {
|
||||
|
|
|
|||
|
|
@ -213,9 +213,8 @@ func (p *Postgres) exec(ctx context.Context, sql string, args ...any) (result in
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (p *Postgres) GetComponentMetadata() map[string]string {
|
||||
func (p *Postgres) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := psqlMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,9 +161,8 @@ func (p *Postmark) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bi
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (p *Postmark) GetComponentMetadata() map[string]string {
|
||||
func (p *Postmark) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := postmarkMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -548,9 +548,8 @@ func (r *RabbitMQ) reset() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
func (r *RabbitMQ) GetComponentMetadata() map[string]string {
|
||||
func (r *RabbitMQ) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := rabbitMQMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,8 @@ func (r *Redis) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (r *Redis) GetComponentMetadata() map[string]string {
|
||||
func (r *Redis) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := rediscomponent.Settings{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,9 +166,8 @@ func metadataToConfig(cfg map[string]string, logger logger.Logger) (StateConfig,
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (b *Binding) GetComponentMetadata() map[string]string {
|
||||
func (b *Binding) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := StateConfig{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,9 +231,8 @@ func (metadata Metadata) parseAddresses(addresses string) []string {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *Mailer) GetComponentMetadata() map[string]string {
|
||||
func (s *Mailer) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,11 +264,10 @@ func (sg *SendGrid) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*b
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (sg *SendGrid) GetComponentMetadata() map[string]string {
|
||||
func (sg *SendGrid) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := sendGridMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
||||
// Function that unmarshals the Dynamic Template Data JSON String into a map[string]any.
|
||||
|
|
|
|||
|
|
@ -135,9 +135,8 @@ func (t *SMS) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*binding
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (t *SMS) GetComponentMetadata() map[string]string {
|
||||
func (t *SMS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := twilioMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,9 +168,8 @@ func detectImports(imports []api.FunctionDefinition) importMode {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (out *outputBinding) GetComponentMetadata() map[string]string {
|
||||
func (out *outputBinding) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := wasm.InitMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,9 +131,8 @@ func (z *ZeebeCommand) Invoke(ctx context.Context, req *bindings.InvokeRequest)
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (z *ZeebeCommand) GetComponentMetadata() map[string]string {
|
||||
func (z *ZeebeCommand) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := zeebe.ClientMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,9 +256,8 @@ func (h *jobHandler) failJob(ctx context.Context, client worker.JobClient, job e
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (z *ZeebeJobWorker) GetComponentMetadata() map[string]string {
|
||||
func (z *ZeebeJobWorker) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := jobWorkerMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.BindingType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Name of the built-in authentication profile.\nCurrently supports:\n\n- `azuread` (Azure AD, including Managed Identity)."
|
||||
"description": "Name of the built-in authentication profile."
|
||||
},
|
||||
"metadata": {
|
||||
"items": {
|
||||
|
|
|
|||
|
|
@ -338,9 +338,8 @@ func (r *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (r *ConfigurationStore) GetComponentMetadata() map[string]string {
|
||||
func (r *ConfigurationStore) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.ConfigurationStoreType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,9 +376,8 @@ func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyCha
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (p *ConfigurationStore) GetComponentMetadata() map[string]string {
|
||||
func (p *ConfigurationStore) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.ConfigurationStoreType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,9 +245,8 @@ func (r *ConfigurationStore) handleSubscribedChange(ctx context.Context, req *co
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (r *ConfigurationStore) GetComponentMetadata() map[string]string {
|
||||
func (r *ConfigurationStore) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := rediscomponent.Settings{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.ConfigurationStoreType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,16 @@ limitations under the License.
|
|||
|
||||
package configuration
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
)
|
||||
|
||||
// Store is an interface to perform operations on store.
|
||||
type Store interface {
|
||||
metadata.ComponentWithMetadata
|
||||
|
||||
// Init configuration store.
|
||||
Init(ctx context.Context, metadata Metadata) error
|
||||
|
||||
|
|
@ -28,9 +34,6 @@ type Store interface {
|
|||
|
||||
// Unsubscribe configuration with keys
|
||||
Unsubscribe(ctx context.Context, req *UnsubscribeRequest) error
|
||||
|
||||
// GetComponentMetadata returns information on the component's metadata.
|
||||
GetComponentMetadata() map[string]string
|
||||
}
|
||||
|
||||
// UpdateHandler is the handler used to send event to daprd.
|
||||
|
|
|
|||
|
|
@ -406,11 +406,10 @@ func (keyvaultCrypto) SupportedSignatureAlgorithms() []string {
|
|||
return signatureAlgsList
|
||||
}
|
||||
|
||||
func (keyvaultCrypto) GetComponentMetadata() map[string]string {
|
||||
func (keyvaultCrypto) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := keyvaultMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.CryptoType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
||||
type keyID struct {
|
||||
|
|
|
|||
|
|
@ -126,9 +126,8 @@ func (k *jwksCrypto) retrieveKeyFromSecretFn(parentCtx context.Context, kid stri
|
|||
return key, nil
|
||||
}
|
||||
|
||||
func (k *jwksCrypto) GetComponentMetadata() map[string]string {
|
||||
func (k *jwksCrypto) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := jwksMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.CryptoType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
contribCrypto "github.com/dapr/components-contrib/crypto"
|
||||
kubeclient "github.com/dapr/components-contrib/internal/authentication/kubernetes"
|
||||
contribMetadata "github.com/dapr/components-contrib/metadata"
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
internals "github.com/dapr/kit/crypto"
|
||||
"github.com/dapr/kit/logger"
|
||||
)
|
||||
|
|
@ -136,9 +136,8 @@ func (k *kubeSecretsCrypto) parseKeyString(param string) (namespace string, secr
|
|||
return
|
||||
}
|
||||
|
||||
func (kubeSecretsCrypto) GetComponentMetadata() map[string]string {
|
||||
func (kubeSecretsCrypto) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := secretsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.CryptoType)
|
||||
return metadataInfo
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.CryptoType)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,9 +105,8 @@ func (l *localStorageCrypto) retrieveKey(parentCtx context.Context, key string)
|
|||
return jwkObj, nil
|
||||
}
|
||||
|
||||
func (localStorageCrypto) GetComponentMetadata() map[string]string {
|
||||
func (localStorageCrypto) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := localStorageMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.CryptoType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,14 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/lestrrat-go/jwx/v2/jwk"
|
||||
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
)
|
||||
|
||||
// SubtleCrypto offers an interface to perform low-level ("subtle") cryptographic operations with keys stored in a vault.
|
||||
type SubtleCrypto interface {
|
||||
metadata.ComponentWithMetadata
|
||||
|
||||
SubtleCryptoAlgorithms
|
||||
|
||||
// Init the component.
|
||||
|
|
@ -161,9 +165,6 @@ type SubtleCrypto interface {
|
|||
valid bool,
|
||||
err error,
|
||||
)
|
||||
|
||||
// GetComponentMetadata returns information on the component's metadata.
|
||||
GetComponentMetadata() map[string]string
|
||||
}
|
||||
|
||||
// SubtleCryptoAlgorithms is an extension to SubtleCrypto that includes methods to return information on the supported algorithms.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
type BlobStorageMetadata struct {
|
||||
ContainerClientOpts `json:",inline" mapstructure:",squash"`
|
||||
DecodeBase64 bool `json:"decodeBase64,string" mapstructure:"decodeBase64" only:"bindings"`
|
||||
DecodeBase64 bool `json:"decodeBase64,string" mapstructure:"decodeBase64" mdonly:"bindings"`
|
||||
PublicAccessLevel azblob.PublicAccessType
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,8 @@ type AzureEventHubsMetadata struct {
|
|||
ResourceGroupName string `json:"resourceGroupName" mapstructure:"resourceGroupName"`
|
||||
|
||||
// Binding only
|
||||
EventHub string `json:"eventHub" mapstructure:"eventHub" only:"bindings"`
|
||||
ConsumerGroup string `json:"consumerGroup" mapstructure:"consumerGroup" only:"bindings"` // Alias for ConsumerID
|
||||
PartitionID string `json:"partitionID" mapstructure:"partitionID" only:"bindings"` // Deprecated
|
||||
EventHub string `json:"eventHub" mapstructure:"eventHub" mdonly:"bindings"`
|
||||
ConsumerGroup string `json:"consumerGroup" mapstructure:"consumerGroup" mdonly:"bindings"` // Alias for ConsumerID
|
||||
|
||||
// Internal properties
|
||||
namespaceName string
|
||||
|
|
@ -91,16 +90,9 @@ func parseEventHubsMetadata(meta map[string]string, isBinding bool, log logger.L
|
|||
return nil, errors.New("the provided connection string does not contain a value for 'EntityPath' and no 'eventHub' property was passed")
|
||||
}
|
||||
}
|
||||
|
||||
// Property partitionID is deprecated
|
||||
if m.PartitionID != "" {
|
||||
log.Info("Property partitionID is deprecated and will be ignored")
|
||||
m.PartitionID = ""
|
||||
}
|
||||
} else {
|
||||
// Ignored when not a binding
|
||||
m.EventHub = ""
|
||||
m.PartitionID = ""
|
||||
|
||||
// If connecting using a connection string, parse hubName
|
||||
if m.ConnectionString != "" {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ type Metadata struct {
|
|||
NamespaceName string `mapstructure:"namespaceName"` // Only for Azure AD
|
||||
|
||||
/** For bindings only **/
|
||||
QueueName string `mapstructure:"queueName" only:"bindings"` // Only queues
|
||||
QueueName string `mapstructure:"queueName" mdonly:"bindings"` // Only queues
|
||||
}
|
||||
|
||||
// Keys.
|
||||
|
|
|
|||
|
|
@ -120,9 +120,8 @@ func (p *PostgreSQL) GetDBAccess() dbAccess {
|
|||
return p.dbaccess
|
||||
}
|
||||
|
||||
func (p *PostgreSQL) GetComponentMetadata() map[string]string {
|
||||
func (p *PostgreSQL) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := postgresMetadataStruct{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.StateStoreType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,23 +79,23 @@ type Settings struct {
|
|||
EnableTLS bool `mapstructure:"enableTLS"`
|
||||
|
||||
// == state only properties ==
|
||||
TTLInSeconds *int `mapstructure:"ttlInSeconds" only:"state"`
|
||||
QueryIndexes string `mapstructure:"queryIndexes" only:"state"`
|
||||
TTLInSeconds *int `mapstructure:"ttlInSeconds" mdonly:"state"`
|
||||
QueryIndexes string `mapstructure:"queryIndexes" mdonly:"state"`
|
||||
|
||||
// == pubsub only properties ==
|
||||
// The consumer identifier
|
||||
ConsumerID string `mapstructure:"consumerID" only:"pubsub"`
|
||||
ConsumerID string `mapstructure:"consumerID" mdonly:"pubsub"`
|
||||
// The interval between checking for pending messages to redelivery (0 disables redelivery)
|
||||
RedeliverInterval time.Duration `mapstructure:"-" only:"pubsub"`
|
||||
RedeliverInterval time.Duration `mapstructure:"-" mdonly:"pubsub"`
|
||||
// The amount time a message must be pending before attempting to redeliver it (0 disables redelivery)
|
||||
ProcessingTimeout time.Duration `mapstructure:"processingTimeout" only:"pubsub"`
|
||||
ProcessingTimeout time.Duration `mapstructure:"processingTimeout" mdonly:"pubsub"`
|
||||
// The size of the message queue for processing
|
||||
QueueDepth uint `mapstructure:"queueDepth" only:"pubsub"`
|
||||
QueueDepth uint `mapstructure:"queueDepth" mdonly:"pubsub"`
|
||||
// The number of concurrent workers that are processing messages
|
||||
Concurrency uint `mapstructure:"concurrency" only:"pubsub"`
|
||||
Concurrency uint `mapstructure:"concurrency" mdonly:"pubsub"`
|
||||
|
||||
// the max len of stream
|
||||
MaxLenApprox int64 `mapstructure:"maxLenApprox" only:"pubsub"`
|
||||
// The max len of stream
|
||||
MaxLenApprox int64 `mapstructure:"maxLenApprox" mdonly:"pubsub"`
|
||||
}
|
||||
|
||||
func (s *Settings) Decode(in interface{}) error {
|
||||
|
|
|
|||
|
|
@ -183,9 +183,8 @@ func (r *StandaloneRedisLock) Close() error {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (r *StandaloneRedisLock) GetComponentMetadata() map[string]string {
|
||||
func (r *StandaloneRedisLock) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := rediscomponent.Settings{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.LockStoreType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,15 @@ limitations under the License.
|
|||
|
||||
package lock
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/dapr/components-contrib/metadata"
|
||||
)
|
||||
|
||||
type Store interface {
|
||||
metadata.ComponentWithMetadata
|
||||
|
||||
// Init this component.
|
||||
InitLockStore(ctx context.Context, metadata Metadata) error
|
||||
|
||||
|
|
@ -24,7 +30,4 @@ type Store interface {
|
|||
|
||||
// Unlock tries to release a lock.
|
||||
Unlock(ctx context.Context, req *UnlockRequest) (*UnlockResponse, error)
|
||||
|
||||
// GetComponentMetadata returns information on the component's metadata.
|
||||
GetComponentMetadata() map[string]string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
//go:build !metadata
|
||||
// +build !metadata
|
||||
|
||||
/*
|
||||
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 metadata
|
||||
|
||||
// ComponentWithMetadata is empty when the `metadata` build tag is not present.
|
||||
// The build tag is present when running the linter.
|
||||
type ComponentWithMetadata interface {
|
||||
// Empty
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
//go:build metadata
|
||||
// +build metadata
|
||||
|
||||
/*
|
||||
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 metadata
|
||||
|
||||
// ComponentWithMetadata includes the GetComponentMetadata method when the `metadata` build tag is present.
|
||||
// The build tag is present when running the linter.
|
||||
type ComponentWithMetadata interface {
|
||||
GetComponentMetadata() MetadataMap
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ func GetMetadataProperty(props map[string]string, keys ...string) (val string, o
|
|||
|
||||
// DecodeMetadata decodes metadata into a struct
|
||||
// This is an extension of mitchellh/mapstructure which also supports decoding durations
|
||||
func DecodeMetadata(input interface{}, result interface{}) error {
|
||||
func DecodeMetadata(input any, result any) error {
|
||||
// avoids a common mistake of passing the metadata struct, instead of the properties map
|
||||
// if input is of type struct, case it to metadata.Base and access the Properties instead
|
||||
v := reflect.ValueOf(input)
|
||||
|
|
@ -174,8 +174,8 @@ func toTruthyBoolHookFunc() mapstructure.DecodeHookFunc {
|
|||
return func(
|
||||
f reflect.Type,
|
||||
t reflect.Type,
|
||||
data interface{},
|
||||
) (interface{}, error) {
|
||||
data any,
|
||||
) (any, error) {
|
||||
if f == reflect.TypeOf("") && t == reflect.TypeOf(true) {
|
||||
val := data.(string)
|
||||
return utils.IsTruthy(val), nil
|
||||
|
|
@ -192,8 +192,8 @@ func toStringArrayHookFunc() mapstructure.DecodeHookFunc {
|
|||
return func(
|
||||
f reflect.Type,
|
||||
t reflect.Type,
|
||||
data interface{},
|
||||
) (interface{}, error) {
|
||||
data any,
|
||||
) (any, error) {
|
||||
if f == reflect.TypeOf("") && t == reflect.TypeOf([]string{}) {
|
||||
val := data.(string)
|
||||
return strings.Split(val, ","), nil
|
||||
|
|
@ -231,8 +231,8 @@ func toTimeDurationArrayHookFunc() mapstructure.DecodeHookFunc {
|
|||
return func(
|
||||
f reflect.Type,
|
||||
t reflect.Type,
|
||||
data interface{},
|
||||
) (interface{}, error) {
|
||||
data any,
|
||||
) (any, error) {
|
||||
if f == reflect.TypeOf("") && t == reflect.TypeOf([]time.Duration{}) {
|
||||
inputArrayString := data.(string)
|
||||
return convert(inputArrayString)
|
||||
|
|
@ -296,9 +296,22 @@ func (t ComponentType) BuiltInMetadataProperties() []string {
|
|||
}
|
||||
}
|
||||
|
||||
type MetadataField struct {
|
||||
// Field type
|
||||
Type string
|
||||
// True if the field should be ignored by the metadata analyzer
|
||||
Ignored bool
|
||||
// True if the field is deprecated
|
||||
Deprecated bool
|
||||
// Aliases used for old, deprecated names
|
||||
Aliases []string
|
||||
}
|
||||
|
||||
type MetadataMap map[string]MetadataField
|
||||
|
||||
// GetMetadataInfoFromStructType converts a struct to a map of field name (or struct tag) to field type.
|
||||
// This is used to generate metadata documentation for components.
|
||||
func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *map[string]string, componentType ComponentType) error {
|
||||
func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *MetadataMap, componentType ComponentType) error {
|
||||
// Return if not struct or pointer to struct.
|
||||
if t.Kind() == reflect.Ptr {
|
||||
t = t.Elem()
|
||||
|
|
@ -307,6 +320,10 @@ func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *map[string]strin
|
|||
return fmt.Errorf("not a struct: %s", t.Kind().String())
|
||||
}
|
||||
|
||||
if *metadataMap == nil {
|
||||
*metadataMap = MetadataMap{}
|
||||
}
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
currentField := t.Field(i)
|
||||
// fields that are not exported cannot be set via the mapstructure metadata decoding mechanism
|
||||
|
|
@ -318,10 +335,11 @@ func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *map[string]strin
|
|||
if mapStructureTag == "-" {
|
||||
continue
|
||||
}
|
||||
onlyTag := currentField.Tag.Get("only")
|
||||
if onlyTag != "" {
|
||||
|
||||
// If there's a "mdonly" tag, that metadata option is only included for certain component types
|
||||
if mdOnlyTag := currentField.Tag.Get("mdonly"); mdOnlyTag != "" {
|
||||
include := false
|
||||
onlyTags := strings.Split(onlyTag, ",")
|
||||
onlyTags := strings.Split(mdOnlyTag, ",")
|
||||
for _, tag := range onlyTags {
|
||||
if tag == string(componentType) {
|
||||
include = true
|
||||
|
|
@ -332,6 +350,24 @@ func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *map[string]strin
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
mdField := MetadataField{
|
||||
Type: currentField.Type.String(),
|
||||
}
|
||||
|
||||
// If there's a mdignore tag and that's truthy, the field should be ignored by the metadata analyzer
|
||||
mdField.Ignored = utils.IsTruthy(currentField.Tag.Get("mdignore"))
|
||||
|
||||
// If there's a "mddeprecated" tag, the field may be deprecated
|
||||
mdField.Deprecated = utils.IsTruthy(currentField.Tag.Get("mddeprecated"))
|
||||
|
||||
// If there's a "mdaliases" tag, the field contains aliases
|
||||
// The value is a comma-separated string
|
||||
if mdAliasesTag := currentField.Tag.Get("mdaliases"); mdAliasesTag != "" {
|
||||
mdField.Aliases = strings.Split(mdAliasesTag, ",")
|
||||
}
|
||||
|
||||
// Handle mapstructure tags and get the field name
|
||||
mapStructureTags := strings.Split(mapStructureTag, ",")
|
||||
numTags := len(mapStructureTags)
|
||||
if numTags > 1 && mapStructureTags[numTags-1] == "squash" && currentField.Anonymous {
|
||||
|
|
@ -345,7 +381,9 @@ func GetMetadataInfoFromStructType(t reflect.Type, metadataMap *map[string]strin
|
|||
} else {
|
||||
fieldName = currentField.Name
|
||||
}
|
||||
(*metadataMap)[fieldName] = currentField.Type.String()
|
||||
|
||||
// Add the field
|
||||
(*metadataMap)[fieldName] = mdField
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -245,33 +245,61 @@ func TestMetadataStructToStringMap(t *testing.T) {
|
|||
Mybool *bool
|
||||
MyRegularDuration time.Duration
|
||||
SomethingWithCustomName string `mapstructure:"something_with_custom_name"`
|
||||
PubSubOnlyProperty string `mapstructure:"pubsub_only_property" only:"pubsub"`
|
||||
BindingOnlyProperty string `mapstructure:"binding_only_property" only:"bindings"`
|
||||
PubSubAndBindingProperty string `mapstructure:"pubsub_and_binding_property" only:"pubsub,bindings"`
|
||||
PubSubOnlyProperty string `mapstructure:"pubsub_only_property" mdonly:"pubsub"`
|
||||
BindingOnlyProperty string `mapstructure:"binding_only_property" mdonly:"bindings"`
|
||||
PubSubAndBindingProperty string `mapstructure:"pubsub_and_binding_property" mdonly:"pubsub,bindings"`
|
||||
MyDurationArray []time.Duration
|
||||
NotExportedByMapStructure string `mapstructure:"-"`
|
||||
notExported string //nolint:structcheck,unused
|
||||
DeprecatedProperty string `mapstructure:"something_deprecated" mddeprecated:"true"`
|
||||
Aliased string `mapstructure:"aliased" mdaliases:"another,name"`
|
||||
Ignored string `mapstructure:"ignored" mdignore:"true"`
|
||||
}
|
||||
m := testMetadata{}
|
||||
metadatainfo := map[string]string{}
|
||||
metadatainfo := MetadataMap{}
|
||||
GetMetadataInfoFromStructType(reflect.TypeOf(m), &metadatainfo, BindingType)
|
||||
|
||||
assert.Equal(t, "string", metadatainfo["Mystring"])
|
||||
assert.Equal(t, "metadata.Duration", metadatainfo["Myduration"])
|
||||
assert.Equal(t, "int", metadatainfo["Myinteger"])
|
||||
assert.Equal(t, "float64", metadatainfo["Myfloat64"])
|
||||
assert.Equal(t, "*bool", metadatainfo["Mybool"])
|
||||
assert.Equal(t, "time.Duration", metadatainfo["MyRegularDuration"])
|
||||
assert.Equal(t, "string", metadatainfo["something_with_custom_name"])
|
||||
_ = assert.NotEmpty(t, metadatainfo["Mystring"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["Mystring"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["Myduration"]) &&
|
||||
assert.Equal(t, "metadata.Duration", metadatainfo["Myduration"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["Myinteger"]) &&
|
||||
assert.Equal(t, "int", metadatainfo["Myinteger"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["Myfloat64"]) &&
|
||||
assert.Equal(t, "float64", metadatainfo["Myfloat64"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["Mybool"]) &&
|
||||
assert.Equal(t, "*bool", metadatainfo["Mybool"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["MyRegularDuration"]) &&
|
||||
assert.Equal(t, "time.Duration", metadatainfo["MyRegularDuration"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["something_with_custom_name"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["something_with_custom_name"].Type)
|
||||
assert.NotContains(t, metadatainfo, "NestedStruct")
|
||||
assert.NotContains(t, metadatainfo, "SomethingWithCustomName")
|
||||
assert.Equal(t, "string", metadatainfo["nested_string_custom"])
|
||||
assert.Equal(t, "string", metadatainfo["NestedString"])
|
||||
_ = assert.NotEmpty(t, metadatainfo["nested_string_custom"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["nested_string_custom"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["NestedString"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["NestedString"].Type)
|
||||
assert.NotContains(t, metadatainfo, "pubsub_only_property")
|
||||
assert.Equal(t, "string", metadatainfo["binding_only_property"])
|
||||
assert.Equal(t, "string", metadatainfo["pubsub_and_binding_property"])
|
||||
assert.Equal(t, "[]time.Duration", metadatainfo["MyDurationArray"])
|
||||
_ = assert.NotEmpty(t, metadatainfo["binding_only_property"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["binding_only_property"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["pubsub_and_binding_property"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["pubsub_and_binding_property"].Type)
|
||||
_ = assert.NotEmpty(t, metadatainfo["MyDurationArray"]) &&
|
||||
assert.Equal(t, "[]time.Duration", metadatainfo["MyDurationArray"].Type)
|
||||
assert.NotContains(t, metadatainfo, "NotExportedByMapStructure")
|
||||
assert.NotContains(t, metadatainfo, "notExported")
|
||||
_ = assert.NotEmpty(t, metadatainfo["something_deprecated"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["something_deprecated"].Type) &&
|
||||
assert.True(t, metadatainfo["something_deprecated"].Deprecated)
|
||||
_ = assert.NotEmpty(t, metadatainfo["aliased"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["aliased"].Type) &&
|
||||
assert.False(t, metadatainfo["aliased"].Deprecated) &&
|
||||
assert.False(t, metadatainfo["aliased"].Ignored) &&
|
||||
assert.Equal(t, []string{"another", "name"}, metadatainfo["aliased"].Aliases)
|
||||
_ = assert.NotEmpty(t, metadatainfo["ignored"]) &&
|
||||
assert.Equal(t, "string", metadatainfo["ignored"].Type) &&
|
||||
assert.False(t, metadatainfo["ignored"].Deprecated) &&
|
||||
assert.True(t, metadatainfo["ignored"].Ignored) &&
|
||||
assert.Empty(t, metadatainfo["ignored"].Aliases)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,9 +126,8 @@ func (m *Middleware) GetHandler(ctx context.Context, metadata middleware.Metadat
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := bearerMiddlewareMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,9 +155,8 @@ func (m *Middleware) getNativeMetadata(metadata middleware.Metadata) (*oAuth2Mid
|
|||
return &middlewareMetadata, nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo mdutils.MetadataMap) {
|
||||
metadataStruct := oAuth2MiddlewareMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
mdutils.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, mdutils.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,9 +178,8 @@ func (m *Middleware) GetToken(ctx context.Context, conf *clientcredentials.Confi
|
|||
return tokenSource.Token()
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo mdutils.MetadataMap) {
|
||||
metadataStruct := oAuth2ClientCredentialsMiddlewareMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
mdutils.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, mdutils.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,9 +260,8 @@ func (m *Middleware) getNativeMetadata(metadata middleware.Metadata) (*middlewar
|
|||
return &meta, nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := middlewareMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,9 +101,8 @@ func (m *Middleware) getNativeMetadata(metadata middleware.Metadata) (*rateLimit
|
|||
return &middlewareMetadata, nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := rateLimitMiddlewareMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
|
@ -118,6 +119,10 @@ func vars(r *http.Request) map[string]string {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
return map[string]string{}
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo mdutils.MetadataMap) {
|
||||
metadataStruct := struct {
|
||||
Routes string `mapstructure:"routes"`
|
||||
}{}
|
||||
mdutils.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, mdutils.MiddlewareType)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,8 @@ func (m *Middleware) getNativeMetadata(metadata middleware.Metadata) (*Metadata,
|
|||
return &middlewareMetadata, nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo mdutils.MetadataMap) {
|
||||
metadataStruct := Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
mdutils.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, mdutils.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,9 +157,8 @@ func getNativeMetadata(metadata middleware.Metadata) (*middlewareMetadata, error
|
|||
return &md, nil
|
||||
}
|
||||
|
||||
func (m *Middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *Middleware) GetComponentMetadata() (metadataInfo mdutils.MetadataMap) {
|
||||
metadataStruct := middlewareMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
mdutils.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, mdutils.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,9 +121,8 @@ func (rh *requestHandler) Close() error {
|
|||
return rh.mw.Close(ctx)
|
||||
}
|
||||
|
||||
func (m *middleware) GetComponentMetadata() map[string]string {
|
||||
func (m *middleware) GetComponentMetadata() (metadataInfo mdutils.MetadataMap) {
|
||||
metadataStruct := wasm.InitMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
mdutils.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, mdutils.MiddlewareType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,4 @@ import (
|
|||
// Middleware is the interface for a middleware.
|
||||
type Middleware interface {
|
||||
GetHandler(ctx context.Context, metadata Metadata) (func(next http.Handler) http.Handler, error)
|
||||
GetComponentMetadata() map[string]string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -931,9 +931,8 @@ func (s *snsSqs) Features() []pubsub.Feature {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (s *snsSqs) GetComponentMetadata() map[string]string {
|
||||
func (s *snsSqs) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := snsSqsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.PubSubType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,9 +147,8 @@ func (aeh *AzureEventHubs) Close() (err error) {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (aeh *AzureEventHubs) GetComponentMetadata() map[string]string {
|
||||
func (aeh *AzureEventHubs) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := impl.AzureEventHubsMetadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.PubSubType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,10 +227,9 @@ func (a *azureServiceBus) Features() []pubsub.Feature {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *azureServiceBus) GetComponentMetadata() map[string]string {
|
||||
func (a *azureServiceBus) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := impl.Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.PubSubType)
|
||||
delete(metadataInfo, "consumerID") // does not apply to queues
|
||||
return metadataInfo
|
||||
delete(metadataInfo, "consumerID") // only applies to topics, not queues
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,9 +317,8 @@ func (a *azureServiceBus) connectAndReceiveWithSessions(ctx context.Context, req
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (a *azureServiceBus) GetComponentMetadata() map[string]string {
|
||||
func (a *azureServiceBus) GetComponentMetadata() (metadataInfo metadata.MetadataMap) {
|
||||
metadataStruct := impl.Metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
metadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, metadata.PubSubType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,9 +402,8 @@ func (g *GCPPubSub) Features() []pubsub.Feature {
|
|||
}
|
||||
|
||||
// GetComponentMetadata returns the metadata of the component.
|
||||
func (g *GCPPubSub) GetComponentMetadata() map[string]string {
|
||||
func (g *GCPPubSub) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMap) {
|
||||
metadataStruct := metadata{}
|
||||
metadataInfo := map[string]string{}
|
||||
contribMetadata.GetMetadataInfoFromStructType(reflect.TypeOf(metadataStruct), &metadataInfo, contribMetadata.PubSubType)
|
||||
return metadataInfo
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue