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

feat: add Vault Module #942

Merged
merged 47 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
754c792
create couchbase module
alihanyalcin Feb 17, 2023
46ef6c7
expose enabled service ports
alihanyalcin Feb 17, 2023
5b355b5
add wait until all nodes are healthy
alihanyalcin Feb 17, 2023
953572f
add cluster initialization functions
alihanyalcin Feb 21, 2023
a6b2493
refactor enabledServices for loop with contains method
alihanyalcin Feb 21, 2023
9263849
add configureExternalPorts
alihanyalcin Feb 21, 2023
d5b4f15
refactor doHttpRequest to create new request with context
alihanyalcin Feb 21, 2023
0e43367
add create buckets
alihanyalcin Feb 21, 2023
c8b3714
complete create bucket flow
alihanyalcin Feb 22, 2023
b78012c
add docker image name to config
alihanyalcin Feb 22, 2023
becc912
fix port suffix, mapped port, enabled services and refactor checkAllS…
alihanyalcin Feb 24, 2023
ca30255
add initCluster method
alihanyalcin Feb 24, 2023
8744d2e
refactor bucket definition
alihanyalcin Feb 24, 2023
ea85e52
update module name
alihanyalcin Feb 24, 2023
c1d0914
add ConnectionString, Username, Password for test case and fix config…
alihanyalcin Feb 25, 2023
4badc7b
add test
alihanyalcin Feb 25, 2023
04443f1
goimports and go mod tidy
alihanyalcin Feb 25, 2023
88e6811
fix: use modules instead of example
mdelapenya Feb 27, 2023
9272120
Merge remote-tracking branch 'upstream/main'
alihanyalcin Feb 28, 2023
d42ed48
change WithBasicCredentials with WithBasicAuth
alihanyalcin Feb 28, 2023
a921729
add test for community edition
alihanyalcin Feb 28, 2023
b85dd3d
Merge remote-tracking branch 'upstream/main'
alihanyalcin Mar 2, 2023
effbe26
fix eventing service with community container test
alihanyalcin Mar 2, 2023
5b59b51
update depandabot.yml and go.mod
alihanyalcin Mar 2, 2023
2ed206a
update couchbase doc
alihanyalcin Mar 2, 2023
23b17e0
reorder modules couchbase dependabot.yml
alihanyalcin Mar 3, 2023
d86893a
Update modules/couchbase/go.mod
alihanyalcin Mar 7, 2023
e784d0b
add comments for public methods
alihanyalcin Mar 7, 2023
c11b7a1
Merge remote-tracking branch 'upstream/main'
alihanyalcin Mar 7, 2023
c596691
add option for index storage mode
alihanyalcin Mar 8, 2023
7b65ad0
add comments for index storage modes
alihanyalcin Mar 9, 2023
abef3b2
Merge remote-tracking branch 'upstream/main'
alihanyalcin Mar 9, 2023
77b0fbf
Merge remote-tracking branch 'upstream/main'
alihanyalcin Mar 12, 2023
dbf9679
create vault module using modulegen
alihanyalcin Mar 13, 2023
29535b1
add vault config options
alihanyalcin Mar 13, 2023
e79a857
update container request, impl add secret and init commands
alihanyalcin Mar 14, 2023
b2322d5
add addSecret and runInitCommands to StartContainer
alihanyalcin Mar 16, 2023
32cefd3
add tests
alihanyalcin Mar 16, 2023
17ab67b
add default log level
alihanyalcin Mar 16, 2023
f8bbf81
add vault doc
alihanyalcin Mar 17, 2023
72bf0c9
Merge remote-tracking branch 'upstream/main'
alihanyalcin Mar 17, 2023
0c7645e
remove options and use ContainerRequest
alihanyalcin Mar 20, 2023
06c286c
update docs and tests, export vault container type
alihanyalcin Mar 20, 2023
c5c52a4
Merge remote-tracking branch 'upstream/main'
alihanyalcin Mar 20, 2023
f6d5f5e
remove log level option
alihanyalcin Mar 23, 2023
fcfa0cb
update default image
alihanyalcin Mar 23, 2023
e845378
update docs
alihanyalcin Mar 23, 2023
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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,9 @@ updates:
interval: monthly
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/vault
schedule:
interval: monthly
open-pull-requests-limit: 3
rebase-strategy: disabled
46 changes: 46 additions & 0 deletions .github/workflows/module-vault.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: vault module pipeline

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
test-vault:
strategy:
matrix:
go-version: [1.19.x, 1.x]
runs-on: "ubuntu-latest"
steps:

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: modVerify
working-directory: ./modules/vault
run: go mod verify

- name: modTidy
working-directory: ./modules/vault
run: make tools-tidy

- name: gotestsum
working-directory: ./modules/vault
run: make test-unit

- name: Run checker
run: |
./scripts/check_environment.sh

- name: Test Summary
uses: test-summary/action@4ee9ece4bca777a38f05c8fc578ac2007fe266f7
with:
paths: "**/TEST-vault*.xml"
if: always()
63 changes: 63 additions & 0 deletions docs/modules/vault.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Vault

<img src="https://cdn.worldvectorlogo.com/logos/vault-enterprise.svg" width="200" />

Testcontainers module for Vault. [Vault](https://www.vaultproject.io/) is an open-source tool designed for securely storing, accessing, and managing secrets and sensitive data such as passwords, certificates, API keys, and other confidential information.

## Adding this module to your project dependencies

Please run the following command to add the Vault module to your Go dependencies:

```
go get github.com/testcontainers/testcontainers-go/modules/vault
```

## Usage example
The **StartContainer** function is the main entry point to create a new VaultContainer instance.
It takes a context and zero or more Option values to configure the container.
<!--codeinclude-->
[Creating a Vault container](../../modules/vault/vault_test.go) inside_block:StartContainer
<!--/codeinclude-->

### Use CLI to read data from Vault container:
<!--codeinclude-->
[Use CLI to read data](../../modules/vault/vault_test.go) inside_block:TestVaultGetSecretPathWithCLI
<!--/codeinclude-->

### Use HTTP API to read data from Vault container:
<!--codeinclude-->
[Use HTTP API to read data](../../modules/vault/vault_test.go) inside_block:TestVaultGetSecretPathWithHTTP
<!--/codeinclude-->

### Use client library to read data from Vault container:
alihanyalcin marked this conversation as resolved.
Show resolved Hide resolved
<!--codeinclude-->
[Use library to read data](../../modules/vault/vault_test.go) inside_block:TestVaultGetSecretPathWithClient
<!--/codeinclude-->

## Container Options

You can set below options to create Vault container.

### Image
If you need to set a different Vault image, you can use the `WithImageName`. Default image name is `vault:1.13.0`
<!--codeinclude-->
[Set image name](../../modules/vault/vault_test.go) inside_block:WithImageName
<!--/codeinclude-->

### Token
If you need to add token authentication, you can use the `WithToken`.
<!--codeinclude-->
[Add token authentication](../../modules/vault/vault_test.go) inside_block:WithToken
<!--/codeinclude-->

### Log Level
If you need to change log level, you can use the `WithLogLevel`. Default log level is `info`
<!--codeinclude-->
[Change log level](../../modules/vault/vault_test.go) inside_block:WithLogLevel
<!--/codeinclude-->

### Command
If you need to run vault command in the container, you can use the `WithInitCommand`.
<!--codeinclude-->
[Run init command](../../modules/vault/vault_test.go) inside_block:WithInitCommand
<!--/codeinclude-->
mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ nav:
- modules/couchbase.md
- modules/localstack.md
- modules/pulsar.md
- modules/vault.md
- Examples:
- examples/index.md
- examples/bigtable.md
Expand Down
5 changes: 5 additions & 0 deletions modules/vault/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include ../../commons-test.mk

.PHONY: test
test:
$(MAKE) test-vault
70 changes: 70 additions & 0 deletions modules/vault/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module github.com/testcontainers/testcontainers-go/modules/vault

go 1.19

require (
github.com/docker/docker v23.0.1+incompatible
github.com/docker/go-connections v0.4.0
github.com/stretchr/testify v1.8.2
github.com/testcontainers/testcontainers-go v0.19.0
github.com/tidwall/gjson v1.14.4
gotest.tools/gotestsum v1.9.0
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/containerd/containerd v1.6.19 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
github.com/hashicorp/vault-client-go v0.2.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.0.0-20221128092401-c43b287e0e0f // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.2.0 // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
)

replace github.com/testcontainers/testcontainers-go => ../..
Loading