# Couchbase Vault database plugin

**URL:** <https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883>\
**Category:** Vault\
**Created:** [May 18, 2020, 11:30pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883 "2020-05-18T23:30:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![fhitchen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fhitchen/32/6995_2.png) [@fhitchen](https://discuss.hashicorp.com/u/fhitchen)\
**Post date:** [May 18, 2020, 11:30pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/1 "2020-05-18T23:30:01Z")

</div>

Hi,  
I have written a database plugin for Couchbase DB. It supports credential rotation and dynamic and static roles. Would anyone in the Vault engineering team be interested in taking a look at it to see what could be improved?  
Regards, Francis.

---

<div class="post-metadata">

**Author:** ![ncabatoff](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ncabatoff/32/818_2.png) [@ncabatoff](https://discuss.hashicorp.com/u/ncabatoff)\
**Post date:** [May 19, 2020, 12:02pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/2 "2020-05-19T12:02:38Z")

</div>

Hi @fhitchen,

Yes, please open a PR and we’ll have a look.

Best,  
Nick

---

<div class="post-metadata">

**Author:** ![fhitchen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fhitchen/32/6995_2.png) [@fhitchen](https://discuss.hashicorp.com/u/fhitchen)\
**Post date:** [May 26, 2020, 3:07pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/3 "2020-05-26T15:07:58Z")

</div>

Hi, I am having problems getting my PR past circleci compilation. I need a couchbase package which normally you pull with

go get [github.com/couchbase/gocb/v2](http://github.com/couchbase/gocb/v2)

Any pointers how to add this to the build? I added the module to the toplevel go.mod but to no avail.

regards, Francis.

---

<div class="post-metadata">

**Author:** ![ncabatoff](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ncabatoff/32/818_2.png) [@ncabatoff](https://discuss.hashicorp.com/u/ncabatoff)\
**Post date:** [May 26, 2020, 3:21pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/4 "2020-05-26T15:21:17Z")

</div>

What happens when you run the `go get` command you listed? That should be the correct way to update go.mod and go.sum.

---

<div class="post-metadata">

**Author:** ![fhitchen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fhitchen/32/6995_2.png) [@fhitchen](https://discuss.hashicorp.com/u/fhitchen)\
**Post date:** [May 26, 2020, 4:09pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/5 "2020-05-26T16:09:07Z")

</div>

Works fine, but how do I add that to the circleci build scripts…

I see this in the go.mod I checked in.

```
github.com/couchbase/gocb/v2 v2.1.1 // indirect
```

---

<div class="post-metadata">

**Author:** ![ncabatoff](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ncabatoff/32/818_2.png) [@ncabatoff](https://discuss.hashicorp.com/u/ncabatoff)\
**Post date:** [May 26, 2020, 5:28pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/6 "2020-05-26T17:28:01Z")

</div>

Why would the circleci build config need to be updated? I should’ve mentioned that you need to `go mod vendor` for the CI to build, maybe that’s what you’re seeing?

---

<div class="post-metadata">

**Author:** ![fhitchen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fhitchen/32/6995_2.png) [@fhitchen](https://discuss.hashicorp.com/u/fhitchen)\
**Post date:** [May 26, 2020, 10:03pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/7 "2020-05-26T22:03:22Z")

</div>

Thanks that tip helped.

I managed to get the go mod vendor command to add the couchbase client code to the vendor path and the build succeeded.

Now I guess I have to figure out how to spin up a couchbase DB container, initialize it and get it ready to accept the tests I have defined.

I hope it won’t be beyond me. I have a test db image already that contains test accounts and data buckets to grant access to, [docker.io/fhitchen/vault-couchbase](http://docker.io/fhitchen/vault-couchbase), no reason why I can’t pull that is there?

---

<div class="post-metadata">

**Author:** ![ncabatoff](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ncabatoff/32/818_2.png) [@ncabatoff](https://discuss.hashicorp.com/u/ncabatoff)\
**Post date:** [May 27, 2020, 12:20pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/8 "2020-05-27T12:20:06Z")

</div>

Here’s what we’re doing to test the physical storage backend currently: [https://github.com/hashicorp/vault/blob/master/physical/couchdb/couchdb\_test.go#L57](https://github.com/hashicorp/vault/blob/master/physical/couchdb/couchdb_test.go#L57)

Ideally they would share the same code, i.e. move prepareCouchdbDBTestContainer from that package to a new package helper/testhelpers/couchdb and make it public. Similar to what we do with ldap, consul, mysql, etc. You can see an example of what that might look like in my PR here: [https://github.com/hashicorp/vault/pull/8948/files](https://github.com/hashicorp/vault/pull/8948/files)

We’d prefer to use standard upstream images where possible, rather than someone’s personal image that might not be updated as often.

---

<div class="post-metadata">

**Author:** ![fhitchen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fhitchen/32/6995_2.png) [@fhitchen](https://discuss.hashicorp.com/u/fhitchen)\
**Post date:** [May 27, 2020, 10:00pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/9 "2020-05-27T22:00:41Z")

</div>

I have modified what was done for cassandra, couchbase requires many more ports to be mapped for plain text and TLS communications though. I am still using a custom docker image as the out of the box one from couchbase requires configuration steps to create an administrator account as well as selecting a subset of the services (most are not needed and will just waste resources) and a test data bucket to test creating accounts that can access that bucket. I will see if there is a way to package all of that and automate creation of the test couchbase db. Don’t really want to waste more time doing a docker build though?

---

<div class="post-metadata">

**Author:** ![fhitchen](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/fhitchen/32/6995_2.png) [@fhitchen](https://discuss.hashicorp.com/u/fhitchen)\
**Post date:** [May 27, 2020, 10:36pm UTC](https://discuss.hashicorp.com/t/couchbase-vault-database-plugin/8883/10 "2020-05-27T22:36:16Z")

</div>

The database init test passed…

PASS physical/raft.TestRaft\_Snapshot\_Restart (2.48s)  
PASS physical/raft.TestRaft\_Snapshot\_ErrorRecovery (7.82s)  
**PASS plugins/database/couchbase.TestCouchbaseDB\_Initialize (62.27s)**  
PASS plugins/database/couchbase  
PASS plugins/database/hana  
PASS plugins/database/influxdb

but the test-go-race step failed on something that I do not think is related to my changes…

=== FAIL: helper/testhelpers/teststorage TestReusableStorage/raft (59.32s)  
=== PAUSE TestReusableStorage/raft  
=== CONT TestReusableStorage/raft  
— FAIL: TestReusableStorage/raft (59.32s)  
teststorage\_reusable.go:119: raft dir: /tmp/vault-raft-005687069  
teststorage\_reusable.go:119: raft dir: /tmp/vault-raft-217546200  
teststorage\_reusable.go:119: raft dir: /tmp/vault-raft-157801303  
teststorage\_reusable.go:119: raft dir: /tmp/vault-raft-581860042  
teststorage\_reusable.go:119: raft dir: /tmp/vault-raft-014599585  
teststorage\_reusable\_test.go:183: Get [https://127.0.0.1:54003/v1/secret/foo:](https://127.0.0.1:54003/v1/secret/foo:) redirects not allowed in these tests  
=== FAIL: helper/testhelpers/teststorage TestReusableStorage (0.00s)

Please advise. What should I do next.?
