Skip to content

Commit

Permalink
1.13 Cherry-pick: Fix Azure App Config not working with gRPC (#3358) (#…
Browse files Browse the repository at this point in the history
…3359)

Signed-off-by: Bernd Verst <[email protected]>
  • Loading branch information
berndverst authored Feb 21, 2024
1 parent cda5cac commit 10ff04b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions configuration/azure/appconfig/appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
"github.com/dapr/components-contrib/configuration"
contribMetadata "github.com/dapr/components-contrib/metadata"

kitmd "github.com/dapr/kit/metadata"

"github.com/dapr/kit/logger"
)

Expand Down Expand Up @@ -201,8 +203,14 @@ func (r *ConfigurationStore) getAll(ctx context.Context, req *configuration.GetR
}

func (r *ConfigurationStore) getLabelFromMetadata(metadata map[string]string) *string {
if s, ok := metadata["label"]; ok && s != "" {
return to.Ptr(s)
type labelMetadata = struct {
Label string `mapstructure:"label"`
}
var label labelMetadata
kitmd.DecodeMetadata(metadata, &label)

if label.Label != "" {
return to.Ptr(label.Label)
}

return nil
Expand Down Expand Up @@ -284,9 +292,16 @@ func (r *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler
}

func (r *ConfigurationStore) getSentinelKeyFromMetadata(metadata map[string]string) string {
if s, ok := metadata["sentinelKey"]; ok && s != "" {
return s
type sentinelKeyMetadata = struct {
SentinelKey string `mapstructure:"sentinelKey"`
}
var sentinelKey sentinelKeyMetadata
kitmd.DecodeMetadata(metadata, &sentinelKey)

if sentinelKey.SentinelKey != "" {
return sentinelKey.SentinelKey
}

return ""
}

Expand Down
2 changes: 1 addition & 1 deletion configuration/azure/appconfig/appconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func Test_subscribeConfigurationWithProvidedKeys(t *testing.T) {
s.client = &MockConfigurationStore{}

metadata := make(map[string]string)
metadata["sentinelKey"] = "test_sentinel_key"
metadata["sentinelkey"] = "test_sentinel_key"

t.Run("call subscribe with sentinel key", func(t *testing.T) {
req := configuration.SubscribeRequest{
Expand Down

0 comments on commit 10ff04b

Please sign in to comment.