Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ibmsm): Support v2 API and KV secret types #513

Merged
merged 4 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(ibmsm): Look for data races
  • Loading branch information
jkayani committed May 25, 2023
commit 9186ef9def927412199ba611d58201abe63123ab
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# golang:1.17-alpine
FROM golang@sha256:f4ece20984a30d1065b04653bf6781f51ab63421b4b8f011565de0401cfe58d7

RUN apk add make git
FROM index.docker.io/golang:1.17@sha256:55636cf1983628109e569690596b85077f45aca810a77904e8afad48b49aa500

ADD go.mod go.mod
ADD go.sum go.sum

ENV GOPATH=""
ENV CGO_ENABLED=0
RUN go mod download

VOLUME work
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default: build

quality:
go vet github.com/argoproj-labs/argocd-vault-plugin
go test -v -coverprofile cover.out ./...
go test -race -v -coverprofile cover.out ./...

build:
go build -o ${BINARY} .
Expand Down
10 changes: 10 additions & 0 deletions pkg/backends/ibmsecretsmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"reflect"
"strings"
"testing"
"sync"

"github.com/IBM/go-sdk-core/v5/core"
ibmsm "github.com/IBM/secrets-manager-go-sdk/secretsmanagerv2"
Expand All @@ -14,6 +15,11 @@ import (

type MockIBMSMClient struct {
ListSecretsOptionCalledWith []*ibmsm.ListSecretsOptions

// GetSecretLock prevents false data races caused by unsychronized access to the mock state
// It is shared b/w both GetSecret and GetSecretVersion for simplicity, even though each writes to a different field
GetSecretLock sync.RWMutex

GetSecretCalledWith *ibmsm.GetSecretOptions
GetSecretCallCount int
GetSecretVersionCalledWith *ibmsm.GetSecretVersionOptions
Expand Down Expand Up @@ -112,8 +118,10 @@ func (m *MockIBMSMClient) ListSecrets(listAllSecretsOptions *ibmsm.ListSecretsOp
}

func (m *MockIBMSMClient) GetSecret(getSecretOptions *ibmsm.GetSecretOptions) (result ibmsm.SecretIntf, response *core.DetailedResponse, err error) {
m.GetSecretLock.Lock()
m.GetSecretCalledWith = getSecretOptions
m.GetSecretCallCount += 1
m.GetSecretLock.Unlock()

if *getSecretOptions.ID == "arbitrary" {
name := "my-secret"
Expand Down Expand Up @@ -148,8 +156,10 @@ func (m *MockIBMSMClient) GetSecret(getSecretOptions *ibmsm.GetSecretOptions) (r
}

func (m *MockIBMSMClient) GetSecretVersion(getSecretOptions *ibmsm.GetSecretVersionOptions) (result ibmsm.SecretVersionIntf, response *core.DetailedResponse, err error) {
m.GetSecretLock.Lock()
m.GetSecretVersionCalledWith = getSecretOptions
m.GetSecretVersionCallCount += 1
m.GetSecretLock.Unlock()
data := "dummy"
id := "public_cert"
yes := true
Expand Down