Skip to content

Commit

Permalink
feat: merge scw and env profiles (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojroques authored Jun 4, 2024
1 parent 4313c28 commit 615e860
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ The official documentation is available at https://developers.google.com/tink.
2. Check the [example](./integration/scwkms/scw_kms_client_test.go) to use the
extension. Make sure to replace the client fields with your own
configuration.
3. Rather than configuring the provider in-app, you can also use Scaleway's
configuration file and environment variables. Check [Scaleway's configuration
documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md)
for more details.
16 changes: 15 additions & 1 deletion integration/scwkms/scw_kms_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,21 @@ type scwClient struct {
var _ registry.KMSClient = (*scwClient)(nil)

func NewClient(uriPrefix string) (registry.KMSClient, error) {
return NewClientWithOptions(uriPrefix, scw.WithEnv())
config, err := scw.LoadConfig()
if err != nil {
return nil, err
}

activeProfile, err := config.GetActiveProfile()
if err != nil {
return nil, err
}

return NewClientWithOptions(
uriPrefix,
scw.WithProfile(activeProfile),
scw.WithEnv(),
)
}

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

0 comments on commit 615e860

Please sign in to comment.