Skip to content

Commit 5e6802a

Browse files
authored
Upgrade Vault sdk and use plugin multiplex (#26)
Signed-off-by: Benoit Pourre <[email protected]>
1 parent 12a2456 commit 5e6802a

File tree

7 files changed

+1938
-25
lines changed

7 files changed

+1938
-25
lines changed

cmd/vault-plugin-secrets-ibmcloud/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
tlsConfig := apiClientMeta.GetTLSConfig()
1818
tlsProviderFunc := api.VaultPluginTLSProvider(tlsConfig)
1919

20-
if err := plugin.Serve(&plugin.ServeOpts{
20+
if err := plugin.ServeMultiplex(&plugin.ServeOpts{
2121
BackendFactoryFunc: ibmcloud.Factory,
2222
TLSProviderFunc: tlsProviderFunc,
2323
}); err != nil {

constants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const (
55
openIDIssuer = "https://iam.cloud.ibm.com/identity"
66
)
77

8-
//Number of minutes to renew the admin token before expiration
8+
// Number of minutes to renew the admin token before expiration
99
const (
1010
adminTokenRenewBeforeExpirationMinutes = 5
1111
maxGroupsPerRole = 10

go.mod

+3-12
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,25 @@ module vault-plugin-secrets-ibmcloud
33
go 1.16
44

55
require (
6-
github.com/armon/go-metrics v0.4.0 // indirect
76
github.com/aws/aws-sdk-go v1.44.66 // indirect
87
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
98
github.com/coreos/go-oidc/v3 v3.2.0
109
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
1110
github.com/golang/mock v1.6.0
1211
github.com/hashicorp/errwrap v1.1.0
1312
github.com/hashicorp/go-cleanhttp v0.5.2
14-
github.com/hashicorp/go-hclog v1.2.2
15-
github.com/hashicorp/go-plugin v1.4.4 // indirect
13+
github.com/hashicorp/go-hclog v1.4.0
1614
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
1715
github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 // indirect
1816
github.com/hashicorp/go-uuid v1.0.3 // indirect
1917
github.com/hashicorp/go-version v1.6.0 // indirect
20-
github.com/hashicorp/vault/api v1.7.2
21-
github.com/hashicorp/vault/sdk v0.5.3
18+
github.com/hashicorp/vault/api v1.9.2
19+
github.com/hashicorp/vault/sdk v0.9.2
2220
github.com/hashicorp/yamux v0.1.1 // indirect
2321
github.com/mitchellh/copystructure v1.2.0 // indirect
2422
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
2523
github.com/oklog/run v1.1.0 // indirect
2624
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
27-
github.com/stretchr/testify v1.8.0 // indirect
28-
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
29-
golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 // indirect
30-
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c // indirect
31-
golang.org/x/sys v0.0.0-20220731174439-a90be440212d // indirect
32-
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
33-
google.golang.org/genproto v0.0.0-20220728213248-dd149ef739b9 // indirect
3425
google.golang.org/protobuf v1.28.1 // indirect
3526
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
3627
)

go.sum

+1,920
Large diffs are not rendered by default.

iam_helper.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ func (h *ibmCloudHelper) getProvider() *oidc.Provider {
141141
return provider
142142
}
143143

144-
/**
144+
/*
145+
*
145146
Obtain an IAM token by way of an API Key
146147
*/
147148
func (h *ibmCloudHelper) ObtainToken(apiKey string) (string, error) {
@@ -174,7 +175,8 @@ func (h *ibmCloudHelper) ObtainToken(apiKey string) (string, error) {
174175
return result["access_token"].(string), nil
175176
}
176177

177-
/**
178+
/*
179+
*
178180
Verifies an IBM Cloud IAM token. If successful, it will return a tokenInfo
179181
with relevant items contained in the token.
180182
*/

path_creds_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ func TestStaticServiceIDDeleted(t *testing.T) {
119119
}
120120

121121
/*
122-
Tests a successful Get (read) of a credential and validates the returned Secret.
123-
The internalData parameter is used to pass in key-values that differ between static and dynamic service ID credentials.
124-
If the ttl and maxTTL values are greater than 0 they will be used to check the Secret's lease.
122+
Tests a successful Get (read) of a credential and validates the returned Secret.
123+
The internalData parameter is used to pass in key-values that differ between static and dynamic service ID credentials.
124+
If the ttl and maxTTL values are greater than 0 they will be used to check the Secret's lease.
125125
*/
126126
func testSuccessfulGet(t *testing.T, b *ibmCloudSecretBackend, s logical.Storage, internalData map[string]string, ttl, maxTTL int) *logical.Secret {
127127
t.Helper()

path_roles_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func TestNoConfig(t *testing.T) {
250250
[]string{"no API key was set in the configuration"})
251251
}
252252

253-
//-- Utils --
253+
// -- Utils --
254254
func testRoleCreate(tb testing.TB, b logical.Backend, s logical.Storage, d map[string]interface{}) {
255255
tb.Helper()
256256

@@ -411,12 +411,12 @@ func testRole(tb testing.TB) string {
411411
}
412412

413413
/*
414-
This function configures the mock iamHelper expectations for the test. It then creates a test Backend with
415-
with the mock, and configures it.
414+
This function configures the mock iamHelper expectations for the test. It then creates a test Backend with
415+
with the mock, and configures it.
416416
417-
The minCalls map is used to control the minimum number of times the functions of the iamHelper interface are
418-
expected to be called. The keys are the function names (e.g. "ObtainToken", "VerifyAccessGroupExists", etc).
419-
If unspecified 0 is used.
417+
The minCalls map is used to control the minimum number of times the functions of the iamHelper interface are
418+
expected to be called. The keys are the function names (e.g. "ObtainToken", "VerifyAccessGroupExists", etc).
419+
If unspecified 0 is used.
420420
*/
421421
func getMockedBackend(t *testing.T, ctrl *gomock.Controller, minCalls map[string]int) (*ibmCloudSecretBackend, logical.Storage) {
422422
t.Helper()

0 commit comments

Comments
 (0)