Skip to content

Commit

Permalink
Merge branch 'master' into update-deps-jul23-2
Browse files Browse the repository at this point in the history
Signed-off-by: Bernd Verst <[email protected]>
  • Loading branch information
berndverst authored Jul 18, 2023
2 parents c8d2c1e + ec05809 commit a770699
Show file tree
Hide file tree
Showing 153 changed files with 754 additions and 689 deletions.
97 changes: 97 additions & 0 deletions .build-tools/builtin-authentication-profiles.yaml
Original file line number Diff line number Diff line change
@@ -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
46 changes: 0 additions & 46 deletions .build-tools/component-folders.json

This file was deleted.

43 changes: 43 additions & 0 deletions .build-tools/component-folders.yaml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 23 additions & 12 deletions .build-tools/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
33 changes: 18 additions & 15 deletions .build-tools/pkg/metadataanalyzer/analyzer.template
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit a770699

Please sign in to comment.