Development¶
Building¶
make build # bin/clickvault, current OS/arch
make build-linux-amd64 # bin/clickvault-linux-amd64
make build-linux-arm64 # bin/clickvault-linux-arm64
make sha256 # builds linux/amd64 and prints its sha256sum
Testing¶
Unit tests¶
Unit tests mock the database connection using go-sqlmock and do not need
Docker or a running ClickHouse:
Integration tests¶
Integration tests spin up a real ClickHouse container (matching
testdata/docker-compose.yml) with the Vault SDK's Docker test helper,
and drive the full lifecycle:
Initialize- configure the connectionNewUser- create a dynamic user- Verify the user can connect to ClickHouse
DeleteUser- revoke the user- Verify the user can no longer connect
- Repeat
DeleteUserto confirm idempotency UpdateUseron a static-style user with before/after connection checks
Integration tests are gated behind the integration build tag:
Docker must be running locally for that command to work.
Repository layout¶
clickvault/
├── go.mod, go.sum module github.com/emiliano-go/clickvault
├── main.go plugin entrypoint
├── internal/clickvault/
│ ├── clickvault.go ClickvaultPlugin and six dbplugin methods
│ ├── clickvault_test.go unit tests (go-sqlmock)
│ ├── ddl.go all SQL construction and cluster branching
│ └── ddl_test.go table-driven tests for ddl.go
├── testdata/docker-compose.yml single-node ClickHouse for manual testing
├── tests/integration_test.go integration tests against real ClickHouse
├── scripts/setup_vault.sh registers and configures the plugin
└── .github/workflows/ci.yml go vet, go test, build, sha256 artifact