From 34d4a1880e48014218fd47a0a9f901692b37dfaf Mon Sep 17 00:00:00 2001 From: Tomasz Sadura Date: Tue, 19 Nov 2024 17:01:16 +0100 Subject: [PATCH 1/3] Update common-go with updates to reading secrets from Azure key vault --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7075e62593..d64fac5cae 100644 --- a/go.mod +++ b/go.mod @@ -106,7 +106,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/redis/go-redis/v9 v9.7.0 github.com/redpanda-data/benthos/v4 v4.40.0 - github.com/redpanda-data/common-go/secrets v0.1.1-0.20241114080637-188c28cdde96 + github.com/redpanda-data/common-go/secrets v0.1.1 github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0 github.com/rs/xid v1.5.0 github.com/sashabaranov/go-openai v1.28.3 diff --git a/go.sum b/go.sum index 953bc9f78b..5a54969276 100644 --- a/go.sum +++ b/go.sum @@ -1048,8 +1048,8 @@ github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/redpanda-data/benthos/v4 v4.40.0 h1:/6h8BYALrqzvAKo3RsVdscIdypj08NwfAMgcvX5/+uY= github.com/redpanda-data/benthos/v4 v4.40.0/go.mod h1:A5izknIGyzs16rCU0qliFVgdCLn2yyvLM4Hltx+s+TI= -github.com/redpanda-data/common-go/secrets v0.1.1-0.20241114080637-188c28cdde96 h1:Ce4Zk9yLvcWmQHD6HQiBqsb/FFwWWFRA570KCEpFzwE= -github.com/redpanda-data/common-go/secrets v0.1.1-0.20241114080637-188c28cdde96/go.mod h1:WjaDI39reE/GPRPHTsaYmiMjhHj+qsSJLe+kHsPKsXk= +github.com/redpanda-data/common-go/secrets v0.1.1 h1:7ZfeTcR/T6YZ/SkCaa5uYG3f5nz9rdjZ/87q0EiPpOk= +github.com/redpanda-data/common-go/secrets v0.1.1/go.mod h1:WjaDI39reE/GPRPHTsaYmiMjhHj+qsSJLe+kHsPKsXk= github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0 h1:Qiz4Q8ZO17n8797hgDdJ2f1XN7wh6J2hIRgeeSw4F24= github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0/go.mod h1:ISgO+/kuuSW0Z7sJo1rWe/rYKIv1rDPHTQ/bSLQEog0= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= From 8349a5bbf281392649369578a2ae6ccbc2dd0467 Mon Sep 17 00:00:00 2001 From: Tomasz Sadura Date: Wed, 20 Nov 2024 13:21:15 +0100 Subject: [PATCH 2/3] Update common-go with support for trimPrefix param --- go.mod | 2 +- go.sum | 4 ++-- internal/secrets/secrets.go | 12 +++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index d64fac5cae..2409f01bcc 100644 --- a/go.mod +++ b/go.mod @@ -106,7 +106,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/redis/go-redis/v9 v9.7.0 github.com/redpanda-data/benthos/v4 v4.40.0 - github.com/redpanda-data/common-go/secrets v0.1.1 + github.com/redpanda-data/common-go/secrets v0.1.2 github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0 github.com/rs/xid v1.5.0 github.com/sashabaranov/go-openai v1.28.3 diff --git a/go.sum b/go.sum index 5a54969276..0a09d7e9d3 100644 --- a/go.sum +++ b/go.sum @@ -1048,8 +1048,8 @@ github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/redpanda-data/benthos/v4 v4.40.0 h1:/6h8BYALrqzvAKo3RsVdscIdypj08NwfAMgcvX5/+uY= github.com/redpanda-data/benthos/v4 v4.40.0/go.mod h1:A5izknIGyzs16rCU0qliFVgdCLn2yyvLM4Hltx+s+TI= -github.com/redpanda-data/common-go/secrets v0.1.1 h1:7ZfeTcR/T6YZ/SkCaa5uYG3f5nz9rdjZ/87q0EiPpOk= -github.com/redpanda-data/common-go/secrets v0.1.1/go.mod h1:WjaDI39reE/GPRPHTsaYmiMjhHj+qsSJLe+kHsPKsXk= +github.com/redpanda-data/common-go/secrets v0.1.2 h1:UCDLN/yL8yjSIYhS5MB+2Am1Jy4XZMZPtuuCRL/82Rw= +github.com/redpanda-data/common-go/secrets v0.1.2/go.mod h1:WjaDI39reE/GPRPHTsaYmiMjhHj+qsSJLe+kHsPKsXk= github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0 h1:Qiz4Q8ZO17n8797hgDdJ2f1XN7wh6J2hIRgeeSw4F24= github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0/go.mod h1:ISgO+/kuuSW0Z7sJo1rWe/rYKIv1rDPHTQ/bSLQEog0= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= diff --git a/internal/secrets/secrets.go b/internal/secrets/secrets.go index 91f877b0b0..19f93e8a7b 100644 --- a/internal/secrets/secrets.go +++ b/internal/secrets/secrets.go @@ -19,6 +19,8 @@ import ( "github.com/redpanda-data/common-go/secrets" ) +const trimPrefixParam = "trimPrefix" + // LookupFn defines the common closure that a secrets management client provides // and is then fed into a Redpanda Connect cli constructor. type LookupFn func(context.Context, string) (string, bool) @@ -82,19 +84,19 @@ func parseSecretsLookupURN(ctx context.Context, logger *slog.Logger, urn string) if err != nil { return nil, err } - return lookupFn(secrets.NewSecretProvider, secretsManager, path) + return lookupFn(secrets.NewSecretProvider, secretsManager, path, u.Query().Get(trimPrefixParam)) case "gcp": secretsManager, err := secrets.NewGCPSecretsManager(ctx, logger, u.Host) if err != nil { return nil, err } - return lookupFn(secrets.NewSecretProvider, secretsManager, path) + return lookupFn(secrets.NewSecretProvider, secretsManager, path, u.Query().Get(trimPrefixParam)) case "az": secretsManager, err := secrets.NewAzSecretsManager(logger, "https://"+u.Host) if err != nil { return nil, err } - return lookupFn(secrets.NewSecretProvider, secretsManager, path) + return lookupFn(secrets.NewSecretProvider, secretsManager, path, u.Query().Get(trimPrefixParam)) case "none": return func(ctx context.Context, key string) (string, bool) { return "", false @@ -104,8 +106,8 @@ func parseSecretsLookupURN(ctx context.Context, logger *slog.Logger, urn string) } } -func lookupFn(providerFn secrets.SecretProviderFn, secretsManager secrets.SecretAPI, prefix string) (LookupFn, error) { - provider, err := providerFn(secretsManager, prefix) +func lookupFn(providerFn secrets.SecretProviderFn, secretsManager secrets.SecretAPI, prefix string, trimPrefix string) (LookupFn, error) { + provider, err := providerFn(secretsManager, prefix, trimPrefix) if err != nil { return nil, err } From 959dad37bf5e0ea3138e3a24886f90c5ec9e6b27 Mon Sep 17 00:00:00 2001 From: Ashley Jeffs Date: Thu, 21 Nov 2024 10:35:50 +0000 Subject: [PATCH 3/3] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f5de85a592..0d9351bf42 100644 --- a/go.mod +++ b/go.mod @@ -106,7 +106,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/redis/go-redis/v9 v9.7.0 github.com/redpanda-data/benthos/v4 v4.41.0 - github.com/redpanda-data/common-go/secrets v0.1.2 + github.com/redpanda-data/common-go/secrets v0.1.2 github.com/redpanda-data/connect/public/bundle/free/v4 v4.31.0 github.com/rs/xid v1.5.0 github.com/sashabaranov/go-openai v1.28.3