diff --git a/go.mod b/go.mod index 3312b1be24..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.1-0.20241114080637-188c28cdde96 + 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 b2b8bcc7ef..609867a530 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.41.0 h1:hntAcrgZBmhUOx6kh7ZxnhaBfhFzEEacdv2oaaY7co4= github.com/redpanda-data/benthos/v4 v4.41.0/go.mod h1:T5Nb0hH1Sa1ChlH4hLW7+nA1+jQ/3CP/cVFI73z6ZIM= -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.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 }