Skip to content

Commit 7138185

Browse files
committed
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 <[email protected]>
1 parent 268b5ff commit 7138185

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

keyservice/client.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ import (
88

99
// LocalClient is a key service client that performs all operations locally
1010
type LocalClient struct {
11-
Server Server
11+
Server KeyServiceServer
1212
}
1313

1414
// NewLocalClient creates a new local client
1515
func NewLocalClient() LocalClient {
1616
return LocalClient{Server{}}
1717
}
1818

19+
// NewCustomLocalClient creates a new local client with a non-default backing
20+
// KeyServiceServer implementation
21+
func NewCustomLocalClient(server KeyServiceServer) LocalClient {
22+
return LocalClient{Server: server}
23+
}
24+
1925
// Decrypt processes a decrypt request locally
2026
// See keyservice/server.go for more details
2127
func (c LocalClient) Decrypt(ctx context.Context,

0 commit comments

Comments
 (0)