diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 25b9e9a0cb..31229f5111 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -23,13 +23,6 @@ updates: day: sunday open-pull-requests-limit: 3 rebase-strategy: disabled - - package-ecosystem: gomod - directory: /examples/consul - schedule: - interval: monthly - day: sunday - open-pull-requests-limit: 3 - rebase-strategy: disabled - package-ecosystem: gomod directory: /examples/nginx schedule: @@ -86,6 +79,13 @@ updates: day: sunday open-pull-requests-limit: 3 rebase-strategy: disabled + - package-ecosystem: gomod + directory: /modules/consul + schedule: + interval: monthly + day: sunday + open-pull-requests-limit: 3 + rebase-strategy: disabled - package-ecosystem: gomod directory: /modules/couchbase schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c7b90777c..a40a43666e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: matrix: go-version: [1.20.x, 1.x] platform: [ubuntu-latest] - module: [artemis, cassandra, clickhouse, cockroachdb, compose, couchbase, elasticsearch, gcloud, inbucket, k3s, k6, kafka, localstack, mariadb, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, openldap, postgres, pulsar, rabbitmq, redis, redpanda, vault] + module: [artemis, cassandra, clickhouse, cockroachdb, compose, consul, couchbase, elasticsearch, gcloud, inbucket, k3s, k6, kafka, localstack, mariadb, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, openldap, postgres, pulsar, rabbitmq, redis, redpanda, vault] exclude: - go-version: 1.20.x module: compose @@ -124,7 +124,7 @@ jobs: needs: test-modules strategy: matrix: - module: [consul, nginx, toxiproxy] + module: [nginx, toxiproxy] uses: ./.github/workflows/ci-test-go.yml with: go-version: "1.20.x" diff --git a/.vscode/.testcontainers-go.code-workspace b/.vscode/.testcontainers-go.code-workspace index 962dbe5886..a1bd38e6ed 100644 --- a/.vscode/.testcontainers-go.code-workspace +++ b/.vscode/.testcontainers-go.code-workspace @@ -5,10 +5,6 @@ "name": "testcontainers-go", "path": "../" }, - { - "name": "example / consul", - "path": "../examples/consul" - }, { "name": "example / nginx", "path": "../examples/nginx" @@ -37,6 +33,10 @@ "name": "module / compose", "path": "../modules/compose" }, + { + "name": "module / consul", + "path": "../modules/consul" + }, { "name": "module / couchbase", "path": "../modules/couchbase" @@ -134,4 +134,4 @@ "path": "../modulegen" } ] -} \ No newline at end of file +} diff --git a/RELEASING.md b/RELEASING.md index fb3727b9cc..31a9954933 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -150,7 +150,6 @@ git add modules/**/go.* git commit -m chore: use new version (v0.20.1) in modules and examples git tag v0.20.1 git tag examples/bigtable/v0.20.1 -git tag examples/consul/v0.20.1 git tag examples/datastore/v0.20.1 git tag examples/firestore/v0.20.1 git tag examples/mongodb/v0.20.1 @@ -178,7 +177,6 @@ git commit -m chore: prepare for next minor development cycle (0.21.0) git push origin main --tags curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/@v/v0.20.1.info curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/bigtable/@v/v0.20.1.info -curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/consul/@v/v0.20.1.info curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/datastore/@v/v0.20.1.info curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/firestore/@v/v0.20.1.info curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/mongodb/@v/v0.20.1.info diff --git a/docs/examples/consul.md b/docs/examples/consul.md deleted file mode 100644 index 6f8cb8bc76..0000000000 --- a/docs/examples/consul.md +++ /dev/null @@ -1,9 +0,0 @@ -# Consul - - -[Creating a Consul container](../../examples/consul/consul.go) - - - -[Test for a Consul container](../../examples/consul/consul_test.go) - diff --git a/docs/modules/consul.md b/docs/modules/consul.md new file mode 100644 index 0000000000..ba21cc39b1 --- /dev/null +++ b/docs/modules/consul.md @@ -0,0 +1,58 @@ +# Consul + +Not available until the next release of testcontainers-go :material-tag: main + +## Introduction + +The Testcontainers module for Consul. + +## Adding this module to your project dependencies + +Please run the following command to add the Consul module to your Go dependencies: + +``` +go get github.com/testcontainers/testcontainers-go/modules/consul +``` + +## Usage example + + +[Creating a Consul container](../../modules/consul/examples_test.go) inside_block:runConsulContainer + + +## Module reference + +The Consul module exposes one entrypoint function to create the Consul container, and this function receives two parameters: + +```golang +func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*ConsulContainer, error) +``` + +- `context.Context`, the Go context. +- `testcontainers.ContainerCustomizer`, a variadic argument for passing options. + +### Container Options + +When starting the Consul container, you can pass options in a variadic way to configure it. + +#### Image + +If you need to set a different Consul Docker image, you can use `testcontainers.WithImage` with a valid Docker image +for Consul. E.g. `testcontainers.WithImage("docker.io/hashicorp/consul:1.15")`. + +{% include "../features/common_functional_options.md" %} + +#### Configuration File +If you need to customize the behavior for the deployed node you can use either `WithConfigString(config string)` or `WithConfigFile(configPath string)`. +The configuration has to be in JSON format and will be loaded at the node startup. + +### Container Methods + +The Consul container exposes the following method: + +#### ApiEndpoint +This method returns the connection string to connect to the Consul container API, using the default `8500` port. + + +[Using ApiEndpoint with the Consul client](../../modules/consul/examples_test.go) inside_block:connectConsul + diff --git a/examples/consul/consul.go b/examples/consul/consul.go deleted file mode 100644 index 46c1b62642..0000000000 --- a/examples/consul/consul.go +++ /dev/null @@ -1,44 +0,0 @@ -package consul - -import ( - "context" - "fmt" - - "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/wait" -) - -// consulContainer represents the consul container type used in the module -type consulContainer struct { - testcontainers.Container - endpoint string -} - -// startContainer creates an instance of the consul container type -func startContainer(ctx context.Context) (*consulContainer, error) { - req := testcontainers.ContainerRequest{ - Image: "hashicorp/consul:latest", - ExposedPorts: []string{"8500/tcp", "8600/udp"}, - Name: "badger", - Cmd: []string{"agent", "-server", "-ui", "-node=server-1", "-bootstrap-expect=1", "-client=0.0.0.0"}, - WaitingFor: wait.ForListeningPort("8500/tcp"), - } - container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ - ContainerRequest: req, - Started: true, - }) - if err != nil { - return nil, err - } - mappedPort, err := container.MappedPort(ctx, "8500") - if err != nil { - return nil, err - } - - host, err := container.Host(ctx) - if err != nil { - return nil, err - } - - return &consulContainer{Container: container, endpoint: fmt.Sprintf("%s:%s", host, mappedPort.Port())}, nil -} diff --git a/examples/consul/consul_test.go b/examples/consul/consul_test.go deleted file mode 100644 index f22e89290c..0000000000 --- a/examples/consul/consul_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package consul - -import ( - "bytes" - "context" - "testing" - - "github.com/hashicorp/consul/api" -) - -func TestConsul(t *testing.T) { - ctx := context.Background() - - container, err := startContainer(ctx) - if err != nil { - t.Fatal(err) - } - - // Clean up the container after the test is complete - t.Cleanup(func() { - if err := container.Terminate(ctx); err != nil { - t.Fatalf("failed to terminate container: %s", err) - } - }) - - // perform assertions - cfg := api.DefaultConfig() - cfg.Address = container.endpoint - client, err := api.NewClient(cfg) - if nil != err { - t.Fatal(err) - } - bs := []byte("apple") - _, err = client.KV().Put(&api.KVPair{ - Key: "fruit", - Value: bs, - }, nil) - if nil != err { - t.Fatal(err) - } - pair, _, err := client.KV().Get("fruit", nil) - if err != nil { - t.Fatal(err) - } - if pair.Key != "fruit" || !bytes.Equal(pair.Value, []byte("apple")) { - t.Errorf("get KV: %v %s,expect them to be: 'fruit' and 'apple'\n", pair.Key, pair.Value) - } -} diff --git a/mkdocs.yml b/mkdocs.yml index 6d6e7b75a5..cbee932874 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -67,6 +67,7 @@ nav: - modules/cassandra.md - modules/clickhouse.md - modules/cockroachdb.md + - modules/consul.md - modules/couchbase.md - modules/elasticsearch.md - modules/gcloud.md @@ -92,7 +93,6 @@ nav: - modules/vault.md - Examples: - examples/index.md - - examples/consul.md - examples/nginx.md - examples/toxiproxy.md - System Requirements: diff --git a/examples/consul/Makefile b/modules/consul/Makefile similarity index 98% rename from examples/consul/Makefile rename to modules/consul/Makefile index 4e67d96436..3e9bb56a17 100644 --- a/examples/consul/Makefile +++ b/modules/consul/Makefile @@ -3,3 +3,4 @@ include ../../commons-test.mk .PHONY: test test: $(MAKE) test-consul + diff --git a/modules/consul/consul.go b/modules/consul/consul.go new file mode 100644 index 0000000000..08a6e0ece2 --- /dev/null +++ b/modules/consul/consul.go @@ -0,0 +1,88 @@ +package consul + +import ( + "context" + "fmt" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" +) + +const ( + defaultHttpApiPort = "8500" + defaultBrokerPort = "8600" +) + +const ( + DefaultBaseImage = "docker.io/hashicorp/consul:1.15" +) + +// ConsulContainer represents the Consul container type used in the module. +type ConsulContainer struct { + testcontainers.Container +} + +// ApiEndpoint returns host:port for the HTTP API endpoint. +func (c *ConsulContainer) ApiEndpoint(ctx context.Context) (string, error) { + mappedPort, err := c.MappedPort(ctx, defaultHttpApiPort) + if err != nil { + return "", err + } + + hostIP, err := c.Host(ctx) + if err != nil { + return "", err + } + + uri := fmt.Sprintf("%s:%s", hostIP, mappedPort.Port()) + return uri, nil +} + +// WithConfigString takes in a JSON string of keys and values to define a configuration to be used by the instance. +func WithConfigString(config string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + req.Env["CONSUL_LOCAL_CONFIG"] = config + } +} + +// WithConfigFile takes in a path to a JSON file to define a configuration to be used by the instance. +func WithConfigFile(configPath string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) { + cf := testcontainers.ContainerFile{ + HostFilePath: configPath, + ContainerFilePath: "/consul/config/node.json", + FileMode: 0o755, + } + req.Files = append(req.Files, cf) + } +} + +// RunContainer creates an instance of the Consul container type +func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*ConsulContainer, error) { + containerReq := testcontainers.GenericContainerRequest{ + ContainerRequest: testcontainers.ContainerRequest{ + Image: DefaultBaseImage, + ExposedPorts: []string{ + defaultHttpApiPort + "/tcp", + defaultBrokerPort + "/tcp", + defaultBrokerPort + "/udp", + }, + Env: map[string]string{}, + WaitingFor: wait.ForAll( + wait.ForLog("Consul agent running!"), + ), + }, + Started: true, + } + + for _, opt := range opts { + opt.Customize(&containerReq) + } + + container, err := testcontainers.GenericContainer(ctx, containerReq) + if err != nil { + return nil, err + } + + return &ConsulContainer{Container: container}, nil +} diff --git a/modules/consul/consul_test.go b/modules/consul/consul_test.go new file mode 100644 index 0000000000..e9f6bfa860 --- /dev/null +++ b/modules/consul/consul_test.go @@ -0,0 +1,73 @@ +package consul_test + +import ( + "context" + "net/http" + "path/filepath" + "testing" + + capi "github.com/hashicorp/consul/api" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/modules/consul" +) + +func TestConsul(t *testing.T) { + ctx := context.Background() + tests := []struct { + name string + opts []testcontainers.ContainerCustomizer + }{ + { + name: "Default", + opts: []testcontainers.ContainerCustomizer{}, + }, + { + name: "WithConfigString", + opts: []testcontainers.ContainerCustomizer{ + consul.WithConfigString(`{ "server":true }`), + }, + }, + { + name: "WithConfigFile", + opts: []testcontainers.ContainerCustomizer{ + consul.WithConfigFile(filepath.Join("testdata", "config.json")), + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + container, err := consul.RunContainer(ctx, test.opts...) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, container.Terminate(ctx), "failed to terminate container") }) + + // Check if API is up + host, err := container.ApiEndpoint(ctx) + require.NoError(t, err) + assert.NotEmpty(t, len(host)) + + res, err := http.Get("http://" + host) + require.NoError(t, err) + assert.Equal(t, http.StatusOK, res.StatusCode) + + cfg := capi.DefaultConfig() + cfg.Address = host + + reg := &capi.AgentServiceRegistration{ID: "abcd", Name: test.name} + + client, err := capi.NewClient(cfg) + require.NoError(t, err) + + // Register / Unregister service + s := client.Agent() + err = s.ServiceRegister(reg) + require.NoError(t, err) + + err = s.ServiceDeregister("abcd") + require.NoError(t, err) + }) + } +} diff --git a/modules/consul/examples_test.go b/modules/consul/examples_test.go new file mode 100644 index 0000000000..002c143c95 --- /dev/null +++ b/modules/consul/examples_test.go @@ -0,0 +1,83 @@ +package consul_test + +import ( + "context" + "fmt" + "log" + + capi "github.com/hashicorp/consul/api" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/modules/consul" +) + +func ExampleRunContainer() { + // runConsulContainer { + ctx := context.Background() + + consulContainer, err := consul.RunContainer(ctx, + testcontainers.WithImage("docker.io/hashicorp/consul:1.15"), + ) + if err != nil { + log.Fatalf("failed to start container: %s", err) + } + + // Clean up the container + defer func() { + if err := consulContainer.Terminate(ctx); err != nil { + log.Fatalf("failed to terminate container: %s", err) + } + }() + // } + + state, err := consulContainer.State(ctx) + if err != nil { + log.Fatalf("failed to get container state: %s", err) // nolint:gocritic + } + + fmt.Println(state.Running) + + // Output: + // true +} + +func ExampleRunContainer_connect() { + // connectConsul { + ctx := context.Background() + + consulContainer, err := consul.RunContainer(ctx, + testcontainers.WithImage("docker.io/hashicorp/consul:1.15"), + ) + if err != nil { + log.Fatalf("failed to start container: %s", err) + } + + // Clean up the container + defer func() { + if err := consulContainer.Terminate(ctx); err != nil { + log.Fatalf("failed to terminate container: %s", err) + } + }() + + endpoint, err := consulContainer.ApiEndpoint(ctx) + if err != nil { + log.Fatalf("failed to get endpoint: %s", err) // nolint:gocritic + } + + config := capi.DefaultConfig() + config.Address = endpoint + client, err := capi.NewClient(config) + if err != nil { + log.Fatalf("failed to connect to Consul: %s", err) + } + // } + + node_name, err := client.Agent().NodeName() + if err != nil { + log.Fatalf("failed to get node name: %s", err) // nolint:gocritic + } + fmt.Println(len(node_name) > 0) + + // Output: + // true +} diff --git a/examples/consul/go.mod b/modules/consul/go.mod similarity index 92% rename from examples/consul/go.mod rename to modules/consul/go.mod index a177fe6244..f1adfded88 100644 --- a/examples/consul/go.mod +++ b/modules/consul/go.mod @@ -1,9 +1,10 @@ -module github.com/testcontainers/testcontainers-go/examples/consul +module github.com/testcontainers/testcontainers-go/modules/consul go 1.20 require ( github.com/hashicorp/consul/api v1.27.0 + github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.27.0 ) @@ -17,6 +18,7 @@ require ( github.com/containerd/containerd v1.7.12 // indirect github.com/containerd/log v0.1.0 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/distribution/reference v0.5.0 // indirect github.com/docker/docker v25.0.2+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect @@ -52,6 +54,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/shirou/gopsutil/v3 v3.23.12 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect @@ -70,6 +73,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/testcontainers/testcontainers-go => ../.. diff --git a/examples/consul/go.sum b/modules/consul/go.sum similarity index 98% rename from examples/consul/go.sum rename to modules/consul/go.sum index 0cf02246a2..6a015d9eea 100644 --- a/examples/consul/go.sum +++ b/modules/consul/go.sum @@ -37,6 +37,7 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/docker v25.0.2+incompatible h1:/OaKeauroa10K4Nqavw4zlhcDq/WBcPMc5DbjOGgozY= @@ -135,8 +136,10 @@ github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -194,6 +197,7 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= @@ -209,6 +213,7 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -347,6 +352,7 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/modules/consul/testdata/config.json b/modules/consul/testdata/config.json new file mode 100644 index 0000000000..3e35005afb --- /dev/null +++ b/modules/consul/testdata/config.json @@ -0,0 +1,3 @@ +{ + "server": true +} diff --git a/sonar-project.properties b/sonar-project.properties index e332ab9c27..25d6e50b0d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,4 +18,4 @@ sonar.test.inclusions=**/*_test.go sonar.test.exclusions=**/vendor/** sonar.go.coverage.reportPaths=**/coverage.out -sonar.go.tests.reportPaths=TEST-unit.xml,examples/consul/TEST-unit.xml,examples/nginx/TEST-unit.xml,examples/toxiproxy/TEST-unit.xml,modulegen/TEST-unit.xml,modules/artemis/TEST-unit.xml,modules/cassandra/TEST-unit.xml,modules/clickhouse/TEST-unit.xml,modules/cockroachdb/TEST-unit.xml,modules/compose/TEST-unit.xml,modules/couchbase/TEST-unit.xml,modules/elasticsearch/TEST-unit.xml,modules/gcloud/TEST-unit.xml,modules/inbucket/TEST-unit.xml,modules/k3s/TEST-unit.xml,modules/k6/TEST-unit.xml,modules/kafka/TEST-unit.xml,modules/localstack/TEST-unit.xml,modules/mariadb/TEST-unit.xml,modules/minio/TEST-unit.xml,modules/mockserver/TEST-unit.xml,modules/mongodb/TEST-unit.xml,modules/mssql/TEST-unit.xml,modules/mysql/TEST-unit.xml,modules/nats/TEST-unit.xml,modules/neo4j/TEST-unit.xml,modules/openldap/TEST-unit.xml,modules/postgres/TEST-unit.xml,modules/pulsar/TEST-unit.xml,modules/rabbitmq/TEST-unit.xml,modules/redis/TEST-unit.xml,modules/redpanda/TEST-unit.xml,modules/vault/TEST-unit.xml +sonar.go.tests.reportPaths=TEST-unit.xml,examples/nginx/TEST-unit.xml,examples/toxiproxy/TEST-unit.xml,modulegen/TEST-unit.xml,modules/artemis/TEST-unit.xml,modules/cassandra/TEST-unit.xml,modules/clickhouse/TEST-unit.xml,modules/cockroachdb/TEST-unit.xml,modules/compose/TEST-unit.xml,modules/consul/TEST-unit.xml,modules/couchbase/TEST-unit.xml,modules/elasticsearch/TEST-unit.xml,modules/gcloud/TEST-unit.xml,modules/inbucket/TEST-unit.xml,modules/k3s/TEST-unit.xml,modules/k6/TEST-unit.xml,modules/kafka/TEST-unit.xml,modules/localstack/TEST-unit.xml,modules/mariadb/TEST-unit.xml,modules/minio/TEST-unit.xml,modules/mockserver/TEST-unit.xml,modules/mongodb/TEST-unit.xml,modules/mssql/TEST-unit.xml,modules/mysql/TEST-unit.xml,modules/nats/TEST-unit.xml,modules/neo4j/TEST-unit.xml,modules/openldap/TEST-unit.xml,modules/postgres/TEST-unit.xml,modules/pulsar/TEST-unit.xml,modules/rabbitmq/TEST-unit.xml,modules/redis/TEST-unit.xml,modules/redpanda/TEST-unit.xml,modules/vault/TEST-unit.xml