Skip to content

Commit 615e860

Browse files
authored
feat: merge scw and env profiles (#4)
1 parent 4313c28 commit 615e860

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ The official documentation is available at https://developers.google.com/tink.
1111
2. Check the [example](./integration/scwkms/scw_kms_client_test.go) to use the
1212
extension. Make sure to replace the client fields with your own
1313
configuration.
14+
3. Rather than configuring the provider in-app, you can also use Scaleway's
15+
configuration file and environment variables. Check [Scaleway's configuration
16+
documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md)
17+
for more details.

integration/scwkms/scw_kms_client.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@ type scwClient struct {
2727
var _ registry.KMSClient = (*scwClient)(nil)
2828

2929
func NewClient(uriPrefix string) (registry.KMSClient, error) {
30-
return NewClientWithOptions(uriPrefix, scw.WithEnv())
30+
config, err := scw.LoadConfig()
31+
if err != nil {
32+
return nil, err
33+
}
34+
35+
activeProfile, err := config.GetActiveProfile()
36+
if err != nil {
37+
return nil, err
38+
}
39+
40+
return NewClientWithOptions(
41+
uriPrefix,
42+
scw.WithProfile(activeProfile),
43+
scw.WithEnv(),
44+
)
3145
}
3246

3347
func NewClientWithOptions(uriPrefix string, opts ...scw.ClientOption) (registry.KMSClient, error) {

0 commit comments

Comments
 (0)