Skip to content

Commit

Permalink
keyservice: accept KeyServiceServer in LocalClient
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
hiddeco committed Mar 31, 2022
1 parent 268b5ff commit 7138185
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion keyservice/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ 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
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,
Expand Down

0 comments on commit 7138185

Please sign in to comment.