From 7138185fbbaecb43bbe8d3da0cecbbb113a6b5c2 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Thu, 31 Mar 2022 14:17:54 +0200 Subject: [PATCH] keyservice: accept KeyServiceServer in LocalClient This allows for easier injection of your own (local) key service server implementation, in situations where e.g. you do not want to rely on environment variables or other runtime defaults. It is not of impact to end-users, but improves the experience of developers making use of SOPS as an SDK to e.g. provide decryption services to users. As they will now in many cases end up copying this bit of code to make this precise change. Signed-off-by: Hidde Beydals --- keyservice/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keyservice/client.go b/keyservice/client.go index 8fa6cb7b9..f0a29fd06 100644 --- a/keyservice/client.go +++ b/keyservice/client.go @@ -8,7 +8,7 @@ import ( // LocalClient is a key service client that performs all operations locally type LocalClient struct { - Server Server + Server KeyServiceServer } // NewLocalClient creates a new local client @@ -16,6 +16,12 @@ func NewLocalClient() LocalClient { return LocalClient{Server{}} } +// NewCustomLocalClient creates a new local client with a non-default backing +// KeyServiceServer implementation +func NewCustomLocalClient(server KeyServiceServer) LocalClient { + return LocalClient{Server: server} +} + // Decrypt processes a decrypt request locally // See keyservice/server.go for more details func (c LocalClient) Decrypt(ctx context.Context,