From 589f92634f01d4b132d6e407bf43130c75af1cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez=20Gonzales?= Date: Mon, 21 Aug 2023 01:19:02 -0600 Subject: [PATCH 01/26] Add "new badge" in header (#1512) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kevin Wittek Co-authored-by: Manuel de la Peña --- docs/css/tc-header.css | 14 ++++++++++++++ docs/theme/partials/tc-header.html | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/css/tc-header.css b/docs/css/tc-header.css index 122102bb4d..c05500938e 100644 --- a/docs/css/tc-header.css +++ b/docs/css/tc-header.css @@ -102,6 +102,20 @@ body.mobile-menu #site-header #mobile-menu-toggle { white-space: nowrap; } +#site-header .menu-item .badge { + color: white; + font-size: 10px; + padding: 2px 6px; + background-color: #0FD5C6; +text-align: center; + text-decoration: none; + display: inline-block; + border-radius: 6px; + &:hover { + + } +} + #site-header .menu-item button:hover, #site-header .menu-item a:hover { color: var(--color-topaz); diff --git a/docs/theme/partials/tc-header.html b/docs/theme/partials/tc-header.html index 73500c640a..3e74341b1e 100644 --- a/docs/theme/partials/tc-header.html +++ b/docs/theme/partials/tc-header.html @@ -2,7 +2,7 @@ "siteUrl": "https://testcontainers.com/", "menuItems": [ { - "label": "Desktop", + "label": "Desktop NEW", "url": "https://testcontainers.com/desktop/" }, { From 7021689bf12ef83a1cef6029cdce9fad54609181 Mon Sep 17 00:00:00 2001 From: martin-mfg <2026226+martin-mfg@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:42:00 +0200 Subject: [PATCH 02/26] doc fix: make file permission examples octal (#1510) * doc fix: make file permission examples octal Examples of file permissions should be in octal format. But in the code examples they are not. * use new octal notation --- docs/features/copy_file.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/features/copy_file.md b/docs/features/copy_file.md index 43d8824187..351667af03 100644 --- a/docs/features/copy_file.md +++ b/docs/features/copy_file.md @@ -14,7 +14,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{ Started: true, }) -nginxC.CopyFileToContainer(ctx, "./testdata/hello.sh", "/hello_copy.sh", 700) +nginxC.CopyFileToContainer(ctx, "./testdata/hello.sh", "/hello_copy.sh", 0o700) ``` Or you can add a list of files in the `ContainerRequest` initialization, which can be copied before the container starts: @@ -31,7 +31,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{ { HostFilePath: "./testdata/hello.sh", ContainerFilePath: "/copies-hello.sh", - FileMode: 700, + FileMode: 0o700, }, }, }, @@ -60,7 +60,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{ { HostFilePath: "./testdata", // a directory ContainerFilePath: "/tmp/testdata", // important! its parent already exists - FileMode: 700, + FileMode: 0o700, }, }, }, @@ -73,7 +73,7 @@ if err != nil { // as the container is started, we can create the directory first _, _, err = nginxC.Exec(ctx, []string{"mkdir", "-p", "/usr/lib/my-software/config"}) // because the container path is a directory, it will use the copy dir method as fallback -err = nginxC.CopyFileToContainer(ctx, "./files", "/usr/lib/my-software/config/files", 700) +err = nginxC.CopyFileToContainer(ctx, "./files", "/usr/lib/my-software/config/files", 0o700) if err != nil { // handle error } @@ -94,7 +94,7 @@ nginxC, err := GenericContainer(ctx, GenericContainerRequest{ { HostFilePath: "./testdata", // a directory ContainerFilePath: "/tmp/testdata", // important! its parent already exists - FileMode: 700, + FileMode: 0o700, }, }, }, @@ -106,7 +106,7 @@ if err != nil { // as the container is started, we can create the directory first _, _, err = nginxC.Exec(ctx, []string{"mkdir", "-p", "/usr/lib/my-software/config"}) -err = nginxC.CopyDirToContainer(ctx, "./plugins", "/usr/lib/my-software/config/plugins", 700) +err = nginxC.CopyDirToContainer(ctx, "./plugins", "/usr/lib/my-software/config/plugins", 0o700) if err != nil { // handle error } From 520b0ac26dbb2cfeed6caa5d96834224bfd92bd1 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Mon, 21 Aug 2023 11:34:40 +0200 Subject: [PATCH 03/26] Golangci-lint for all go-modules (#1498) * move golangci-lint to ci-test-go.yml Signed-off-by: Matthieu MOREL * checkout before setup-go * cleanup .golangci.yml * define cache-dependency-path for actions/setup-go * remove static-analysis from required status check * apply gofumpt formatting Signed-off-by: Matthieu MOREL --------- Signed-off-by: Matthieu MOREL --- .github/settings.yml | 2 +- .github/workflows/ci-test-go.yml | 27 ++++++++-- .github/workflows/golangci-lint.yml | 51 ------------------- .golangci.yml | 9 ++-- config_test.go | 1 + container.go | 1 + container_test.go | 20 ++++---- docker.go | 4 +- docker_auth.go | 1 + docker_auth_test.go | 1 + docker_exec_test.go | 1 + docker_mounts.go | 14 +++-- docker_test.go | 3 +- examples/bigtable/bigtable.go | 3 +- examples/bigtable/bigtable_test.go | 5 +- examples/cockroachdb/cockroachdb.go | 1 + examples/datastore/datastore_test.go | 5 +- examples/firestore/firestore.go | 3 +- examples/firestore/firestore_test.go | 9 ++-- examples/nats/nats.go | 2 +- examples/nats/nats_test.go | 1 - examples/pubsub/pubsub_test.go | 8 ++- examples/spanner/spanner.go | 3 +- examples/spanner/spanner_test.go | 10 ++-- examples/toxiproxy/redis.go | 1 + examples/toxiproxy/toxiproxy.go | 3 +- examples/toxiproxy/toxiproxy_test.go | 6 ++- file_test.go | 6 +-- generic.go | 1 + generic_test.go | 1 + internal/config/config.go | 6 ++- internal/testcontainersdocker/client.go | 1 + internal/testcontainersdocker/docker_host.go | 13 +++-- .../testcontainersdocker/docker_host_test.go | 11 ++-- .../docker_rootless_test.go | 8 +-- internal/testcontainersdocker/images.go | 2 +- internal/testcontainerssession/session.go | 6 ++- lifecycle_test.go | 3 +- logconsumer_test.go | 1 + logger.go | 1 + modulegen/dependabot.go | 2 +- modulegen/dependabot_test.go | 6 +-- modulegen/main.go | 14 ++--- modulegen/main_test.go | 24 ++++----- modulegen/mkdocs.go | 6 +-- modulegen/mkdocs_test.go | 6 +-- modules/artemis/artemis.go | 1 + modules/artemis/artemis_test.go | 1 + modules/artemis/example_test.go | 1 + modules/clickhouse/clickhouse.go | 19 ++++--- modules/clickhouse/clickhouse_test.go | 9 ++-- modules/compose/compose.go | 6 ++- modules/compose/compose_api_test.go | 2 +- modules/compose/compose_local.go | 10 ++-- modules/compose/compose_test.go | 9 ++-- modules/compose/testdata/echoserver.go | 1 - modules/couchbase/couchbase.go | 3 +- modules/couchbase/couchbase_test.go | 4 +- modules/k3s/k3s.go | 5 +- modules/k3s/k3s_test.go | 5 +- modules/localstack/localstack.go | 18 +++---- .../localstack/localstack_legacy_mode_test.go | 1 + modules/localstack/localstack_test.go | 10 ++-- modules/localstack/v1/s3_test.go | 1 + modules/localstack/v2/s3_test.go | 1 + modules/mysql/mysql.go | 14 ++--- modules/mysql/mysql_test.go | 3 +- modules/neo4j/neo4j.go | 1 + modules/neo4j/neo4j_test.go | 4 +- modules/postgres/postgres.go | 12 +++-- modules/postgres/postgres_test.go | 12 +++-- modules/pulsar/pulsar.go | 20 +++++--- modules/pulsar/pulsar_test.go | 1 + modules/redis/redis.go | 2 +- modules/redis/redis_test.go | 3 +- modules/redpanda/redpanda.go | 2 +- modules/vault/vault.go | 4 +- modules/vault/vault_test.go | 3 +- mounts.go | 3 +- mounts_test.go | 1 + network_test.go | 3 +- parallel.go | 5 +- parallel_test.go | 7 +-- provider_test.go | 2 +- reaper.go | 1 + reaper_test.go | 1 + testdata/echoserver.go | 1 - wait/all.go | 6 ++- wait/exec.go | 6 ++- wait/exec_test.go | 1 + wait/exit.go | 7 +-- wait/exit_test.go | 1 + wait/health.go | 7 +-- wait/health_test.go | 1 + wait/host_port.go | 10 ++-- wait/host_port_test.go | 1 + wait/http.go | 6 ++- wait/http_test.go | 1 + wait/log.go | 13 +++-- wait/nop.go | 7 ++- wait/sql.go | 6 ++- wait/wait.go | 1 + wait/wait_test.go | 1 + 103 files changed, 324 insertions(+), 276 deletions(-) delete mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/settings.yml b/.github/settings.yml index 82898f8762..b1e3ed8e12 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -183,7 +183,7 @@ branches: # Required. Require branches to be up to date before merging. strict: true # Required. The list of status checks to require in order to merge into this branch - contexts: ["static-analysis", "test (1.x, ubuntu-latest) / ./ubuntu-latest/1.x"] + contexts: ["test (1.x, ubuntu-latest) / ./ubuntu-latest/1.x"] # Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable. enforce_admins: false # Prevent merge commits from being pushed to matching branches diff --git a/.github/workflows/ci-test-go.yml b/.github/workflows/ci-test-go.yml index 5f2a91588a..4748634ee0 100644 --- a/.github/workflows/ci-test-go.yml +++ b/.github/workflows/ci-test-go.yml @@ -33,6 +33,11 @@ on: default: false description: "Disable the ryuk container for the test." +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + jobs: test-go-project: name: "${{ inputs.project-directory }}/${{ inputs.platform }}/${{ inputs.go-version }}" @@ -48,14 +53,30 @@ jobs: if: ${{ inputs.rootless-docker }} run: sudo rm -rf /var/run/docker.sock + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + - name: Set up Go uses: actions/setup-go@v4 with: - go-version: ${{ inputs.go-version }} + go-version: '${{ inputs.go-version }}' + cache-dependency-path: '${{ inputs.project-directory }}/go.sum' id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v3 + - name: golangci-lint + # TODO: Remove each example/module once it passes the golangci-lint + if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["examples/cockroachdb", "examples/spanner", "examples/toxiproxy", "modules/compose", "modules/pulsar", "modules/redis"]'), inputs.project-directory) }} + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: v1.54.1 + # Optional: working directory, useful for monorepos + working-directory: ${{ inputs.project-directory }} + # Optional: golangci-lint command line arguments. + args: --verbose + # Optional: if set to true then the all caching functionality will be complete disabled, + # takes precedence over all other caching options. + skip-cache: true - name: modVerify working-directory: ./${{ inputs.project-directory }} diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index 813df6f282..0000000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: golangci-lint / static-analysis -on: - push: - tags: - - v* - branches: - - main - pull_request: - -concurrency: - group: "${{ github.workflow }}-${{ github.head_ref || github.sha }}" - cancel-in-progress: true - -permissions: - contents: read - # Optional: allow read access to pull request. Use with `only-new-issues` option. - # pull-requests: read - -jobs: - static-analysis: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.54.1 - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - # args: --issues-exit-code=0 - args: --verbose - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true then the all caching functionality will be complete disabled, - # takes precedence over all other caching options. - # skip-cache: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true diff --git a/.golangci.yml b/.golangci.yml index 6d4d77a746..8c02d880c6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,16 +1,15 @@ linters: enable: - gci - - gofmt + - gofumpt - misspell - linters-settings: gci: sections: - - standard - - default - - prefix(github.com/testcontainters) + - standard + - default + - prefix(github.com/testcontainers) run: timeout: 5m diff --git a/config_test.go b/config_test.go index bf4ce23adc..e2c803b904 100644 --- a/config_test.go +++ b/config_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/testcontainers/testcontainers-go/internal/config" ) diff --git a/container.go b/container.go index ec2351ea20..7dbd544ff2 100644 --- a/container.go +++ b/container.go @@ -14,6 +14,7 @@ import ( "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/archive" "github.com/docker/go-connections/nat" + tcexec "github.com/testcontainers/testcontainers-go/exec" "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" diff --git a/container_test.go b/container_test.go index 37bd04a373..b417822986 100644 --- a/container_test.go +++ b/container_test.go @@ -12,11 +12,11 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/testcontainers/testcontainers-go/wait" ) func Test_ContainerValidation(t *testing.T) { - type ContainerValidationTestCase struct { Name string ExpectedError error @@ -71,13 +71,14 @@ func Test_ContainerValidation(t *testing.T) { for _, testCase := range testTable { t.Run(testCase.Name, func(t *testing.T) { err := testCase.ContainerRequest.Validate() - if err == nil && testCase.ExpectedError == nil { + switch { + case err == nil && testCase.ExpectedError == nil: return - } else if err == nil && testCase.ExpectedError != nil { + case err == nil && testCase.ExpectedError != nil: t.Errorf("did not receive expected error: %s", testCase.ExpectedError.Error()) - } else if err != nil && testCase.ExpectedError == nil { + case err != nil && testCase.ExpectedError == nil: t.Errorf("received unexpected error: %s", err.Error()) - } else if err.Error() != testCase.ExpectedError.Error() { + case err.Error() != testCase.ExpectedError.Error(): t.Errorf("errors mismatch: %s != %s", err.Error(), testCase.ExpectedError.Error()) } }) @@ -155,7 +156,7 @@ func Test_BuildImageWithContexts(t *testing.T) { for _, f := range files { header := tar.Header{ Name: f.Name, - Mode: 0777, + Mode: 0o777, Size: int64(len(f.Contents)), Typeflag: tar.TypeReg, Format: tar.FormatGNU, @@ -271,13 +272,14 @@ func Test_BuildImageWithContexts(t *testing.T) { ContainerRequest: req, Started: true, }) - if testCase.ExpectedError != nil && err != nil { + switch { + case testCase.ExpectedError != nil && err != nil: if testCase.ExpectedError.Error() != err.Error() { t.Fatalf("unexpected error: %s, was expecting %s", err.Error(), testCase.ExpectedError.Error()) } - } else if err != nil { + case err != nil: t.Fatal(err) - } else { + default: terminateContainerOnEnd(t, ctx, c) } }) diff --git a/docker.go b/docker.go index 4e6574ce36..51b7c562f9 100644 --- a/docker.go +++ b/docker.go @@ -31,6 +31,7 @@ import ( "github.com/google/uuid" "github.com/moby/term" specs "github.com/opencontainers/image-spec/specs-go/v1" + tcexec "github.com/testcontainers/testcontainers-go/exec" "github.com/testcontainers/testcontainers-go/internal" "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" @@ -316,7 +317,6 @@ func (c *DockerContainer) inspectContainer(ctx context.Context) (*types.Containe // Logs will fetch both STDOUT and STDERR from the current container. Returns a // ReadCloser and leaves it up to the caller to extract what it wants. func (c *DockerContainer) Logs(ctx context.Context) (io.ReadCloser, error) { - const streamHeaderSize = 8 options := types.ContainerLogsOptions{ @@ -334,7 +334,7 @@ func (c *DockerContainer) Logs(ctx context.Context) (io.ReadCloser, error) { r := bufio.NewReader(rc) go func() { - var lineStarted = true + lineStarted := true for err == nil { line, isPrefix, err := r.ReadLine() diff --git a/docker_auth.go b/docker_auth.go index 5a5c40ad84..db678a3981 100644 --- a/docker_auth.go +++ b/docker_auth.go @@ -8,6 +8,7 @@ import ( "github.com/cpuguy83/dockercfg" "github.com/docker/docker/api/types/registry" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" ) diff --git a/docker_auth_test.go b/docker_auth_test.go index 77d6cb3cd5..87c32d4e55 100644 --- a/docker_auth_test.go +++ b/docker_auth_test.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/client" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/docker_exec_test.go b/docker_exec_test.go index a31b1eeb01..e925fc0f1f 100644 --- a/docker_exec_test.go +++ b/docker_exec_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" + tcexec "github.com/testcontainers/testcontainers-go/exec" ) diff --git a/docker_mounts.go b/docker_mounts.go index bb63dc0479..fa3e825c4b 100644 --- a/docker_mounts.go +++ b/docker_mounts.go @@ -2,14 +2,12 @@ package testcontainers import "github.com/docker/docker/api/types/mount" -var ( - mountTypeMapping = map[MountType]mount.Type{ - MountTypeBind: mount.TypeBind, - MountTypeVolume: mount.TypeVolume, - MountTypeTmpfs: mount.TypeTmpfs, - MountTypePipe: mount.TypeNamedPipe, - } -) +var mountTypeMapping = map[MountType]mount.Type{ + MountTypeBind: mount.TypeBind, + MountTypeVolume: mount.TypeVolume, + MountTypeTmpfs: mount.TypeTmpfs, + MountTypePipe: mount.TypeNamedPipe, +} // BindMounter can optionally be implemented by mount sources // to support advanced scenarios based on mount.BindOptions diff --git a/docker_test.go b/docker_test.go index b3a05af2aa..d0527223dd 100644 --- a/docker_test.go +++ b/docker_test.go @@ -24,6 +24,7 @@ import ( "github.com/docker/go-units" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" @@ -2190,7 +2191,7 @@ func TestNetworkModeWithContainerReference(t *testing.T) { // creates a temporary dir in which the files will be extracted. Then it will compare the bytes of each file in the source with the bytes from the copied-from-container file func assertExtractedFiles(t *testing.T, ctx context.Context, container Container, hostFilePath string, containerFilePath string) { // create all copied files into a temporary dir - tmpDir := filepath.Join(t.TempDir()) + tmpDir := t.TempDir() // compare the bytes of each file in the source with the bytes from the copied-from-container file srcFiles, err := os.ReadDir(hostFilePath) diff --git a/examples/bigtable/bigtable.go b/examples/bigtable/bigtable.go index f6c32bac7d..7ff43b78c5 100644 --- a/examples/bigtable/bigtable.go +++ b/examples/bigtable/bigtable.go @@ -4,9 +4,8 @@ import ( "context" "fmt" - "github.com/testcontainers/testcontainers-go/wait" - "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) // bigtableContainer represents the bigtable container type used in the module diff --git a/examples/bigtable/bigtable_test.go b/examples/bigtable/bigtable_test.go index f724ee8585..7d6c6dc94f 100644 --- a/examples/bigtable/bigtable_test.go +++ b/examples/bigtable/bigtable_test.go @@ -1,12 +1,13 @@ package bigtable import ( - "cloud.google.com/go/bigtable" "context" + "testing" + + "cloud.google.com/go/bigtable" "google.golang.org/api/option" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "testing" ) const ( diff --git a/examples/cockroachdb/cockroachdb.go b/examples/cockroachdb/cockroachdb.go index 176c1a371d..08b05a440b 100644 --- a/examples/cockroachdb/cockroachdb.go +++ b/examples/cockroachdb/cockroachdb.go @@ -5,6 +5,7 @@ import ( "fmt" _ "github.com/jackc/pgx/v4/stdlib" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/examples/datastore/datastore_test.go b/examples/datastore/datastore_test.go index f8a45ee828..3bf5007463 100644 --- a/examples/datastore/datastore_test.go +++ b/examples/datastore/datastore_test.go @@ -1,12 +1,13 @@ package datastore import ( - "cloud.google.com/go/datastore" "context" + "testing" + + "cloud.google.com/go/datastore" "google.golang.org/api/option" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "testing" ) type Task struct { diff --git a/examples/firestore/firestore.go b/examples/firestore/firestore.go index 4e0ef27d06..63ba9cae26 100644 --- a/examples/firestore/firestore.go +++ b/examples/firestore/firestore.go @@ -4,9 +4,8 @@ import ( "context" "fmt" - "github.com/testcontainers/testcontainers-go/wait" - "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) // firestoreContainer represents the firestore container type used in the module diff --git a/examples/firestore/firestore_test.go b/examples/firestore/firestore_test.go index 398fdac767..e20de884de 100644 --- a/examples/firestore/firestore_test.go +++ b/examples/firestore/firestore_test.go @@ -1,12 +1,13 @@ package firestore import ( - "cloud.google.com/go/firestore" "context" + "testing" + + "cloud.google.com/go/firestore" "google.golang.org/api/option" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "testing" ) type Person struct { @@ -14,12 +15,12 @@ type Person struct { Lastname string `json:"lastname"` } -type emulatorCreds struct { -} +type emulatorCreds struct{} func (ec emulatorCreds) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{"authorization": "Bearer owner"}, nil } + func (ec emulatorCreds) RequireTransportSecurity() bool { return false } diff --git a/examples/nats/nats.go b/examples/nats/nats.go index 4ce61a7713..517414938f 100644 --- a/examples/nats/nats.go +++ b/examples/nats/nats.go @@ -47,7 +47,7 @@ func runContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return nil, err } - uri:= fmt.Sprintf("nats://%s:%s", hostIP, mappedPort.Port()) + uri := fmt.Sprintf("nats://%s:%s", hostIP, mappedPort.Port()) return &natsContainer{Container: container, URI: uri}, nil } diff --git a/examples/nats/nats_test.go b/examples/nats/nats_test.go index c894da5528..d4ef04d200 100644 --- a/examples/nats/nats_test.go +++ b/examples/nats/nats_test.go @@ -63,4 +63,3 @@ func TestNats(t *testing.T) { t.Fatalf("expected message to be 'hello', got '%s'", msg.Data) } } - diff --git a/examples/pubsub/pubsub_test.go b/examples/pubsub/pubsub_test.go index 67c97bd38d..21fdea7ce7 100644 --- a/examples/pubsub/pubsub_test.go +++ b/examples/pubsub/pubsub_test.go @@ -1,12 +1,13 @@ package pubsub import ( - "cloud.google.com/go/pubsub" "context" + "testing" + + "cloud.google.com/go/pubsub" "google.golang.org/api/option" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "testing" ) func TestPubsub(t *testing.T) { @@ -58,6 +59,9 @@ func TestPubsub(t *testing.T) { m.Ack() defer cancel() }) + if err != nil { + t.Fatal(err) + } if string(data) != "Hello World" { t.Fatalf("Expected value %s. Got %s.", "Hello World", data) } diff --git a/examples/spanner/spanner.go b/examples/spanner/spanner.go index ad8f3370af..84093c13ff 100644 --- a/examples/spanner/spanner.go +++ b/examples/spanner/spanner.go @@ -4,9 +4,8 @@ import ( "context" "fmt" - "github.com/testcontainers/testcontainers-go/wait" - "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) // spannerContainer represents the spanner container type used in the module diff --git a/examples/spanner/spanner_test.go b/examples/spanner/spanner_test.go index 3715dc88ae..e26eb5c42e 100644 --- a/examples/spanner/spanner_test.go +++ b/examples/spanner/spanner_test.go @@ -1,18 +1,19 @@ package spanner import ( + "context" + "fmt" + "testing" + "cloud.google.com/go/spanner" database "cloud.google.com/go/spanner/admin/database/apiv1" instance "cloud.google.com/go/spanner/admin/instance/apiv1" - "context" - "fmt" "google.golang.org/api/option" "google.golang.org/api/option/internaloption" databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1" instancepb "google.golang.org/genproto/googleapis/spanner/admin/instance/v1" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "testing" ) const ( @@ -95,7 +96,8 @@ func TestSpanner(t *testing.T) { _, err = client.Apply(ctx, []*spanner.Mutation{ spanner.Insert("Languages", []string{"language", "mascot"}, - []interface{}{"Go", "Gopher"})}) + []interface{}{"Go", "Gopher"}), + }) if err != nil { t.Fatal(err) } diff --git a/examples/toxiproxy/redis.go b/examples/toxiproxy/redis.go index 26e3336deb..ead526773d 100644 --- a/examples/toxiproxy/redis.go +++ b/examples/toxiproxy/redis.go @@ -2,6 +2,7 @@ package toxiproxy import ( "context" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/examples/toxiproxy/toxiproxy.go b/examples/toxiproxy/toxiproxy.go index ed335c14f3..e7903a9f99 100644 --- a/examples/toxiproxy/toxiproxy.go +++ b/examples/toxiproxy/toxiproxy.go @@ -4,9 +4,8 @@ import ( "context" "fmt" - "github.com/testcontainers/testcontainers-go/wait" - "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) // toxiproxyContainer represents the toxiproxy container type used in the module diff --git a/examples/toxiproxy/toxiproxy_test.go b/examples/toxiproxy/toxiproxy_test.go index 5cee012924..f1ba128b59 100644 --- a/examples/toxiproxy/toxiproxy_test.go +++ b/examples/toxiproxy/toxiproxy_test.go @@ -3,12 +3,14 @@ package toxiproxy import ( "context" "fmt" + "testing" + "time" + toxiproxy "github.com/Shopify/toxiproxy/v2/client" "github.com/go-redis/redis/v8" "github.com/google/uuid" + "github.com/testcontainers/testcontainers-go" - "testing" - "time" ) func TestToxiproxy(t *testing.T) { diff --git a/file_test.go b/file_test.go index 8d7231d0a8..41c25d095f 100644 --- a/file_test.go +++ b/file_test.go @@ -76,7 +76,7 @@ func Test_TarDir(t *testing.T) { src = absSrc } - buff, err := tarDir(src, 0755) + buff, err := tarDir(src, 0o755) if err != nil { t.Fatal(err) } @@ -117,7 +117,7 @@ func Test_TarFile(t *testing.T) { t.Fatal(err) } - buff, err := tarFile(b, "Docker.file", 0755) + buff, err := tarFile(b, "Docker.file", 0o755) if err != nil { t.Fatal(err) } @@ -177,7 +177,7 @@ func untar(dst string, r io.Reader) error { // if its a dir and it doesn't exist create it case tar.TypeDir: if _, err := os.Stat(target); err != nil { - if err := os.MkdirAll(target, 0755); err != nil { + if err := os.MkdirAll(target, 0o755); err != nil { return err } } diff --git a/generic.go b/generic.go index 0b8d46f1f3..85b1542c7d 100644 --- a/generic.go +++ b/generic.go @@ -10,6 +10,7 @@ import ( "dario.cat/mergo" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/generic_test.go b/generic_test.go index f71fb59dae..77faa919c2 100644 --- a/generic_test.go +++ b/generic_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/internal/config/config.go b/internal/config/config.go index 5460d6d67e..dd5731e0f7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -10,8 +10,10 @@ import ( "github.com/magiconair/properties" ) -var tcConfig Config -var tcConfigOnce *sync.Once = new(sync.Once) +var ( + tcConfig Config + tcConfigOnce *sync.Once = new(sync.Once) +) // Config represents the configuration for Testcontainers // testcontainersConfig { diff --git a/internal/testcontainersdocker/client.go b/internal/testcontainersdocker/client.go index 27eb87a473..ca88b2af4b 100644 --- a/internal/testcontainersdocker/client.go +++ b/internal/testcontainersdocker/client.go @@ -5,6 +5,7 @@ import ( "path/filepath" "github.com/docker/docker/client" + "github.com/testcontainers/testcontainers-go/internal" "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/testcontainerssession" diff --git a/internal/testcontainersdocker/docker_host.go b/internal/testcontainersdocker/docker_host.go index a9a6f328cb..6d96029a9c 100644 --- a/internal/testcontainersdocker/docker_host.go +++ b/internal/testcontainersdocker/docker_host.go @@ -10,6 +10,7 @@ import ( "sync" "github.com/docker/docker/client" + "github.com/testcontainers/testcontainers-go/internal/config" ) @@ -29,11 +30,15 @@ var ( ErrTestcontainersHostNotSetInProperties = errors.New("tc.host not set in ~/.testcontainers.properties") ) -var dockerHostCache string -var dockerHostOnce sync.Once +var ( + dockerHostCache string + dockerHostOnce sync.Once +) -var dockerSocketPathCache string -var dockerSocketPathOnce sync.Once +var ( + dockerSocketPathCache string + dockerSocketPathOnce sync.Once +) // deprecated // see https://github.com/testcontainers/testcontainers-java/blob/main/core/src/main/java/org/testcontainers/dockerclient/DockerClientConfigUtils.java#L46 diff --git a/internal/testcontainersdocker/docker_host_test.go b/internal/testcontainersdocker/docker_host_test.go index 0cc1063abc..45684e134b 100644 --- a/internal/testcontainersdocker/docker_host_test.go +++ b/internal/testcontainersdocker/docker_host_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/client" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/internal/config" ) @@ -21,8 +22,10 @@ var ( originalDockerSocketPathWithSchema string ) -var originalDockerSocketOverride string -var tmpSchema string +var ( + originalDockerSocketOverride string + tmpSchema string +) func init() { originalDockerSocketPath = DockerSocketPath @@ -403,7 +406,7 @@ func TestInAContainer(t *testing.T) { } func createTmpDir(dir string) error { - err := os.MkdirAll(dir, 0755) + err := os.MkdirAll(dir, 0o755) if err != nil { return err } @@ -413,7 +416,7 @@ func createTmpDir(dir string) error { func createTmpDockerSocket(parent string) error { socketPath := filepath.Join(parent, "docker.sock") - err := os.MkdirAll(filepath.Dir(socketPath), 0755) + err := os.MkdirAll(filepath.Dir(socketPath), 0o755) if err != nil { return err } diff --git a/internal/testcontainersdocker/docker_rootless_test.go b/internal/testcontainersdocker/docker_rootless_test.go index 40d82d36a8..faa43b3000 100644 --- a/internal/testcontainersdocker/docker_rootless_test.go +++ b/internal/testcontainersdocker/docker_rootless_test.go @@ -11,9 +11,11 @@ import ( "github.com/stretchr/testify/require" ) -var originalBaseRunDir string -var originalXDGRuntimeDir string -var originalHomeDir string +var ( + originalBaseRunDir string + originalXDGRuntimeDir string + originalHomeDir string +) func init() { originalBaseRunDir = baseRunDir diff --git a/internal/testcontainersdocker/images.go b/internal/testcontainersdocker/images.go index 3dc10c2a45..b462007a44 100644 --- a/internal/testcontainersdocker/images.go +++ b/internal/testcontainersdocker/images.go @@ -60,7 +60,7 @@ func ExtractImagesFromDockerfile(dockerfile string, buildArgs map[string]*string // interpolate build args for k, v := range buildArgs { if v != nil { - parts[0] = strings.Replace(parts[0], "${"+k+"}", *v, -1) + parts[0] = strings.ReplaceAll(parts[0], "${"+k+"}", *v) } } images = append(images, parts[0]) diff --git a/internal/testcontainerssession/session.go b/internal/testcontainerssession/session.go index 21bd1f9800..ed98808a69 100644 --- a/internal/testcontainerssession/session.go +++ b/internal/testcontainerssession/session.go @@ -6,8 +6,10 @@ import ( "github.com/google/uuid" ) -var id uuid.UUID -var idOnce sync.Once +var ( + id uuid.UUID + idOnce sync.Once +) func ID() uuid.UUID { idOnce.Do(func() { diff --git a/lifecycle_test.go b/lifecycle_test.go index 6aed6befc2..87b55f1436 100644 --- a/lifecycle_test.go +++ b/lifecycle_test.go @@ -15,6 +15,7 @@ import ( "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) @@ -559,7 +560,6 @@ func TestLifecycleHooks(t *testing.T) { lifecycleHooksIsHonouredFn(t, ctx, c, prints) }) } - } type inMemoryLogger struct { @@ -704,7 +704,6 @@ func TestPrintContainerLogsOnError(t *testing.T) { } assert.True(t, found, "container log line not found in the output of the logger: %s", line) } - } func lifecycleHooksIsHonouredFn(t *testing.T, ctx context.Context, container Container, prints []string) { diff --git a/logconsumer_test.go b/logconsumer_test.go index 08f2a6ba60..d1176944a8 100644 --- a/logconsumer_test.go +++ b/logconsumer_test.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/client" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/logger.go b/logger.go index 3a2b30b1ce..917f7eaba5 100644 --- a/logger.go +++ b/logger.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/docker/docker/client" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" ) diff --git a/modulegen/dependabot.go b/modulegen/dependabot.go index a06990fc99..d0807f635e 100644 --- a/modulegen/dependabot.go +++ b/modulegen/dependabot.go @@ -134,5 +134,5 @@ func writeDependabotConfig(rootDir string, config *DependabotConfig) error { data = append([]byte(header), data...) - return os.WriteFile(file, data, 0777) + return os.WriteFile(file, data, 0o777) } diff --git a/modulegen/dependabot_test.go b/modulegen/dependabot_test.go index 5b512637b1..7dab43fcb6 100644 --- a/modulegen/dependabot_test.go +++ b/modulegen/dependabot_test.go @@ -16,10 +16,10 @@ func TestGetDependabotConfigFile(t *testing.T) { rootDir := filepath.Join(tmp, "testcontainers-go") githubDir := filepath.Join(rootDir, ".github") cfgFile := filepath.Join(githubDir, "dependabot.yml") - err := os.MkdirAll(githubDir, 0777) + err := os.MkdirAll(githubDir, 0o777) require.NoError(t, err) - err = os.WriteFile(cfgFile, []byte{}, 0777) + err = os.WriteFile(cfgFile, []byte{}, 0o777) require.NoError(t, err) file := getDependabotConfigFile(rootDir) @@ -59,7 +59,7 @@ func TestReadDependabotConfig(t *testing.T) { rootDir := filepath.Join(tmp, "testcontainers-go") githubDir := filepath.Join(rootDir, ".github") - err := os.MkdirAll(githubDir, 0777) + err := os.MkdirAll(githubDir, 0o777) require.NoError(t, err) err = copyInitialDependabotConfig(t, rootDir) diff --git a/modulegen/main.go b/modulegen/main.go index aa31d18297..99acaf5925 100644 --- a/modulegen/main.go +++ b/modulegen/main.go @@ -17,10 +17,12 @@ import ( "golang.org/x/text/language" ) -var asModuleVar bool -var nameVar string -var nameTitleVar string -var imageVar string +var ( + asModuleVar bool + nameVar string + nameTitleVar string + imageVar string +) var templates = []string{ "ci.yml", "docs_example.md", "example_test.go", "example.go", "go.mod", "Makefile", @@ -188,7 +190,7 @@ func generate(example Example, rootDir string) error { exampleLower := example.Lower() // create the example dir - err := os.MkdirAll(filepath.Join(outputDir, exampleLower), 0700) + err := os.MkdirAll(filepath.Join(outputDir, exampleLower), 0o700) if err != nil { return err } @@ -242,7 +244,7 @@ func generate(example Example, rootDir string) error { exampleFilePath = filepath.Join(outputDir, exampleLower, strings.ReplaceAll(tmpl, "example", exampleLower)) } - err = os.MkdirAll(filepath.Dir(exampleFilePath), 0777) + err = os.MkdirAll(filepath.Dir(exampleFilePath), 0o777) if err != nil { return err } diff --git a/modulegen/main_test.go b/modulegen/main_test.go index 43d3300bae..c023d60656 100644 --- a/modulegen/main_test.go +++ b/modulegen/main_test.go @@ -154,11 +154,11 @@ func TestGenerateWrongExampleName(t *testing.T) { examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") - err := os.MkdirAll(examplesTmp, 0777) + err := os.MkdirAll(examplesTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(examplesDocTmp, 0777) + err = os.MkdirAll(examplesDocTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(githubWorkflowsTmp, 0777) + err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) err = copyInitialMkdocsConfig(t, rootTmp) @@ -197,11 +197,11 @@ func TestGenerateWrongExampleTitle(t *testing.T) { examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") - err := os.MkdirAll(examplesTmp, 0777) + err := os.MkdirAll(examplesTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(examplesDocTmp, 0777) + err = os.MkdirAll(examplesDocTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(githubWorkflowsTmp, 0777) + err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) err = copyInitialMkdocsConfig(t, rootTmp) @@ -241,11 +241,11 @@ func TestGenerate(t *testing.T) { examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") - err := os.MkdirAll(examplesTmp, 0777) + err := os.MkdirAll(examplesTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(examplesDocTmp, 0777) + err = os.MkdirAll(examplesDocTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(githubWorkflowsTmp, 0777) + err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) err = copyInitialMkdocsConfig(t, rootTmp) @@ -312,11 +312,11 @@ func TestGenerateModule(t *testing.T) { modulesDocTmp := filepath.Join(rootTmp, "docs", "modules") githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") - err := os.MkdirAll(modulesTmp, 0777) + err := os.MkdirAll(modulesTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(modulesDocTmp, 0777) + err = os.MkdirAll(modulesDocTmp, 0o777) assert.Nil(t, err) - err = os.MkdirAll(githubWorkflowsTmp, 0777) + err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) err = copyInitialMkdocsConfig(t, rootTmp) diff --git a/modulegen/mkdocs.go b/modulegen/mkdocs.go index 815483524c..ed41f3dfa8 100644 --- a/modulegen/mkdocs.go +++ b/modulegen/mkdocs.go @@ -63,10 +63,6 @@ func getExamplesDocs() ([]os.DirEntry, error) { return os.ReadDir(dir) } -func getModules() ([]os.DirEntry, error) { - return getModulesOrExamples(true) -} - func getRootDir() (string, error) { current, err := os.Getwd() if err != nil { @@ -102,5 +98,5 @@ func writeMkdocsConfig(rootDir string, config *MkDocsConfig) error { file := getMkdocsConfigFile(rootDir) - return os.WriteFile(file, data, 0777) + return os.WriteFile(file, data, 0o777) } diff --git a/modulegen/mkdocs_test.go b/modulegen/mkdocs_test.go index 40d0473ba6..d996ecac7c 100644 --- a/modulegen/mkdocs_test.go +++ b/modulegen/mkdocs_test.go @@ -15,10 +15,10 @@ func TestGetMkDocsConfigFile(t *testing.T) { rootDir := filepath.Join(tmp, "testcontainers-go") cfgFile := filepath.Join(rootDir, "mkdocs.yml") - err := os.MkdirAll(rootDir, 0777) + err := os.MkdirAll(rootDir, 0o777) require.NoError(t, err) - err = os.WriteFile(cfgFile, []byte{}, 0777) + err = os.WriteFile(cfgFile, []byte{}, 0o777) require.NoError(t, err) file := getMkdocsConfigFile(rootDir) @@ -31,7 +31,7 @@ func TestReadMkDocsConfig(t *testing.T) { tmp := t.TempDir() rootDir := filepath.Join(tmp, "testcontainers-go") - err := os.MkdirAll(rootDir, 0777) + err := os.MkdirAll(rootDir, 0o777) require.NoError(t, err) err = copyInitialMkdocsConfig(t, rootDir) diff --git a/modules/artemis/artemis.go b/modules/artemis/artemis.go index 64bc588081..a3c26702ad 100644 --- a/modules/artemis/artemis.go +++ b/modules/artemis/artemis.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/modules/artemis/artemis_test.go b/modules/artemis/artemis_test.go index b68fac3f21..4cf70db556 100644 --- a/modules/artemis/artemis_test.go +++ b/modules/artemis/artemis_test.go @@ -10,6 +10,7 @@ import ( "github.com/go-stomp/stomp/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/artemis" ) diff --git a/modules/artemis/example_test.go b/modules/artemis/example_test.go index b626056731..37e05af537 100644 --- a/modules/artemis/example_test.go +++ b/modules/artemis/example_test.go @@ -4,6 +4,7 @@ import ( "context" "github.com/go-stomp/stomp/v3" + "github.com/testcontainers/testcontainers-go/modules/artemis" ) diff --git a/modules/clickhouse/clickhouse.go b/modules/clickhouse/clickhouse.go index 9f59cf7280..3d6b111b56 100644 --- a/modules/clickhouse/clickhouse.go +++ b/modules/clickhouse/clickhouse.go @@ -7,17 +7,22 @@ import ( "strings" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) -const defaultUser = "default" -const defaultDatabaseName = "clickhouse" +const ( + defaultUser = "default" + defaultDatabaseName = "clickhouse" +) const defaultImage = "clickhouse/clickhouse-server:23.3.8.21-alpine" -const httpPort = nat.Port("8123/tcp") -const nativePort = nat.Port("9000/tcp") +const ( + httpPort = nat.Port("8123/tcp") + nativePort = nat.Port("9000/tcp") +) // ClickHouseContainer represents the ClickHouse container type used in the module type ClickHouseContainer struct { @@ -71,7 +76,7 @@ func WithInitScripts(scripts ...string) testcontainers.CustomizeRequestOption { cf := testcontainers.ContainerFile{ HostFilePath: script, ContainerFilePath: "/docker-entrypoint-initdb.d/" + filepath.Base(script), - FileMode: 0755, + FileMode: 0o755, } initScripts = append(initScripts, cf) } @@ -87,7 +92,7 @@ func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption { cf := testcontainers.ContainerFile{ HostFilePath: configFile, ContainerFilePath: "/etc/clickhouse-server/config.d/config.xml", - FileMode: 0755, + FileMode: 0o755, } req.Files = append(req.Files, cf) } @@ -101,7 +106,7 @@ func WithYamlConfigFile(configFile string) testcontainers.CustomizeRequestOption cf := testcontainers.ContainerFile{ HostFilePath: configFile, ContainerFilePath: "/etc/clickhouse-server/config.d/config.yaml", - FileMode: 0755, + FileMode: 0o755, } req.Files = append(req.Files, cf) } diff --git a/modules/clickhouse/clickhouse_test.go b/modules/clickhouse/clickhouse_test.go index f299219b09..5670719e0c 100644 --- a/modules/clickhouse/clickhouse_test.go +++ b/modules/clickhouse/clickhouse_test.go @@ -8,12 +8,15 @@ import ( ch "github.com/ClickHouse/clickhouse-go/v2" "github.com/ClickHouse/clickhouse-go/v2/lib/driver" "github.com/stretchr/testify/assert" + "github.com/testcontainers/testcontainers-go" ) -const dbname = "testdb" -const user = "clickhouse" -const password = "password" +const ( + dbname = "testdb" + user = "clickhouse" + password = "password" +) type Test struct { Id uint64 diff --git a/modules/compose/compose.go b/modules/compose/compose.go index 5ee34a6dd6..6c45d5119b 100644 --- a/modules/compose/compose.go +++ b/modules/compose/compose.go @@ -24,8 +24,10 @@ const ( envComposeFile = "COMPOSE_FILE" ) -var composeLogOnce sync.Once -var ErrNoStackConfigured = errors.New("no stack files configured") +var ( + composeLogOnce sync.Once + ErrNoStackConfigured = errors.New("no stack files configured") +) type composeStackOptions struct { Identifier string diff --git a/modules/compose/compose_api_test.go b/modules/compose/compose_api_test.go index f9c875bc6e..152d348ea7 100644 --- a/modules/compose/compose_api_test.go +++ b/modules/compose/compose_api_test.go @@ -485,7 +485,7 @@ func TestDockerComposeApiWithWaitForShortLifespanService(t *testing.T) { t.Cleanup(cancel) err = compose. - //Assumption: tzatziki service wait logic will run before falafel, so that falafel service will exit before + // Assumption: tzatziki service wait logic will run before falafel, so that falafel service will exit before WaitForService("tzatziki", wait.ForExit().WithExitTimeout(10*time.Second)). WaitForService("falafel", wait.ForExit().WithExitTimeout(10*time.Second)). Up(ctx) diff --git a/modules/compose/compose_local.go b/modules/compose/compose_local.go index 3b58989ec6..ba4fb8beef 100644 --- a/modules/compose/compose_local.go +++ b/modules/compose/compose_local.go @@ -30,15 +30,13 @@ type ComposeVersion interface { Format(parts ...string) string } -type composeVersion1 struct { -} +type composeVersion1 struct{} func (c composeVersion1) Format(parts ...string) string { return strings.Join(parts, "_") } -type composeVersion2 struct { -} +type composeVersion2 struct{} func (c composeVersion2) Format(parts ...string) string { return strings.Join(parts, "-") @@ -279,8 +277,8 @@ type ExecError struct { // execute executes a program with arguments and environment variables inside a specific directory func execute( - dirContext string, environment map[string]string, binary string, args []string) ExecError { - + dirContext string, environment map[string]string, binary string, args []string, +) ExecError { var errStdout, errStderr error cmd := exec.Command(binary, args...) diff --git a/modules/compose/compose_test.go b/modules/compose/compose_test.go index caf755f7e1..548e27fd36 100644 --- a/modules/compose/compose_test.go +++ b/modules/compose/compose_test.go @@ -19,8 +19,10 @@ import ( "github.com/testcontainers/testcontainers-go/wait" ) -var complexComposeTestFile string = filepath.Join("testdata", "docker-compose-complex.yml") -var simpleComposeTestFile string = filepath.Join("testdata", "docker-compose-simple.yml") +var ( + complexComposeTestFile string = filepath.Join("testdata", "docker-compose-complex.yml") + simpleComposeTestFile string = filepath.Join("testdata", "docker-compose-simple.yml") +) func ExampleNewLocalDockerCompose() { path := "/path/to/docker-compose.yml" @@ -116,6 +118,7 @@ func TestLocalDockerCompose(t *testing.T) { Invoke() checkIfError(t, err) } + func TestDockerComposeStrategyForInvalidService(t *testing.T) { path := simpleComposeTestFile @@ -202,7 +205,7 @@ func TestDockerComposeWithWaitForShortLifespanService(t *testing.T) { err := compose. WithCommand([]string{"up", "-d"}). - //Assumption: tzatziki service wait logic will run before falafel, so that falafel service will exit before + // Assumption: tzatziki service wait logic will run before falafel, so that falafel service will exit before WaitForService(compose.Format("tzatziki", "1"), wait.ForExit().WithExitTimeout(10*time.Second)). WaitForService(compose.Format("falafel", "1"), wait.ForExit().WithExitTimeout(10*time.Second)). Invoke() diff --git a/modules/compose/testdata/echoserver.go b/modules/compose/testdata/echoserver.go index 1b331e8890..090e7fcf58 100644 --- a/modules/compose/testdata/echoserver.go +++ b/modules/compose/testdata/echoserver.go @@ -10,7 +10,6 @@ import ( func envHandler() http.HandlerFunc { return func(rw http.ResponseWriter, req *http.Request) { - _, _ = rw.Write([]byte(os.Getenv("FOO"))) rw.WriteHeader(http.StatusAccepted) diff --git a/modules/couchbase/couchbase.go b/modules/couchbase/couchbase.go index b452a92ef5..7e0e87e2eb 100644 --- a/modules/couchbase/couchbase.go +++ b/modules/couchbase/couchbase.go @@ -12,9 +12,10 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/docker/go-connections/nat" + "github.com/tidwall/gjson" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" - "github.com/tidwall/gjson" ) // containerPorts { diff --git a/modules/couchbase/couchbase_test.go b/modules/couchbase/couchbase_test.go index 4e721390c9..605fa00d1e 100644 --- a/modules/couchbase/couchbase_test.go +++ b/modules/couchbase/couchbase_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/couchbase/gocb/v2" + "github.com/testcontainers/testcontainers-go" tccouchbase "github.com/testcontainers/testcontainers-go/modules/couchbase" ) @@ -108,7 +109,6 @@ func TestWithCredentials(t *testing.T) { testcontainers.WithImage(communityEdition), tccouchbase.WithAdminCredentials("testcontainers", "testcontainers.IS.cool!"), tccouchbase.WithBuckets(tccouchbase.NewBucket(bucketName))) - if err != nil { t.Errorf("Expected error to be [%v] , got nil", err) } @@ -179,7 +179,7 @@ func testBucketUsage(t *testing.T, bucket *gocb.Bucket) { var resultData map[string]string err = result.Content(&resultData) if err != nil { - t.Fatalf("could not asign content: %s", err) + t.Fatalf("could not assign content: %s", err) } if resultData["key"] != "value" { diff --git a/modules/k3s/k3s.go b/modules/k3s/k3s.go index 30f7c348d5..fa8c43bb0a 100644 --- a/modules/k3s/k3s.go +++ b/modules/k3s/k3s.go @@ -8,9 +8,10 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" "github.com/docker/go-connections/nat" + "gopkg.in/yaml.v3" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" - "gopkg.in/yaml.v3" ) var ( @@ -47,7 +48,6 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize "/var/run": "", } hc.Mounts = []mount.Mount{} - }, Cmd: []string{ "server", @@ -134,7 +134,6 @@ func (c *K3sContainer) GetKubeConfig(ctx context.Context) ([]byte, error) { } func kubeConfigWithServerUrl(kubeConfigYaml, server string) ([]byte, error) { - kubeConfig, err := unmarshal([]byte(kubeConfigYaml)) if err != nil { return nil, fmt.Errorf("failed to unmarshal kubeconfig: %w", err) diff --git a/modules/k3s/k3s_test.go b/modules/k3s/k3s_test.go index 71f2ec5827..e55f1e0aad 100644 --- a/modules/k3s/k3s_test.go +++ b/modules/k3s/k3s_test.go @@ -5,11 +5,12 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/wait" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) func TestK3s(t *testing.T) { diff --git a/modules/localstack/localstack.go b/modules/localstack/localstack.go index 8046b8e40b..f5aca5b031 100644 --- a/modules/localstack/localstack.go +++ b/modules/localstack/localstack.go @@ -6,21 +6,19 @@ import ( "strings" "time" + "golang.org/x/mod/semver" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" - "golang.org/x/mod/semver" ) -const defaultPort = 4566 -const defaultRegion = "us-east-1" -const defaultVersion = "1.4.0" -const hostnameExternalEnvVar = "HOSTNAME_EXTERNAL" -const localstackHostEnvVar = "LOCALSTACK_HOST" - -const defaultAccessKeyID = "accesskey" -const defaultSecretAccessKey = "secretkey" -const defaultToken = "token" +const ( + defaultPort = 4566 + defaultVersion = "1.4.0" + hostnameExternalEnvVar = "HOSTNAME_EXTERNAL" + localstackHostEnvVar = "LOCALSTACK_HOST" +) func isLegacyMode(image string) bool { parts := strings.Split(image, ":") diff --git a/modules/localstack/localstack_legacy_mode_test.go b/modules/localstack/localstack_legacy_mode_test.go index 4356c8f2c9..40a8271b43 100644 --- a/modules/localstack/localstack_legacy_mode_test.go +++ b/modules/localstack/localstack_legacy_mode_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/modules/localstack/localstack_test.go b/modules/localstack/localstack_test.go index de99d150b4..857808a2ee 100644 --- a/modules/localstack/localstack_test.go +++ b/modules/localstack/localstack_test.go @@ -8,11 +8,11 @@ import ( "testing" "time" - "github.com/testcontainers/testcontainers-go/wait" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) func generateContainerRequest() *LocalStackContainerRequest { @@ -246,8 +246,10 @@ func TestStartV2WithNetwork(t *testing.T) { "AWS_SECRET_ACCESS_KEY": "secretkey", "AWS_REGION": "eu-west-1", }, - WaitingFor: wait.ForExec([]string{"/usr/local/bin/aws", "sqs", "create-queue", "--queue-name", "baz", "--region", "eu-west-1", - "--endpoint-url", "http://localstack:4566", "--no-verify-ssl"}). + WaitingFor: wait.ForExec([]string{ + "/usr/local/bin/aws", "sqs", "create-queue", "--queue-name", "baz", "--region", "eu-west-1", + "--endpoint-url", "http://localstack:4566", "--no-verify-ssl", + }). WithStartupTimeout(time.Second * 10). WithExitCodeMatcher(func(exitCode int) bool { return exitCode == 0 diff --git a/modules/localstack/v1/s3_test.go b/modules/localstack/v1/s3_test.go index 3dbf2297a8..5d60747258 100644 --- a/modules/localstack/v1/s3_test.go +++ b/modules/localstack/v1/s3_test.go @@ -14,6 +14,7 @@ import ( "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/localstack" ) diff --git a/modules/localstack/v2/s3_test.go b/modules/localstack/v2/s3_test.go index 66286f671f..7de829d9f8 100644 --- a/modules/localstack/v2/s3_test.go +++ b/modules/localstack/v2/s3_test.go @@ -13,6 +13,7 @@ import ( "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/modules/localstack" ) diff --git a/modules/mysql/mysql.go b/modules/mysql/mysql.go index 8390e9b272..ec98b481be 100644 --- a/modules/mysql/mysql.go +++ b/modules/mysql/mysql.go @@ -10,10 +10,12 @@ import ( "github.com/testcontainers/testcontainers-go/wait" ) -const rootUser = "root" -const defaultUser = "test" -const defaultPassword = "test" -const defaultDatabaseName = "test" +const ( + rootUser = "root" + defaultUser = "test" + defaultPassword = "test" + defaultDatabaseName = "test" +) // defaultImage { const defaultImage = "mysql:8" @@ -134,7 +136,7 @@ func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption { cf := testcontainers.ContainerFile{ HostFilePath: configFile, ContainerFilePath: "/etc/mysql/conf.d/my.cnf", - FileMode: 0755, + FileMode: 0o755, } req.Files = append(req.Files, cf) } @@ -147,7 +149,7 @@ func WithScripts(scripts ...string) testcontainers.CustomizeRequestOption { cf := testcontainers.ContainerFile{ HostFilePath: script, ContainerFilePath: "/docker-entrypoint-initdb.d/" + filepath.Base(script), - FileMode: 0755, + FileMode: 0o755, } initScripts = append(initScripts, cf) } diff --git a/modules/mysql/mysql_test.go b/modules/mysql/mysql_test.go index fe578b0f00..41ac2f828b 100644 --- a/modules/mysql/mysql_test.go +++ b/modules/mysql/mysql_test.go @@ -8,6 +8,7 @@ import ( // Import mysql into the scope of this package (required) _ "github.com/go-sql-driver/mysql" + "github.com/testcontainers/testcontainers-go" ) @@ -145,7 +146,7 @@ func TestMySQLWithConfigFile(t *testing.T) { } defer stmt.Close() row := stmt.QueryRow() - var innodbFileFormat = "" + innodbFileFormat := "" err = row.Scan(&innodbFileFormat) if err != nil { t.Errorf("error fetching innodb_file_format value") diff --git a/modules/neo4j/neo4j.go b/modules/neo4j/neo4j.go index aa7a33c782..62dd7e3763 100644 --- a/modules/neo4j/neo4j.go +++ b/modules/neo4j/neo4j.go @@ -6,6 +6,7 @@ import ( "net/http" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/modules/neo4j/neo4j_test.go b/modules/neo4j/neo4j_test.go index 9429511d88..35294a246c 100644 --- a/modules/neo4j/neo4j_test.go +++ b/modules/neo4j/neo4j_test.go @@ -8,6 +8,7 @@ import ( "testing" neo "github.com/neo4j/neo4j-go-driver/v5/neo4j" + "github.com/testcontainers/testcontainers-go/modules/neo4j" ) @@ -30,7 +31,6 @@ func TestNeo4j(outer *testing.T) { driver := createDriver(t, ctx, container) err := driver.VerifyConnectivity(ctx) - if err != nil { t.Fatalf("should have successfully connected to server but did not: %s", err) } @@ -42,7 +42,6 @@ func TestNeo4j(outer *testing.T) { result, err := neo.ExecuteQuery(ctx, driver, "RETURN apoc.number.arabicToRoman(1986) AS output", nil, neo.EagerResultTransformer) - if err != nil { t.Fatalf("expected APOC query to successfully run but did not: %s", err) } @@ -175,7 +174,6 @@ func createDriver(t *testing.T, ctx context.Context, container *neo4j.Neo4jConta func getContainerEnv(t *testing.T, ctx context.Context, container *neo4j.Neo4jContainer) string { exec, reader, err := container.Exec(ctx, []string{"env"}) - if err != nil { t.Fatalf("expected env to successfully run but did not: %s", err) } diff --git a/modules/postgres/postgres.go b/modules/postgres/postgres.go index 95e598b228..b50f58737a 100644 --- a/modules/postgres/postgres.go +++ b/modules/postgres/postgres.go @@ -10,9 +10,11 @@ import ( "github.com/testcontainers/testcontainers-go" ) -const defaultUser = "postgres" -const defaultPassword = "postgres" -const defaultPostgresImage = "docker.io/postgres:11-alpine" +const ( + defaultUser = "postgres" + defaultPassword = "postgres" + defaultPostgresImage = "docker.io/postgres:11-alpine" +) // PostgresContainer represents the postgres container type used in the module type PostgresContainer struct { @@ -50,7 +52,7 @@ func WithConfigFile(cfg string) testcontainers.CustomizeRequestOption { cfgFile := testcontainers.ContainerFile{ HostFilePath: cfg, ContainerFilePath: "/etc/postgresql.conf", - FileMode: 0755, + FileMode: 0o755, } req.Files = append(req.Files, cfgFile) @@ -75,7 +77,7 @@ func WithInitScripts(scripts ...string) testcontainers.CustomizeRequestOption { cf := testcontainers.ContainerFile{ HostFilePath: script, ContainerFilePath: "/docker-entrypoint-initdb.d/" + filepath.Base(script), - FileMode: 0755, + FileMode: 0o755, } initScripts = append(initScripts, cf) } diff --git a/modules/postgres/postgres_test.go b/modules/postgres/postgres_test.go index bf2c5e13c3..f375268940 100644 --- a/modules/postgres/postgres_test.go +++ b/modules/postgres/postgres_test.go @@ -10,16 +10,18 @@ import ( "github.com/docker/go-connections/nat" _ "github.com/lib/pq" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) -const dbname = "test-db" -const user = "postgres" -const password = "password" +const ( + dbname = "test-db" + user = "postgres" + password = "password" +) func TestPostgres(t *testing.T) { ctx := context.Background() @@ -103,7 +105,7 @@ func TestPostgres(t *testing.T) { func TestContainerWithWaitForSQL(t *testing.T) { ctx := context.Background() - var port = "5432/tcp" + port := "5432/tcp" dbURL := func(host string, port nat.Port) string { return fmt.Sprintf("postgres://postgres:password@%s:%s/%s?sslmode=disable", host, port.Port(), dbname) } diff --git a/modules/pulsar/pulsar.go b/modules/pulsar/pulsar.go index 47fc2da0da..eeb8f907b0 100644 --- a/modules/pulsar/pulsar.go +++ b/modules/pulsar/pulsar.go @@ -7,16 +7,19 @@ import ( "strings" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) -const defaultPulsarImage = "docker.io/apachepulsar/pulsar:2.10.2" -const defaultPulsarPort = "6650/tcp" -const defaultPulsarAdminPort = "8080/tcp" -const defaultPulsarCmd = "/pulsar/bin/apply-config-from-env.py /pulsar/conf/standalone.conf && bin/pulsar standalone" -const detaultPulsarCmdWithoutFunctionsWorker = "--no-functions-worker -nss" -const transactionTopicEndpoint = "/admin/v2/persistent/pulsar/system/transaction_coordinator_assign/partitions" +const ( + defaultPulsarImage = "docker.io/apachepulsar/pulsar:2.10.2" + defaultPulsarPort = "6650/tcp" + defaultPulsarAdminPort = "8080/tcp" + defaultPulsarCmd = "/pulsar/bin/apply-config-from-env.py /pulsar/conf/standalone.conf && bin/pulsar standalone" + detaultPulsarCmdWithoutFunctionsWorker = "--no-functions-worker -nss" + transactionTopicEndpoint = "/admin/v2/persistent/pulsar/system/transaction_coordinator_assign/partitions" +) var defaultWaitStrategies = wait.ForAll( wait.ForHTTP("/admin/v2/clusters").WithPort(defaultPulsarAdminPort).WithResponseMatcher(func(r io.Reader) bool { @@ -121,8 +124,9 @@ func WithTransactions() testcontainers.CustomizeRequestOption { // - image: docker.io/apachepulsar/pulsar:2.10.2 // - exposed ports: 6650/tcp, 8080/tcp // - waiting strategy: wait for all the following strategies: -// - the Pulsar admin API ("/admin/v2/clusters") to be ready on port 8080/tcp and return the response `["standalone"]` -// - the log message "Successfully updated the policies on namespace public/default" +// - the Pulsar admin API ("/admin/v2/clusters") to be ready on port 8080/tcp and return the response `["standalone"]` +// - the log message "Successfully updated the policies on namespace public/default" +// // - command: "/bin/bash -c /pulsar/bin/apply-config-from-env.py /pulsar/conf/standalone.conf && bin/pulsar standalone --no-functions-worker -nss" func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*Container, error) { req := testcontainers.ContainerRequest{ diff --git a/modules/pulsar/pulsar_test.go b/modules/pulsar/pulsar_test.go index f994f3e33c..208cd094b2 100644 --- a/modules/pulsar/pulsar_test.go +++ b/modules/pulsar/pulsar_test.go @@ -15,6 +15,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" testcontainerspulsar "github.com/testcontainers/testcontainers-go/modules/pulsar" ) diff --git a/modules/redis/redis.go b/modules/redis/redis.go index c4f20852a1..a828816d73 100644 --- a/modules/redis/redis.go +++ b/modules/redis/redis.go @@ -80,7 +80,7 @@ func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption { cf := testcontainers.ContainerFile{ HostFilePath: configFile, ContainerFilePath: defaultConfigFile, - FileMode: 0755, + FileMode: 0o755, } req.Files = append(req.Files, cf) diff --git a/modules/redis/redis_test.go b/modules/redis/redis_test.go index b9cffc032e..fd29c81432 100644 --- a/modules/redis/redis_test.go +++ b/modules/redis/redis_test.go @@ -10,6 +10,7 @@ import ( "github.com/go-redis/redis/v8" "github.com/google/uuid" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go" ) @@ -130,7 +131,7 @@ func assertSetsGets(t *testing.T, ctx context.Context, redisContainer *RedisCont // } // You will likely want to wrap your Redis package of choice in an - // interface to aid in unit testing and limit lock-in throughtout your + // interface to aid in unit testing and limit lock-in throughout your // codebase but that's out of scope for this example options, err := redis.ParseURL(uri) require.NoError(t, err) diff --git a/modules/redpanda/redpanda.go b/modules/redpanda/redpanda.go index cc373b42cd..944a6d112a 100644 --- a/modules/redpanda/redpanda.go +++ b/modules/redpanda/redpanda.go @@ -254,7 +254,7 @@ func createBootstrapConfigFile(settings options) (*os.File, error) { return bootstrapTmpFile, nil } -// renderNodeConfig renders the redpanda.yaml node config and retuns it as +// renderNodeConfig renders the redpanda.yaml node config and returns it as // byte array. func renderNodeConfig(settings options, hostIP string, advertisedKafkaPort int) ([]byte, error) { tplParams := redpandaConfigTplParams{ diff --git a/modules/vault/vault.go b/modules/vault/vault.go index d5e655f9bf..ca5ab4bb13 100644 --- a/modules/vault/vault.go +++ b/modules/vault/vault.go @@ -5,10 +5,10 @@ import ( "fmt" "strings" - "github.com/testcontainers/testcontainers-go/wait" - "github.com/docker/docker/api/types/container" + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/wait" ) const ( diff --git a/modules/vault/vault_test.go b/modules/vault/vault_test.go index 008f5f5ff6..c139c91611 100644 --- a/modules/vault/vault_test.go +++ b/modules/vault/vault_test.go @@ -12,9 +12,10 @@ import ( vaultClient "github.com/hashicorp/vault-client-go" "github.com/hashicorp/vault-client-go/schema" "github.com/stretchr/testify/assert" + "github.com/tidwall/gjson" + "github.com/testcontainers/testcontainers-go" testcontainervault "github.com/testcontainers/testcontainers-go/modules/vault" - "github.com/tidwall/gjson" ) const ( diff --git a/mounts.go b/mounts.go index c4b6fc916a..85fcfa8b63 100644 --- a/mounts.go +++ b/mounts.go @@ -63,8 +63,7 @@ func (GenericVolumeMountSource) Type() MountType { // GenericTmpfsMountSource implements ContainerMountSource and represents a TmpFS mount // Optionally mount.TmpfsOptions might be added for advanced scenarios -type GenericTmpfsMountSource struct { -} +type GenericTmpfsMountSource struct{} func (s GenericTmpfsMountSource) Source() string { return "" diff --git a/mounts_test.go b/mounts_test.go index c445e24d64..16a6458ed4 100644 --- a/mounts_test.go +++ b/mounts_test.go @@ -6,6 +6,7 @@ import ( "github.com/docker/docker/api/types/mount" "github.com/stretchr/testify/assert" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" ) diff --git a/network_test.go b/network_test.go index 453c854114..52b44c1e96 100644 --- a/network_test.go +++ b/network_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/stretchr/testify/assert" + "github.com/testcontainers/testcontainers-go/wait" ) @@ -68,7 +69,6 @@ func Test_NetworkWithIPAM(t *testing.T) { IPAM: &ipamConfig, }, }) - if err != nil { t.Fatal("cannot create network: ", err) } @@ -129,7 +129,6 @@ func Test_MultipleContainersInTheNewNetwork(t *testing.T) { net, err := GenericNetwork(ctx, GenericNetworkRequest{ NetworkRequest: networkRequest, }) - if err != nil { t.Fatal("cannot create network") } diff --git a/parallel.go b/parallel.go index 297ab9d6dc..34740eeaf4 100644 --- a/parallel.go +++ b/parallel.go @@ -36,8 +36,8 @@ func parallelContainersRunner( requests <-chan GenericContainerRequest, errors chan<- ParallelContainersRequestError, containers chan<- Container, - wg *sync.WaitGroup) { - + wg *sync.WaitGroup, +) { for req := range requests { c, err := GenericContainer(ctx, req) if err != nil { @@ -101,7 +101,6 @@ func ParallelContainers(ctx context.Context, reqs ParallelContainerRequest, opt break } } - }() for _, req := range reqs { diff --git a/parallel_test.go b/parallel_test.go index 3a23c47e57..7195c9f4f3 100644 --- a/parallel_test.go +++ b/parallel_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/wait" ) @@ -22,7 +23,6 @@ func TestParallelContainers(t *testing.T) { reqs: ParallelContainerRequest{ { ContainerRequest: ContainerRequest{ - Image: "nginx", ExposedPorts: []string{ "10080/tcp", @@ -32,7 +32,6 @@ func TestParallelContainers(t *testing.T) { }, { ContainerRequest: ContainerRequest{ - Image: "bad bad bad", ExposedPorts: []string{ "10081/tcp", @@ -49,7 +48,6 @@ func TestParallelContainers(t *testing.T) { reqs: ParallelContainerRequest{ { ContainerRequest: ContainerRequest{ - Image: "bad bad bad", ExposedPorts: []string{ "10081/tcp", @@ -59,7 +57,6 @@ func TestParallelContainers(t *testing.T) { }, { ContainerRequest: ContainerRequest{ - Image: "bad bad bad", ExposedPorts: []string{ "10081/tcp", @@ -76,7 +73,6 @@ func TestParallelContainers(t *testing.T) { reqs: ParallelContainerRequest{ { ContainerRequest: ContainerRequest{ - Image: "nginx", ExposedPorts: []string{ "10080/tcp", @@ -86,7 +82,6 @@ func TestParallelContainers(t *testing.T) { }, { ContainerRequest: ContainerRequest{ - Image: "nginx", ExposedPorts: []string{ "10081/tcp", diff --git a/provider_test.go b/provider_test.go index a634ef7914..3459dfe634 100644 --- a/provider_test.go +++ b/provider_test.go @@ -8,7 +8,7 @@ import ( ) func TestProviderTypeGetProviderAutodetect(t *testing.T) { - var dockerHost = testcontainersdocker.ExtractDockerHost(context.Background()) + dockerHost := testcontainersdocker.ExtractDockerHost(context.Background()) const podmanSocket = "unix://$XDG_RUNTIME_DIR/podman/podman.sock" tests := []struct { diff --git a/reaper.go b/reaper.go index 5813f0992a..d55a6d6d55 100644 --- a/reaper.go +++ b/reaper.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/reaper_test.go b/reaper_test.go index 9f955f366d..511a216d34 100644 --- a/reaper_test.go +++ b/reaper_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" diff --git a/testdata/echoserver.go b/testdata/echoserver.go index 019c825cd6..db5798699a 100644 --- a/testdata/echoserver.go +++ b/testdata/echoserver.go @@ -10,7 +10,6 @@ import ( func envHandler() http.HandlerFunc { return func(rw http.ResponseWriter, req *http.Request) { - _, _ = rw.Write([]byte(os.Getenv("FOO"))) rw.WriteHeader(http.StatusAccepted) diff --git a/wait/all.go b/wait/all.go index 18531cbf54..fb097fb5ea 100644 --- a/wait/all.go +++ b/wait/all.go @@ -7,8 +7,10 @@ import ( ) // Implement interface -var _ Strategy = (*MultiStrategy)(nil) -var _ StrategyTimeout = (*MultiStrategy)(nil) +var ( + _ Strategy = (*MultiStrategy)(nil) + _ StrategyTimeout = (*MultiStrategy)(nil) +) type MultiStrategy struct { // all Strategies should have a startupTimeout to avoid waiting infinitely diff --git a/wait/exec.go b/wait/exec.go index 82f15c609f..e0ffc89758 100644 --- a/wait/exec.go +++ b/wait/exec.go @@ -9,8 +9,10 @@ import ( ) // Implement interface -var _ Strategy = (*ExecStrategy)(nil) -var _ StrategyTimeout = (*ExecStrategy)(nil) +var ( + _ Strategy = (*ExecStrategy)(nil) + _ StrategyTimeout = (*ExecStrategy)(nil) +) type ExecStrategy struct { // all Strategies should have a startupTimeout to avoid waiting infinitely diff --git a/wait/exec_test.go b/wait/exec_test.go index f4a001314b..21a5b6c331 100644 --- a/wait/exec_test.go +++ b/wait/exec_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" tcexec "github.com/testcontainers/testcontainers-go/exec" "github.com/testcontainers/testcontainers-go/wait" diff --git a/wait/exit.go b/wait/exit.go index 8ff59fe0ae..5526483441 100644 --- a/wait/exit.go +++ b/wait/exit.go @@ -7,8 +7,10 @@ import ( ) // Implement interface -var _ Strategy = (*ExitStrategy)(nil) -var _ StrategyTimeout = (*ExitStrategy)(nil) +var ( + _ Strategy = (*ExitStrategy)(nil) + _ StrategyTimeout = (*ExitStrategy)(nil) +) // ExitStrategy will wait until container exit type ExitStrategy struct { @@ -24,7 +26,6 @@ func NewExitStrategy() *ExitStrategy { return &ExitStrategy{ PollInterval: defaultPollInterval(), } - } // fluent builders for each property diff --git a/wait/exit_test.go b/wait/exit_test.go index 9a4f7eded3..df6aec1c4a 100644 --- a/wait/exit_test.go +++ b/wait/exit_test.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + tcexec "github.com/testcontainers/testcontainers-go/exec" ) diff --git a/wait/health.go b/wait/health.go index b0821c8aec..e4513ae883 100644 --- a/wait/health.go +++ b/wait/health.go @@ -8,8 +8,10 @@ import ( ) // Implement interface -var _ Strategy = (*HealthStrategy)(nil) -var _ StrategyTimeout = (*HealthStrategy)(nil) +var ( + _ Strategy = (*HealthStrategy)(nil) + _ StrategyTimeout = (*HealthStrategy)(nil) +) // HealthStrategy will wait until the container becomes healthy type HealthStrategy struct { @@ -25,7 +27,6 @@ func NewHealthStrategy() *HealthStrategy { return &HealthStrategy{ PollInterval: defaultPollInterval(), } - } // fluent builders for each property diff --git a/wait/health_test.go b/wait/health_test.go index 9f75cf5987..beafe33527 100644 --- a/wait/health_test.go +++ b/wait/health_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" "github.com/stretchr/testify/assert" + tcexec "github.com/testcontainers/testcontainers-go/exec" ) diff --git a/wait/host_port.go b/wait/host_port.go index 59fe7c113a..6ef1da82bf 100644 --- a/wait/host_port.go +++ b/wait/host_port.go @@ -14,8 +14,10 @@ import ( ) // Implement interface -var _ Strategy = (*HostPortStrategy)(nil) -var _ StrategyTimeout = (*HostPortStrategy)(nil) +var ( + _ Strategy = (*HostPortStrategy)(nil) + _ StrategyTimeout = (*HostPortStrategy)(nil) +) var errShellNotExecutable = errors.New("/bin/sh command not executable") @@ -83,7 +85,7 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT return } - var waitInterval = hp.PollInterval + waitInterval := hp.PollInterval internalPort := hp.Port if internalPort == "" { @@ -107,7 +109,7 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT var port nat.Port port, err = target.MappedPort(ctx, internalPort) - var i = 0 + i := 0 for port == "" { i++ diff --git a/wait/host_port_test.go b/wait/host_port_test.go index 0a766360b7..92212989eb 100644 --- a/wait/host_port_test.go +++ b/wait/host_port_test.go @@ -10,6 +10,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go/exec" ) diff --git a/wait/http.go b/wait/http.go index 3ebd4469b0..39c0c155f8 100644 --- a/wait/http.go +++ b/wait/http.go @@ -17,8 +17,10 @@ import ( ) // Implement interface -var _ Strategy = (*HTTPStrategy)(nil) -var _ StrategyTimeout = (*HTTPStrategy)(nil) +var ( + _ Strategy = (*HTTPStrategy)(nil) + _ StrategyTimeout = (*HTTPStrategy)(nil) +) type HTTPStrategy struct { // all Strategies should have a startupTimeout to avoid waiting infinitely diff --git a/wait/http_test.go b/wait/http_test.go index a1daee2c15..f1df456bcd 100644 --- a/wait/http_test.go +++ b/wait/http_test.go @@ -17,6 +17,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/wait/log.go b/wait/log.go index fca23e28e6..0b802a5693 100644 --- a/wait/log.go +++ b/wait/log.go @@ -8,8 +8,10 @@ import ( ) // Implement interface -var _ Strategy = (*LogStrategy)(nil) -var _ StrategyTimeout = (*LogStrategy)(nil) +var ( + _ Strategy = (*LogStrategy)(nil) + _ StrategyTimeout = (*LogStrategy)(nil) +) // LogStrategy will wait until a given log entry shows up in the docker logs type LogStrategy struct { @@ -104,11 +106,12 @@ LOOP: } logs := string(b) - if length == len(logs) && checkErr != nil { + switch { + case length == len(logs) && checkErr != nil: return checkErr - } else if strings.Count(logs, ws.Log) >= ws.Occurrence { + case strings.Count(logs, ws.Log) >= ws.Occurrence: break LOOP - } else { + default: length = len(logs) time.Sleep(ws.PollInterval) continue diff --git a/wait/nop.go b/wait/nop.go index a16feb8787..e7c86bea5e 100644 --- a/wait/nop.go +++ b/wait/nop.go @@ -7,11 +7,14 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go/exec" ) -var _ Strategy = (*NopStrategy)(nil) -var _ StrategyTimeout = (*NopStrategy)(nil) +var ( + _ Strategy = (*NopStrategy)(nil) + _ StrategyTimeout = (*NopStrategy)(nil) +) type NopStrategy struct { timeout *time.Duration diff --git a/wait/sql.go b/wait/sql.go index 9e0c05607c..c24629ed94 100644 --- a/wait/sql.go +++ b/wait/sql.go @@ -9,8 +9,10 @@ import ( "github.com/docker/go-connections/nat" ) -var _ Strategy = (*waitForSql)(nil) -var _ StrategyTimeout = (*waitForSql)(nil) +var ( + _ Strategy = (*waitForSql)(nil) + _ StrategyTimeout = (*waitForSql)(nil) +) const defaultForSqlQuery = "SELECT 1" diff --git a/wait/wait.go b/wait/wait.go index 559ce39794..46a66f7dfa 100644 --- a/wait/wait.go +++ b/wait/wait.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go/exec" ) diff --git a/wait/wait_test.go b/wait/wait_test.go index 4a18e7bbdb..0e07ba87b6 100644 --- a/wait/wait_test.go +++ b/wait/wait_test.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/go-connections/nat" + tcexec "github.com/testcontainers/testcontainers-go/exec" ) From 94b45632fbc72cff82ff3065fd065d3103533abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Mon, 21 Aug 2023 13:09:14 +0200 Subject: [PATCH 04/26] chore: use Info instead of Ping to check if Docker is live (#1490) * chore: use Info instead of Ping to check if Docker is live * chore: deprecate the NewDockerClient function Use the internal in the library * chore: create our own Docker client struct * feat: implement Docker's SystemAPIClient in our client * chore: cache Info calls to be reused just once * chore: log Docker version only when Docker Info is retrieved * docs: enrich docs * fix: remove unused variable * chore: rename method * chore: reuse context * fix: forgot to update * chore: fix fmt --- docker.go | 10 +- docker_auth.go | 2 +- docker_auth_test.go | 2 +- docker_client.go | 118 ++++++++++++++++++++++++ docker_test.go | 20 ++-- internal/testcontainersdocker/client.go | 18 ---- lifecycle_test.go | 3 +- logconsumer_test.go | 3 +- logger.go | 25 +---- modules/compose/compose.go | 5 - modules/compose/compose_api.go | 2 +- modules/compose/compose_local.go | 3 +- modules/compose/compose_test.go | 4 +- mounts_test.go | 2 +- provider.go | 10 +- testing.go | 4 +- 16 files changed, 145 insertions(+), 86 deletions(-) create mode 100644 docker_client.go diff --git a/docker.go b/docker.go index 51b7c562f9..567f6bb840 100644 --- a/docker.go +++ b/docker.go @@ -15,7 +15,6 @@ import ( "os" "path/filepath" "strings" - "sync" "time" "github.com/cenkalti/backoff/v4" @@ -43,7 +42,6 @@ var ( // Implement interfaces _ Container = (*DockerContainer)(nil) - logOnce sync.Once ErrDuplicateMountTarget = errors.New("duplicate mount target detected") ) @@ -773,10 +771,6 @@ func (p *DockerProvider) SetClient(c client.APIClient) { var _ ContainerProvider = (*DockerProvider)(nil) -func NewDockerClient() (cli *client.Client, err error) { - return testcontainersdocker.NewClient(context.Background()) -} - // BuildImage will build and image from context and Dockerfile, then return the tag func (p *DockerProvider) BuildImage(ctx context.Context, img ImageBuildInfo) (string, error) { repo := uuid.New() @@ -1191,9 +1185,9 @@ func (p *DockerProvider) attemptToPullImage(ctx context.Context, tag string, pul } // Health measure the healthiness of the provider. Right now we leverage the -// docker-client ping endpoint to see if the daemon is reachable. +// docker-client Info endpoint to see if the daemon is reachable. func (p *DockerProvider) Health(ctx context.Context) (err error) { - _, err = p.client.Ping(ctx) + _, err = p.client.Info(ctx) defer p.Close() return err diff --git a/docker_auth.go b/docker_auth.go index db678a3981..a8c32bf46f 100644 --- a/docker_auth.go +++ b/docker_auth.go @@ -35,7 +35,7 @@ func DockerImageAuth(ctx context.Context, image string) (string, registry.AuthCo // It will use the docker daemon to get the default registry, returning "https://index.docker.io/v1/" if // it fails to get the information from the daemon func defaultRegistry(ctx context.Context) string { - client, err := testcontainersdocker.NewClient(ctx) + client, err := NewDockerClientWithOpts(ctx) if err != nil { return testcontainersdocker.IndexDockerIO } diff --git a/docker_auth_test.go b/docker_auth_test.go index 87c32d4e55..3274a9cb15 100644 --- a/docker_auth_test.go +++ b/docker_auth_test.go @@ -138,7 +138,7 @@ func TestBuildContainerFromDockerfile(t *testing.T) { func removeImageFromLocalCache(t *testing.T, image string) { ctx := context.Background() - testcontainersClient, err := testcontainersdocker.NewClient(ctx, client.WithVersion(daemonMaxVersion)) + testcontainersClient, err := NewDockerClientWithOpts(ctx, client.WithVersion(daemonMaxVersion)) if err != nil { t.Log("could not create client to cleanup registry: ", err) } diff --git a/docker_client.go b/docker_client.go new file mode 100644 index 0000000000..e279cbc599 --- /dev/null +++ b/docker_client.go @@ -0,0 +1,118 @@ +package testcontainers + +import ( + "context" + "sync" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/events" + "github.com/docker/docker/api/types/registry" + "github.com/docker/docker/client" + + "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" +) + +// DockerClient is a wrapper around the docker client that is used by testcontainers-go. +// It implements the SystemAPIClient interface in order to cache the docker info and reuse it. +type DockerClient struct { + *client.Client // client is embedded into our own client +} + +var ( + dockerInfo types.Info // dockerInfo stores the docker info to be reused in the Info method + dockerInfoOnce sync.Once +) + +// implements SystemAPIClient interface +var _ client.SystemAPIClient = &DockerClient{} + +// Events returns a channel to listen to events that happen to the docker daemon. +func (c *DockerClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) { + return c.Client.Events(ctx, options) +} + +// Info returns information about the docker server. The result of Info is cached +// and reused every time Info is called. +// It will also print out the docker server info, and the resolved Docker paths, to the default logger. +func (c *DockerClient) Info(ctx context.Context) (types.Info, error) { + var err error + dockerInfoOnce.Do(func() { + dockerInfo, err = c.Client.Info(ctx) + if err != nil { + // reset the state of the sync.Once so that the next call to Info will try again + dockerInfoOnce = sync.Once{} + return + } + + infoMessage := `%v - Connected to docker: + Server Version: %v + API Version: %v + Operating System: %v + Total Memory: %v MB + Resolved Docker Host: %s + Resolved Docker Socket Path: %s +` + + Logger.Printf(infoMessage, packagePath, + dockerInfo.ServerVersion, c.Client.ClientVersion(), + dockerInfo.OperatingSystem, dockerInfo.MemTotal/1024/1024, + testcontainersdocker.ExtractDockerHost(ctx), + testcontainersdocker.ExtractDockerSocket(ctx), + ) + }) + + return dockerInfo, err +} + +// RegistryLogin logs into a Docker registry. +func (c *DockerClient) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) { + return c.Client.RegistryLogin(ctx, auth) +} + +// DiskUsage returns the disk usage of all images. +func (c *DockerClient) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) { + return c.Client.DiskUsage(ctx, options) +} + +// Ping pings the docker server. +func (c *DockerClient) Ping(ctx context.Context) (types.Ping, error) { + return c.Client.Ping(ctx) +} + +// Deprecated: Use NewDockerClientWithOpts instead. +func NewDockerClient() (*client.Client, error) { + cli, err := NewDockerClientWithOpts(context.Background()) + if err != nil { + return nil, err + } + + return cli.Client, nil +} + +func NewDockerClientWithOpts(ctx context.Context, opt ...client.Opt) (*DockerClient, error) { + dockerClient, err := testcontainersdocker.NewClient(ctx, opt...) + if err != nil { + return nil, err + } + + tcClient := DockerClient{ + Client: dockerClient, + } + + if _, err = tcClient.Info(ctx); err != nil { + // Fallback to environment, including the original options + if len(opt) == 0 { + opt = []client.Opt{client.FromEnv, client.WithAPIVersionNegotiation()} + } + + dockerClient, err := client.NewClientWithOpts(opt...) + if err != nil { + return nil, err + } + + tcClient.Client = dockerClient + } + defer tcClient.Close() + + return &tcClient, nil +} diff --git a/docker_test.go b/docker_test.go index d0527223dd..dbc1030e9b 100644 --- a/docker_test.go +++ b/docker_test.go @@ -323,7 +323,7 @@ func TestContainerStartsWithoutTheReaper(t *testing.T) { } ctx := context.Background() - client, err := testcontainersdocker.NewClient(ctx) + client, err := NewDockerClientWithOpts(ctx) if err != nil { t.Fatal(err) } @@ -363,7 +363,7 @@ func TestContainerStartsWithTheReaper(t *testing.T) { } ctx := context.Background() - client, err := testcontainersdocker.NewClient(ctx) + client, err := NewDockerClientWithOpts(ctx) if err != nil { t.Fatal(err) } @@ -620,7 +620,7 @@ func TestContainerTerminationWithoutReaper(t *testing.T) { func TestContainerTerminationRemovesDockerImage(t *testing.T) { t.Run("if not built from Dockerfile", func(t *testing.T) { ctx := context.Background() - client, err := testcontainersdocker.NewClient(ctx) + client, err := NewDockerClientWithOpts(ctx) if err != nil { t.Fatal(err) } @@ -651,7 +651,7 @@ func TestContainerTerminationRemovesDockerImage(t *testing.T) { t.Run("if built from Dockerfile", func(t *testing.T) { ctx := context.Background() - client, err := testcontainersdocker.NewClient(ctx) + client, err := NewDockerClientWithOpts(ctx) if err != nil { t.Fatal(err) } @@ -1380,7 +1380,7 @@ func TestContainerCreationWithBindAndVolume(t *testing.T) { ctx, cnl := context.WithTimeout(context.Background(), 30*time.Second) defer cnl() // Create a Docker client. - dockerCli, err := NewDockerClient() + dockerCli, err := NewDockerClientWithOpts(context.Background()) if err != nil { t.Fatal(err) } @@ -1536,7 +1536,7 @@ func TestContainerCustomPlatformImage(t *testing.T) { require.NoError(t, err) terminateContainerOnEnd(t, ctx, c) - dockerCli, err := NewDockerClient() + dockerCli, err := NewDockerClientWithOpts(ctx) require.NoError(t, err) defer dockerCli.Close() @@ -1574,7 +1574,7 @@ func TestContainerWithCustomHostname(t *testing.T) { } func readHostname(tb testing.TB, containerId string) string { - containerClient, err := NewDockerClient() + containerClient, err := NewDockerClientWithOpts(context.Background()) if err != nil { tb.Fatalf("Failed to create Docker client: %v", err) } @@ -1940,7 +1940,7 @@ func TestDockerContainerResources(t *testing.T) { require.NoError(t, err) terminateContainerOnEnd(t, ctx, nginxC) - c, err := testcontainersdocker.NewClient(ctx) + c, err := NewDockerClientWithOpts(ctx) require.NoError(t, err) defer c.Close() @@ -2001,7 +2001,7 @@ func TestContainerWithReaperNetwork(t *testing.T) { containerId := nginxC.GetContainerID() - cli, err := testcontainersdocker.NewClient(ctx) + cli, err := NewDockerClientWithOpts(ctx) assert.Nil(t, err) defer cli.Close() @@ -2036,7 +2036,7 @@ func TestContainerCapAdd(t *testing.T) { require.NoError(t, err) terminateContainerOnEnd(t, ctx, nginx) - dockerClient, err := testcontainersdocker.NewClient(ctx) + dockerClient, err := NewDockerClientWithOpts(ctx) require.NoError(t, err) defer dockerClient.Close() diff --git a/internal/testcontainersdocker/client.go b/internal/testcontainersdocker/client.go index ca88b2af4b..1cf2d6dceb 100644 --- a/internal/testcontainersdocker/client.go +++ b/internal/testcontainersdocker/client.go @@ -46,23 +46,5 @@ func NewClient(ctx context.Context, ops ...client.Opt) (*client.Client, error) { return nil, err } - if _, err = cli.Ping(context.Background()); err != nil { - // Fallback to environment, including the original options - cli, err = defaultClient(context.Background(), ops...) - if err != nil { - return nil, err - } - } - defer cli.Close() - return cli, nil } - -// defaultClient returns a plain, new docker client with the default options -func defaultClient(ctx context.Context, ops ...client.Opt) (*client.Client, error) { - if len(ops) == 0 { - ops = []client.Opt{client.FromEnv, client.WithAPIVersionNegotiation()} - } - - return client.NewClientWithOpts(ops...) -} diff --git a/lifecycle_test.go b/lifecycle_test.go index 87b55f1436..8676cb43d6 100644 --- a/lifecycle_test.go +++ b/lifecycle_test.go @@ -16,7 +16,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) @@ -647,7 +646,7 @@ func (l *linesTestLogger) Printf(format string, args ...interface{}) { func TestPrintContainerLogsOnError(t *testing.T) { ctx := context.Background() - client, err := testcontainersdocker.NewClient(ctx) + client, err := NewDockerClientWithOpts(ctx) if err != nil { t.Fatal(err) } diff --git a/logconsumer_test.go b/logconsumer_test.go index d1176944a8..05f8d558a6 100644 --- a/logconsumer_test.go +++ b/logconsumer_test.go @@ -14,7 +14,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) @@ -299,7 +298,7 @@ func TestContainerLogWithErrClosed(t *testing.T) { opts := []client.Opt{client.WithHost(remoteDocker), client.WithAPIVersionNegotiation()} - client, err := testcontainersdocker.NewClient(ctx, opts...) + client, err := NewDockerClientWithOpts(ctx, opts...) if err != nil { t.Fatal(err) } diff --git a/logger.go b/logger.go index 917f7eaba5..5236ac4640 100644 --- a/logger.go +++ b/logger.go @@ -7,8 +7,6 @@ import ( "testing" "github.com/docker/docker/client" - - "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" ) // Logger is the default log instance @@ -19,29 +17,10 @@ type Logging interface { Printf(format string, v ...interface{}) } +// Deprecated: this function will be removed in a future release // LogDockerServerInfo logs the docker server info using the provided logger and Docker client func LogDockerServerInfo(ctx context.Context, client client.APIClient, logger Logging) { - infoMessage := `%v - Connected to docker: - Server Version: %v - API Version: %v - Operating System: %v - Total Memory: %v MB - Resolved Docker Host: %s - Resolved Docker Socket Path: %s -` - - info, err := client.Info(ctx) - if err != nil { - logger.Printf("failed getting information about docker server: %s", err) - return - } - - logger.Printf(infoMessage, packagePath, - info.ServerVersion, client.ClientVersion(), - info.OperatingSystem, info.MemTotal/1024/1024, - testcontainersdocker.ExtractDockerHost(ctx), - testcontainersdocker.ExtractDockerSocket(ctx), - ) + // NOOP } // TestLogger returns a Logging implementation for testing.TB diff --git a/modules/compose/compose.go b/modules/compose/compose.go index 6c45d5119b..dfb9d61a10 100644 --- a/modules/compose/compose.go +++ b/modules/compose/compose.go @@ -135,11 +135,6 @@ func NewDockerComposeWith(opts ...ComposeStackOption) (*dockerCompose, error) { containers: make(map[string]*testcontainers.DockerContainer), } - // log docker server info only once - composeLogOnce.Do(func() { - testcontainers.LogDockerServerInfo(context.Background(), dockerCli.Client(), testcontainers.Logger) - }) - return composeAPI, nil } diff --git a/modules/compose/compose_api.go b/modules/compose/compose_api.go index c7d35c2692..c7955280c2 100644 --- a/modules/compose/compose_api.go +++ b/modules/compose/compose_api.go @@ -375,7 +375,7 @@ func withEnv(env map[string]string) func(*cli.ProjectOptions) error { } func makeClient(*command.DockerCli) (client.APIClient, error) { - dockerClient, err := testcontainers.NewDockerClient() + dockerClient, err := testcontainers.NewDockerClientWithOpts(context.Background()) if err != nil { return nil, err } diff --git a/modules/compose/compose_local.go b/modules/compose/compose_local.go index ba4fb8beef..5e963ae005 100644 --- a/modules/compose/compose_local.go +++ b/modules/compose/compose_local.go @@ -17,7 +17,6 @@ import ( "gopkg.in/yaml.v3" "github.com/testcontainers/testcontainers-go" - "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" "github.com/testcontainers/testcontainers-go/wait" ) @@ -123,7 +122,7 @@ func (dc *LocalDockerCompose) containerNameFromServiceName(service, separator st } func (dc *LocalDockerCompose) applyStrategyToRunningContainer() error { - cli, err := testcontainersdocker.NewClient(context.Background()) + cli, err := testcontainers.NewDockerClientWithOpts(context.Background()) if err != nil { return err } diff --git a/modules/compose/compose_test.go b/modules/compose/compose_test.go index 548e27fd36..10d23f1059 100644 --- a/modules/compose/compose_test.go +++ b/modules/compose/compose_test.go @@ -449,7 +449,7 @@ func TestLocalDockerComposeWithVolume(t *testing.T) { } func assertVolumeDoesNotExist(tb testing.TB, volumeName string) { - containerClient, err := testcontainers.NewDockerClient() + containerClient, err := testcontainers.NewDockerClientWithOpts(context.Background()) if err != nil { tb.Fatalf("Failed to get provider: %v", err) } @@ -474,7 +474,7 @@ func assertContainerEnvironmentVariables( present map[string]string, absent map[string]string, ) { - containerClient, err := testcontainers.NewDockerClient() + containerClient, err := testcontainers.NewDockerClientWithOpts(context.Background()) if err != nil { tb.Fatalf("Failed to get provider: %v", err) } diff --git a/mounts_test.go b/mounts_test.go index 16a6458ed4..26ce4f6ed5 100644 --- a/mounts_test.go +++ b/mounts_test.go @@ -268,7 +268,7 @@ func TestCreateContainerWithVolume(t *testing.T) { terminateContainerOnEnd(t, ctx, c) // Check if volume is created - client, err := NewDockerClient() + client, err := NewDockerClientWithOpts(ctx) assert.NoError(t, err) defer client.Close() diff --git a/provider.go b/provider.go index d6868f8d1c..84e959d9e0 100644 --- a/provider.go +++ b/provider.go @@ -138,14 +138,15 @@ func NewDockerProvider(provOpts ...DockerProviderOption) (*DockerProvider, error provOpts[idx].ApplyDockerTo(o) } - c, err := NewDockerClient() + ctx := context.Background() + c, err := NewDockerClientWithOpts(ctx) if err != nil { return nil, err } tcConfig := ReadConfig() - dockerHost := testcontainersdocker.ExtractDockerHost(context.Background()) + dockerHost := testcontainersdocker.ExtractDockerHost(ctx) p := &DockerProvider{ DockerProviderOptions: o, @@ -154,10 +155,5 @@ func NewDockerProvider(provOpts ...DockerProviderOption) (*DockerProvider, error config: tcConfig, } - // log docker server info only once - logOnce.Do(func() { - LogDockerServerInfo(context.Background(), p.client, p.Logger) - }) - return p, nil } diff --git a/testing.go b/testing.go index cdbd68d72e..5cba53e79f 100644 --- a/testing.go +++ b/testing.go @@ -3,8 +3,6 @@ package testcontainers import ( "context" "testing" - - "github.com/testcontainers/testcontainers-go/internal/testcontainersdocker" ) // SkipIfProviderIsNotHealthy is a utility function capable of skipping tests @@ -26,7 +24,7 @@ func SkipIfProviderIsNotHealthy(t *testing.T) { // SkipIfDockerDesktop is a utility function capable of skipping tests // if tests are run using Docker Desktop. func SkipIfDockerDesktop(t *testing.T, ctx context.Context) { - cli, err := testcontainersdocker.NewClient(ctx) + cli, err := NewDockerClientWithOpts(ctx) if err != nil { t.Fatalf("failed to create docker client: %s", err) } From 41c24e0ac28930cc42796359d0b246179b693474 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Mon, 21 Aug 2023 13:55:07 +0200 Subject: [PATCH 05/26] modulegen: create internal/dependabot (#1503) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modulegen: create internal/dependabot Signed-off-by: Matthieu MOREL * Apply suggestions from code review Co-authored-by: Manuel de la Peña --------- Signed-off-by: Matthieu MOREL Co-authored-by: Manuel de la Peña --- modulegen/context.go | 58 ++++++++++ modulegen/context_test.go | 113 +++++++++++++++++++ modulegen/dependabot.go | 138 ------------------------ modulegen/dependabot_test.go | 117 -------------------- modulegen/internal/dependabot/main.go | 26 +++++ modulegen/internal/dependabot/reader.go | 23 ++++ modulegen/internal/dependabot/sorter.go | 33 ++++++ modulegen/internal/dependabot/types.go | 64 +++++++++++ modulegen/internal/dependabot/writer.go | 17 +++ modulegen/main.go | 20 ++-- modulegen/main_test.go | 37 ++++--- 11 files changed, 367 insertions(+), 279 deletions(-) create mode 100644 modulegen/context.go create mode 100644 modulegen/context_test.go delete mode 100644 modulegen/dependabot.go delete mode 100644 modulegen/dependabot_test.go create mode 100644 modulegen/internal/dependabot/main.go create mode 100644 modulegen/internal/dependabot/reader.go create mode 100644 modulegen/internal/dependabot/sorter.go create mode 100644 modulegen/internal/dependabot/types.go create mode 100644 modulegen/internal/dependabot/writer.go diff --git a/modulegen/context.go b/modulegen/context.go new file mode 100644 index 0000000000..470cd5113c --- /dev/null +++ b/modulegen/context.go @@ -0,0 +1,58 @@ +package main + +import ( + "os" + "path/filepath" + "sort" +) + +type Context struct { + RootDir string +} + +func (ctx *Context) DependabotConfigFile() string { + return filepath.Join(ctx.GithubDir(), "dependabot.yml") +} + +func (ctx *Context) DocsDir() string { + return filepath.Join(ctx.RootDir, "docs") +} + +func (ctx *Context) GithubDir() string { + return filepath.Join(ctx.RootDir, ".github") +} + +func (ctx *Context) GithubWorkflowsDir() string { + return filepath.Join(ctx.GithubDir(), "workflows") +} + +func (ctx *Context) getModulesByBaseDir(baseDir string) ([]string, error) { + dir := filepath.Join(ctx.RootDir, baseDir) + + allFiles, err := os.ReadDir(dir) + if err != nil { + return nil, err + } + + dirs := make([]string, 0) + + for _, f := range allFiles { + if f.IsDir() { + dirs = append(dirs, f.Name()) + } + } + sort.Strings(dirs) + return dirs, nil +} + +func (ctx *Context) GetExamples() ([]string, error) { + return ctx.getModulesByBaseDir("examples") +} + +func (ctx *Context) GetModules() ([]string, error) { + return ctx.getModulesByBaseDir("modules") +} + +func (ctx *Context) MkdocsConfigFile() string { + return filepath.Join(ctx.RootDir, "mkdocs.yml") +} diff --git a/modulegen/context_test.go b/modulegen/context_test.go new file mode 100644 index 0000000000..101a1a33cc --- /dev/null +++ b/modulegen/context_test.go @@ -0,0 +1,113 @@ +package main_test + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + main "github.com/testcontainers/testcontainers-go/modulegen" + "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" +) + +func TestGetDependabotConfigFile(t *testing.T) { + tmp := t.TempDir() + + ctx := &main.Context{RootDir: filepath.Join(tmp, "testcontainers-go")} + + githubDir := ctx.GithubDir() + cfgFile := ctx.DependabotConfigFile() + err := os.MkdirAll(githubDir, 0o777) + require.NoError(t, err) + + err = os.WriteFile(cfgFile, []byte{}, 0o777) + require.NoError(t, err) + + file := ctx.DependabotConfigFile() + require.NotNil(t, file) + + assert.True(t, strings.HasSuffix(file, filepath.Join("testcontainers-go", ".github", "dependabot.yml"))) +} + +func TestExamplesHasDependabotEntry(t *testing.T) { + rootDir, err := getRootDir() + require.NoError(t, err) + ctx := &main.Context{RootDir: rootDir} + examples, err := ctx.GetExamples() + require.NoError(t, err) + dependabotUpdates, err := dependabot.GetUpdates(ctx.DependabotConfigFile()) + require.NoError(t, err) + + exampleUpdates := []dependabot.Update{} + // exclude the Go modules from the examples updates + for _, update := range dependabotUpdates { + if strings.HasPrefix(update.Directory, "/examples/") { + exampleUpdates = append(exampleUpdates, update) + } + } + + assert.Equal(t, len(exampleUpdates), len(examples)) + + // all example modules exist in the dependabot updates + for _, example := range examples { + found := false + for _, exampleUpdate := range exampleUpdates { + dependabotDir := "/examples/" + example + + assert.Equal(t, exampleUpdate.Schedule.Interval, "monthly") + + if dependabotDir == exampleUpdate.Directory { + found = true + continue + } + } + assert.True(t, found, "example %s is not present in the dependabot updates", example) + } +} + +func TestModulesHasDependabotEntry(t *testing.T) { + rootDir, err := getRootDir() + require.NoError(t, err) + ctx := &main.Context{RootDir: rootDir} + modules, err := ctx.GetModules() + require.NoError(t, err) + dependabotUpdates, err := dependabot.GetUpdates(ctx.DependabotConfigFile()) + require.NoError(t, err) + + moduleUpdates := []dependabot.Update{} + // exclude the Go modules from the examples updates + for _, update := range dependabotUpdates { + if strings.HasPrefix(update.Directory, "/modules/") { + moduleUpdates = append(moduleUpdates, update) + } + } + assert.Equal(t, len(moduleUpdates), len(modules)) + + // all module modules exist in the dependabot updates + for _, module := range modules { + found := false + for _, moduleUpdate := range moduleUpdates { + dependabotDir := "/modules/" + module + + assert.Equal(t, moduleUpdate.Schedule.Interval, "monthly") + + if dependabotDir == moduleUpdate.Directory { + found = true + continue + } + } + assert.True(t, found, "module %s is not present in the dependabot updates", module) + } +} + +func getRootDir() (string, error) { + current, err := os.Getwd() + if err != nil { + return "", err + } + + return filepath.Dir(current), nil +} diff --git a/modulegen/dependabot.go b/modulegen/dependabot.go deleted file mode 100644 index d0807f635e..0000000000 --- a/modulegen/dependabot.go +++ /dev/null @@ -1,138 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - - "gopkg.in/yaml.v3" -) - -const updateSchedule = "monthly" - -type Updates []Update - -type DependabotConfig struct { - Version int `yaml:"version"` - Updates Updates `yaml:"updates"` -} - -type Group struct { - Patterns []string `yaml:"patterns"` -} - -type Groups map[string]Group - -type Schedule struct { - Interval string `yaml:"interval"` - Day string `yaml:"day"` -} - -type Update struct { - PackageEcosystem string `yaml:"package-ecosystem"` - Directory string `yaml:"directory"` - Schedule Schedule `yaml:"schedule"` - OpenPullRequestsLimit int `yaml:"open-pull-requests-limit"` - RebaseStrategy string `yaml:"rebase-strategy"` - Groups Groups `yaml:"groups,omitempty"` -} - -func NewUpdate(example Example) Update { - return Update{ - Directory: "/" + example.ParentDir() + "/" + example.Lower(), - OpenPullRequestsLimit: 3, - PackageEcosystem: "gomod", - RebaseStrategy: "disabled", - Schedule: Schedule{ - Interval: updateSchedule, - Day: "sunday", - }, - Groups: Groups{ - "all": Group{ - Patterns: []string{"*"}, - }, - }, - } -} - -// Len is the number of elements in the collection. -func (u Updates) Len() int { - return len(u) -} - -// Less reports whether the element with index i -// must sort before the element with index j. -// -// If both Less(i, j) and Less(j, i) are false, -// then the elements at index i and j are considered equal. -// Sort may place equal elements in any order in the final result, -// while Stable preserves the original input order of equal elements. -// -// Less must describe a transitive ordering: -// - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well. -// - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well. -// -// Note that floating-point comparison (the < operator on float32 or float64 values) -// is not a transitive ordering when not-a-number (NaN) values are involved. -// See Float64Slice.Less for a correct implementation for floating-point values. -func (u Updates) Less(i, j int) bool { - if u[i].Directory != u[j].Directory { - return u[i].Directory < u[j].Directory - } - return u[i].PackageEcosystem < u[j].PackageEcosystem -} - -// Swap swaps the elements with indexes i and j. -func (u Updates) Swap(i, j int) { - u[i], u[j] = u[j], u[i] -} - -func getDependabotConfigFile(rootDir string) string { - return filepath.Join(rootDir, ".github", "dependabot.yml") -} - -func getDependabotUpdates() ([]Update, error) { - parent, err := getRootDir() - if err != nil { - return nil, err - } - - config, err := readDependabotConfig(parent) - if err != nil { - return nil, err - } - - return config.Updates, nil -} - -func readDependabotConfig(rootDir string) (*DependabotConfig, error) { - configFile := getDependabotConfigFile(rootDir) - - file, err := os.ReadFile(configFile) - if err != nil { - return nil, err - } - - config := &DependabotConfig{} - - err = yaml.Unmarshal(file, config) - if err != nil { - return nil, err - } - - return config, nil -} - -func writeDependabotConfig(rootDir string, config *DependabotConfig) error { - data, err := yaml.Marshal(config) - if err != nil { - return err - } - - file := getDependabotConfigFile(rootDir) - - header := "# This file is autogenerated by the modulegen code generator. Please look at the generator code when updating it.\n" - - data = append([]byte(header), data...) - - return os.WriteFile(file, data, 0o777) -} diff --git a/modulegen/dependabot_test.go b/modulegen/dependabot_test.go deleted file mode 100644 index 7dab43fcb6..0000000000 --- a/modulegen/dependabot_test.go +++ /dev/null @@ -1,117 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestGetDependabotConfigFile(t *testing.T) { - tmp := t.TempDir() - - rootDir := filepath.Join(tmp, "testcontainers-go") - githubDir := filepath.Join(rootDir, ".github") - cfgFile := filepath.Join(githubDir, "dependabot.yml") - err := os.MkdirAll(githubDir, 0o777) - require.NoError(t, err) - - err = os.WriteFile(cfgFile, []byte{}, 0o777) - require.NoError(t, err) - - file := getDependabotConfigFile(rootDir) - require.NotNil(t, file) - - assert.True(t, strings.HasSuffix(file, filepath.Join("testcontainers-go", ".github", "dependabot.yml"))) -} - -func TestNewUpdate(t *testing.T) { - tests := []struct { - isModule bool - parentDir string - }{ - {true, "/modules"}, - {false, "/examples"}, - } - - for _, test := range tests { - update := NewUpdate(Example{ - Name: "Test", - IsModule: test.isModule, - Image: "test", - TitleName: "Test", - TCVersion: "v1.0.0", - }) - - assert.Equal(t, update.Directory, test.parentDir+"/test") - assert.Equal(t, update.PackageEcosystem, "gomod") - assert.Equal(t, update.OpenPullRequestsLimit, 3) - assert.Equal(t, update.Schedule.Interval, updateSchedule) - assert.Equal(t, update.RebaseStrategy, "disabled") - } -} - -func TestReadDependabotConfig(t *testing.T) { - tmp := t.TempDir() - - rootDir := filepath.Join(tmp, "testcontainers-go") - githubDir := filepath.Join(rootDir, ".github") - err := os.MkdirAll(githubDir, 0o777) - require.NoError(t, err) - - err = copyInitialDependabotConfig(t, rootDir) - require.NoError(t, err) - - config, err := readDependabotConfig(rootDir) - require.NoError(t, err) - require.NotNil(t, config) - - assert.Greater(t, len(config.Updates), 0) -} - -func TestExamplesHasDependabotEntry(t *testing.T) { - examples, err := getExamples() - require.NoError(t, err) - dependabotUpdates, err := getDependabotUpdates() - require.NoError(t, err) - - exampleUpdates := []Update{} - // exclude the Go modules from the examples updates - for _, update := range dependabotUpdates { - if update.PackageEcosystem != "gomod" || update.Directory == "/" || update.Directory == "/modulegen" || strings.HasPrefix(update.Directory, "/modules") { - continue - } - exampleUpdates = append(exampleUpdates, update) - } - - assert.Equal(t, len(exampleUpdates), len(examples)) - - // all example modules exist in the dependabot updates - for _, example := range examples { - found := false - for _, exampleUpdate := range exampleUpdates { - dependabotDir := "/examples/" + strings.ToLower(example.Name()) - - assert.Equal(t, exampleUpdate.Schedule.Interval, updateSchedule) - - if dependabotDir == exampleUpdate.Directory { - found = true - continue - } - } - assert.True(t, found, "example %s is not present in the dependabot updates", example.Name()) - } -} - -func copyInitialDependabotConfig(t *testing.T, tmpDir string) error { - projectDir, err := getRootDir() - require.NoError(t, err) - - initialConfig, err := readDependabotConfig(projectDir) - require.NoError(t, err) - - return writeDependabotConfig(tmpDir, initialConfig) -} diff --git a/modulegen/internal/dependabot/main.go b/modulegen/internal/dependabot/main.go new file mode 100644 index 0000000000..7a40d8b70e --- /dev/null +++ b/modulegen/internal/dependabot/main.go @@ -0,0 +1,26 @@ +package dependabot + +func UpdateConfig(configFile string, directory string, packageEcosystem string) error { + config, err := readConfig(configFile) + if err != nil { + return err + } + config.addUpdate(newUpdate(directory, packageEcosystem)) + return writeConfig(configFile, config) +} + +func GetUpdates(configFile string) (Updates, error) { + config, err := readConfig(configFile) + if err != nil { + return nil, err + } + return config.Updates, nil +} + +func CopyConfig(configFile string, tmpFile string) error { + config, err := readConfig(configFile) + if err != nil { + return err + } + return writeConfig(tmpFile, config) +} diff --git a/modulegen/internal/dependabot/reader.go b/modulegen/internal/dependabot/reader.go new file mode 100644 index 0000000000..b9bfe6db79 --- /dev/null +++ b/modulegen/internal/dependabot/reader.go @@ -0,0 +1,23 @@ +package dependabot + +import ( + "os" + + "gopkg.in/yaml.v3" +) + +func readConfig(configFile string) (*Config, error) { + file, err := os.ReadFile(configFile) + if err != nil { + return nil, err + } + + config := &Config{} + + err = yaml.Unmarshal(file, config) + if err != nil { + return nil, err + } + + return config, nil +} diff --git a/modulegen/internal/dependabot/sorter.go b/modulegen/internal/dependabot/sorter.go new file mode 100644 index 0000000000..d6d572e464 --- /dev/null +++ b/modulegen/internal/dependabot/sorter.go @@ -0,0 +1,33 @@ +package dependabot + +// Len is the number of elements in the collection. +func (u Updates) Len() int { + return len(u) +} + +// Less reports whether the element with index i +// must sort before the element with index j. +// +// If both Less(i, j) and Less(j, i) are false, +// then the elements at index i and j are considered equal. +// Sort may place equal elements in any order in the final result, +// while Stable preserves the original input order of equal elements. +// +// Less must describe a transitive ordering: +// - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well. +// - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well. +// +// Note that floating-point comparison (the < operator on float32 or float64 values) +// is not a transitive ordering when not-a-number (NaN) values are involved. +// See Float64Slice.Less for a correct implementation for floating-point values. +func (u Updates) Less(i, j int) bool { + if u[i].Directory != u[j].Directory { + return u[i].Directory < u[j].Directory + } + return u[i].PackageEcosystem < u[j].PackageEcosystem +} + +// Swap swaps the elements with indexes i and j. +func (u Updates) Swap(i, j int) { + u[i], u[j] = u[j], u[i] +} diff --git a/modulegen/internal/dependabot/types.go b/modulegen/internal/dependabot/types.go new file mode 100644 index 0000000000..626a0a2fa2 --- /dev/null +++ b/modulegen/internal/dependabot/types.go @@ -0,0 +1,64 @@ +package dependabot + +import ( + "sort" +) + +type Config struct { + Version int `yaml:"version"` + Updates Updates `yaml:"updates"` +} + +type Group struct { + Patterns []string `yaml:"patterns"` +} + +type Groups map[string]Group + +type Schedule struct { + Interval string `yaml:"interval"` + Day string `yaml:"day"` +} + +type Update struct { + PackageEcosystem string `yaml:"package-ecosystem"` + Directory string `yaml:"directory"` + Schedule Schedule `yaml:"schedule"` + OpenPullRequestsLimit int `yaml:"open-pull-requests-limit"` + RebaseStrategy string `yaml:"rebase-strategy"` + Groups Groups `yaml:"groups,omitempty"` +} + +type Updates []Update + +func newUpdate(directory string, packageExosystem string) Update { + return Update{ + Directory: directory, + OpenPullRequestsLimit: 3, + PackageEcosystem: packageExosystem, + RebaseStrategy: "disabled", + Schedule: Schedule{ + Interval: "monthly", + Day: "sunday", + }, + Groups: Groups{ + "all": Group{ + Patterns: []string{"*"}, + }, + }, + } +} + +func (c *Config) addUpdate(newUpdate Update) { + exists := false + for _, update := range c.Updates { + if update.Directory == newUpdate.Directory && update.PackageEcosystem == newUpdate.PackageEcosystem { + exists = true + } + } + + if !exists { + c.Updates = append(c.Updates, newUpdate) + sort.Sort(c.Updates) + } +} diff --git a/modulegen/internal/dependabot/writer.go b/modulegen/internal/dependabot/writer.go new file mode 100644 index 0000000000..611bd63783 --- /dev/null +++ b/modulegen/internal/dependabot/writer.go @@ -0,0 +1,17 @@ +package dependabot + +import ( + "os" + + "gopkg.in/yaml.v3" +) + +func writeConfig(configFile string, config *Config) error { + data, err := yaml.Marshal(config) + if err != nil { + return err + } + header := "# This file is autogenerated by the modulegen code generator. Please look at the generator code when updating it.\n" + data = append([]byte(header), data...) + return os.WriteFile(configFile, data, 0o777) +} diff --git a/modulegen/main.go b/modulegen/main.go index 99acaf5925..2b7eb9ad03 100644 --- a/modulegen/main.go +++ b/modulegen/main.go @@ -15,6 +15,8 @@ import ( "golang.org/x/text/cases" "golang.org/x/text/language" + + "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" ) var ( @@ -172,10 +174,11 @@ func generate(example Example, rootDir string) error { if err := example.Validate(); err != nil { return err } + ctx := &Context{RootDir: rootDir} - githubWorkflowsDir := filepath.Join(rootDir, ".github", "workflows") + githubWorkflowsDir := ctx.GithubWorkflowsDir() outputDir := filepath.Join(rootDir, example.ParentDir()) - docsOuputDir := filepath.Join(rootDir, "docs", example.ParentDir()) + docsOuputDir := filepath.Join(ctx.DocsDir(), example.ParentDir()) funcMap := template.FuncMap{ "Entrypoint": func() string { return example.Entrypoint() }, @@ -267,7 +270,7 @@ func generate(example Example, rootDir string) error { } // update examples in dependabot - err = generateDependabotUpdates(rootDir, example) + err = generateDependabotUpdates(ctx, example) if err != nil { return err } @@ -275,15 +278,10 @@ func generate(example Example, rootDir string) error { return nil } -func generateDependabotUpdates(rootDir string, example Example) error { +func generateDependabotUpdates(ctx *Context, example Example) error { // update examples in dependabot - dependabotConfig, err := readDependabotConfig(rootDir) - if err != nil { - return err - } - dependabotConfig.Updates = append(dependabotConfig.Updates, NewUpdate(example)) - sort.Sort(dependabotConfig.Updates) - return writeDependabotConfig(rootDir, dependabotConfig) + directory := "/" + example.ParentDir() + "/" + example.Lower() + return dependabot.UpdateConfig(ctx.DependabotConfigFile(), directory, "gomod") } func generateMkdocs(rootDir string, example Example) error { diff --git a/modulegen/main_test.go b/modulegen/main_test.go index c023d60656..617998fdb7 100644 --- a/modulegen/main_test.go +++ b/modulegen/main_test.go @@ -8,6 +8,8 @@ import ( "testing" "github.com/stretchr/testify/assert" + + "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" ) func TestExample(t *testing.T) { @@ -237,9 +239,10 @@ func TestGenerateWrongExampleTitle(t *testing.T) { func TestGenerate(t *testing.T) { rootTmp := t.TempDir() + tmpCtx := &Context{RootDir: rootTmp} examplesTmp := filepath.Join(rootTmp, "examples") examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") - githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") + githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir() err := os.MkdirAll(examplesTmp, 0o777) assert.Nil(t, err) @@ -254,10 +257,10 @@ func TestGenerate(t *testing.T) { originalConfig, err := readMkdocsConfig(rootTmp) assert.Nil(t, err) - err = copyInitialDependabotConfig(t, rootTmp) + err = copyInitialDependabotConfig(t, tmpCtx.DependabotConfigFile()) assert.Nil(t, err) - originalDependabotConfig, err := readDependabotConfig(rootTmp) + originalDependabotConfigUpdates, err := dependabot.GetUpdates(tmpCtx.DependabotConfigFile()) assert.Nil(t, err) example := Example{ @@ -303,14 +306,15 @@ func TestGenerate(t *testing.T) { assertGoModContent(t, example, filepath.Join(generatedTemplatesDir, "go.mod")) assertMakefileContent(t, example, filepath.Join(generatedTemplatesDir, "Makefile")) assertMkdocsExamplesNav(t, example, originalConfig, rootTmp) - assertDependabotExamplesUpdates(t, example, originalDependabotConfig, rootTmp) + assertDependabotExamplesUpdates(t, example, originalDependabotConfigUpdates, tmpCtx.DependabotConfigFile()) } func TestGenerateModule(t *testing.T) { rootTmp := t.TempDir() + tmpCtx := &Context{RootDir: rootTmp} modulesTmp := filepath.Join(rootTmp, "modules") modulesDocTmp := filepath.Join(rootTmp, "docs", "modules") - githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") + githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir() err := os.MkdirAll(modulesTmp, 0o777) assert.Nil(t, err) @@ -325,10 +329,10 @@ func TestGenerateModule(t *testing.T) { originalConfig, err := readMkdocsConfig(rootTmp) assert.Nil(t, err) - err = copyInitialDependabotConfig(t, rootTmp) + err = copyInitialDependabotConfig(t, tmpCtx.DependabotConfigFile()) assert.Nil(t, err) - originalDependabotConfig, err := readDependabotConfig(rootTmp) + originalDependabotConfigUpdates, err := dependabot.GetUpdates(tmpCtx.DependabotConfigFile()) assert.Nil(t, err) example := Example{ @@ -374,17 +378,15 @@ func TestGenerateModule(t *testing.T) { assertGoModContent(t, example, filepath.Join(generatedTemplatesDir, "go.mod")) assertMakefileContent(t, example, filepath.Join(generatedTemplatesDir, "Makefile")) assertMkdocsExamplesNav(t, example, originalConfig, rootTmp) - assertDependabotExamplesUpdates(t, example, originalDependabotConfig, rootTmp) + assertDependabotExamplesUpdates(t, example, originalDependabotConfigUpdates, tmpCtx.DependabotConfigFile()) } // assert content in the Examples nav from mkdocs.yml -func assertDependabotExamplesUpdates(t *testing.T, example Example, originalConfig *DependabotConfig, rootDir string) { - config, err := readDependabotConfig(rootDir) +func assertDependabotExamplesUpdates(t *testing.T, example Example, originalConfigUpdates dependabot.Updates, tmpFile string) { + examples, err := dependabot.GetUpdates(tmpFile) assert.Nil(t, err) - examples := config.Updates - - assert.Equal(t, len(originalConfig.Updates)+1, len(examples)) + assert.Equal(t, len(originalConfigUpdates)+1, len(examples)) // the example should be in the dependabot updates found := false @@ -544,3 +546,12 @@ func sanitiseContent(bytes []byte) []string { return data } + +func copyInitialDependabotConfig(t *testing.T, tmpFile string) error { + projectDir, err := getRootDir() + assert.Nil(t, err) + + ctx := &Context{RootDir: projectDir} + + return dependabot.CopyConfig(ctx.DependabotConfigFile(), tmpFile) +} From 864dbb3aa89a137ee6317352e9f2e6f2e97eb7e4 Mon Sep 17 00:00:00 2001 From: Adam Bouqdib Date: Tue, 22 Aug 2023 08:19:49 +0100 Subject: [PATCH 06/26] feat(modules/redpanda): support tls (#1511) * feat(modules/redpanda): support tls * chore(modules/redpanda): clean up temporary files * chore: rename option * refactor: use constants for paths * docs: add tls encryption info --- docs/modules/redpanda.md | 4 + modules/redpanda/mounts/redpanda.yaml.tpl | 20 +++ modules/redpanda/options.go | 13 ++ modules/redpanda/redpanda.go | 156 +++++++++++----------- modules/redpanda/redpanda_test.go | 134 ++++++++++++++++++- 5 files changed, 244 insertions(+), 83 deletions(-) diff --git a/docs/modules/redpanda.md b/docs/modules/redpanda.md index 02e6ea33ec..2663570a3c 100644 --- a/docs/modules/redpanda.md +++ b/docs/modules/redpanda.md @@ -55,6 +55,10 @@ for Redpanda. At the same time, it's possible to set a wait strategy and a custom deadline with `testcontainers.WithWaitStrategyAndDeadline`. +#### TLS Encryption + +If you need to enable TLS use `WithTLS` with a valid PEM encoded certificate and key. + #### Docker type modifiers If you need an advanced configuration for Redpanda, you can leverage the following Docker type modifiers: diff --git a/modules/redpanda/mounts/redpanda.yaml.tpl b/modules/redpanda/mounts/redpanda.yaml.tpl index 9c7922d75d..a19d21ce19 100644 --- a/modules/redpanda/mounts/redpanda.yaml.tpl +++ b/modules/redpanda/mounts/redpanda.yaml.tpl @@ -27,6 +27,18 @@ redpanda: name: internal port: 9093 +{{ if .EnableTLS }} + admin_api_tls: + - enabled: true + cert_file: /etc/redpanda/cert.pem + key_file: /etc/redpanda/key.pem + kafka_api_tls: + - name: external + enabled: true + cert_file: /etc/redpanda/cert.pem + key_file: /etc/redpanda/key.pem +{{ end }} + schema_registry: schema_registry_api: - address: "0.0.0.0" @@ -34,6 +46,14 @@ schema_registry: port: 8081 authentication_method: {{ .SchemaRegistry.AuthenticationMethod }} +{{ if .EnableTLS }} + schema_registry_api_tls: + - name: main + enabled: true + cert_file: /etc/redpanda/cert.pem + key_file: /etc/redpanda/key.pem +{{ end }} + schema_registry_client: brokers: - address: localhost diff --git a/modules/redpanda/options.go b/modules/redpanda/options.go index 29a32bdb9b..379492b95d 100644 --- a/modules/redpanda/options.go +++ b/modules/redpanda/options.go @@ -26,6 +26,10 @@ type options struct { // AutoCreateTopics is a flag to allow topic auto creation. AutoCreateTopics bool + + // EnableTLS is a flag to enable TLS. + EnableTLS bool + cert, key []byte } func defaultOptions() options { @@ -36,6 +40,7 @@ func defaultOptions() options { SchemaRegistryAuthenticationMethod: "none", ServiceAccounts: make(map[string]string, 0), AutoCreateTopics: false, + EnableTLS: false, } } @@ -93,3 +98,11 @@ func WithAutoCreateTopics() Option { o.AutoCreateTopics = true } } + +func WithTLS(cert, key []byte) Option { + return func(o *options) { + o.EnableTLS = true + o.cert = cert + o.key = key + } +} diff --git a/modules/redpanda/redpanda.go b/modules/redpanda/redpanda.go index 944a6d112a..83252d5fa3 100644 --- a/modules/redpanda/redpanda.go +++ b/modules/redpanda/redpanda.go @@ -6,6 +6,7 @@ import ( _ "embed" "fmt" "os" + "path/filepath" "text/template" "time" @@ -24,19 +25,34 @@ var ( //go:embed mounts/entrypoint-tc.sh entrypoint []byte +) +const ( defaultKafkaAPIPort = "9092/tcp" defaultAdminAPIPort = "9644/tcp" defaultSchemaRegistryPort = "8081/tcp" + + redpandaDir = "/etc/redpanda" + entrypointFile = "/entrypoint-tc.sh" + bootstrapConfigFile = ".bootstrap.yaml" + certFile = "cert.pem" + keyFile = "key.pem" ) -// Container represents the Redpanda container type used in the module +// Container represents the Redpanda container type used in the module. type Container struct { testcontainers.Container + urlScheme string } -// RunContainer creates an instance of the Redpanda container type +// RunContainer creates an instance of the Redpanda container type. func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*Container, error) { + tmpDir, err := os.MkdirTemp("", "redpanda") + if err != nil { + return nil, fmt.Errorf("failed to create directory: %w", err) + } + defer os.RemoveAll(tmpDir) + // 1. Create container request. // Some (e.g. Image) may be overridden by providing an option argument to this function. req := testcontainers.GenericContainerRequest{ @@ -51,7 +67,7 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize }, Entrypoint: []string{}, Cmd: []string{ - "/entrypoint-tc.sh", + entrypointFile, "redpanda", "start", "--mode=dev-container", @@ -75,38 +91,66 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize // We have to do this kind of two-step process, because we need to know the mapped // port, so that we can use this in Redpanda's advertised listeners configuration for // the Kafka API. - entrypointFile, err := createEntrypointTmpFile() - if err != nil { + entrypointPath := filepath.Join(tmpDir, entrypointFile) + if err := os.WriteFile(entrypointPath, entrypoint, 0o700); err != nil { return nil, fmt.Errorf("failed to create entrypoint file: %w", err) } // Bootstrap config file contains cluster configurations which will only be considered // the very first time you start a cluster. - bootstrapConfigFile, err := createBootstrapConfigFile(settings) + bootstrapConfigPath := filepath.Join(tmpDir, bootstrapConfigFile) + bootstrapConfig, err := renderBootstrapConfig(settings) if err != nil { return nil, fmt.Errorf("failed to create bootstrap config file: %w", err) } + if err := os.WriteFile(bootstrapConfigPath, bootstrapConfig, 0o600); err != nil { + return nil, fmt.Errorf("failed to create bootstrap config file: %w", err) + } - toBeMountedFiles := []testcontainers.ContainerFile{ - { - HostFilePath: entrypointFile.Name(), - ContainerFilePath: "/entrypoint-tc.sh", + req.Files = append(req.Files, + testcontainers.ContainerFile{ + HostFilePath: entrypointPath, + ContainerFilePath: entrypointFile, FileMode: 700, }, - { - HostFilePath: bootstrapConfigFile.Name(), - ContainerFilePath: "/etc/redpanda/.bootstrap.yaml", - FileMode: 700, + testcontainers.ContainerFile{ + HostFilePath: bootstrapConfigPath, + ContainerFilePath: filepath.Join(redpandaDir, bootstrapConfigFile), + FileMode: 600, }, + ) + + // 4. Create certificate and key for TLS connections. + if settings.EnableTLS { + certPath := filepath.Join(tmpDir, certFile) + if err := os.WriteFile(certPath, settings.cert, 0o600); err != nil { + return nil, fmt.Errorf("failed to create certificate file: %w", err) + } + keyPath := filepath.Join(tmpDir, keyFile) + if err := os.WriteFile(keyPath, settings.key, 0o600); err != nil { + return nil, fmt.Errorf("failed to create key file: %w", err) + } + + req.Files = append(req.Files, + testcontainers.ContainerFile{ + HostFilePath: certPath, + ContainerFilePath: filepath.Join(redpandaDir, certFile), + FileMode: 600, + }, + testcontainers.ContainerFile{ + HostFilePath: keyPath, + ContainerFilePath: filepath.Join(redpandaDir, keyFile), + FileMode: 600, + }, + ) } - req.Files = append(req.Files, toBeMountedFiles...) container, err := testcontainers.GenericContainer(ctx, req) if err != nil { return nil, err } - // 4. Get mapped port for the Kafka API, so that we can render and then mount + // 5. Get mapped port for the Kafka API, so that we can render and then mount // the Redpanda config with the advertised Kafka address. hostIP, err := container.Host(ctx) if err != nil { @@ -118,18 +162,13 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize return nil, fmt.Errorf("failed to get mapped Kafka port: %w", err) } - // 5. Render redpanda.yaml config and mount it. + // 6. Render redpanda.yaml config and mount it. nodeConfig, err := renderNodeConfig(settings, hostIP, kafkaPort.Int()) if err != nil { return nil, fmt.Errorf("failed to render node config: %w", err) } - err = container.CopyToContainer( - ctx, - nodeConfig, - "/etc/redpanda/redpanda.yaml", - 700, - ) + err = container.CopyToContainer(ctx, nodeConfig, filepath.Join(redpandaDir, "redpanda.yaml"), 600) if err != nil { return nil, fmt.Errorf("failed to copy redpanda.yaml into container: %w", err) } @@ -159,73 +198,37 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize } } - return &Container{Container: container}, nil + scheme := "http" + if settings.EnableTLS { + scheme += "s" + } + + return &Container{Container: container, urlScheme: scheme}, nil } // KafkaSeedBroker returns the seed broker that should be used for connecting // to the Kafka API with your Kafka client. It'll be returned in the format: // "host:port" - for example: "localhost:55687". func (c *Container) KafkaSeedBroker(ctx context.Context) (string, error) { - return c.getMappedHostPort(ctx, nat.Port(defaultKafkaAPIPort)) + return c.PortEndpoint(ctx, nat.Port(defaultKafkaAPIPort), "") } // AdminAPIAddress returns the address to the Redpanda Admin API. This // is an HTTP-based API and thus the returned format will be: http://host:port. func (c *Container) AdminAPIAddress(ctx context.Context) (string, error) { - hostPort, err := c.getMappedHostPort(ctx, nat.Port(defaultAdminAPIPort)) - if err != nil { - return "", err - } - return fmt.Sprintf("http://%v", hostPort), nil + return c.PortEndpoint(ctx, nat.Port(defaultAdminAPIPort), c.urlScheme) } // SchemaRegistryAddress returns the address to the schema registry API. This // is an HTTP-based API and thus the returned format will be: http://host:port. func (c *Container) SchemaRegistryAddress(ctx context.Context) (string, error) { - hostPort, err := c.getMappedHostPort(ctx, nat.Port(defaultSchemaRegistryPort)) - if err != nil { - return "", err - } - return fmt.Sprintf("http://%v", hostPort), nil + return c.PortEndpoint(ctx, nat.Port(defaultSchemaRegistryPort), c.urlScheme) } -// getMappedHostPort returns the mapped host and port a given nat.Port following -// this format: "host:port". The mapped port is the port that is accessible from -// the host system and is remapped to the given container port. -func (c *Container) getMappedHostPort(ctx context.Context, port nat.Port) (string, error) { - hostIP, err := c.Host(ctx) - if err != nil { - return "", fmt.Errorf("failed to get hostIP: %w", err) - } - - mappedPort, err := c.MappedPort(ctx, port) - if err != nil { - return "", fmt.Errorf("failed to get mapped port: %w", err) - } - - return fmt.Sprintf("%v:%d", hostIP, mappedPort.Int()), nil -} - -// createEntrypointTmpFile returns a temporary file with the custom entrypoint -// that awaits the actual Redpanda config after the container has been started, -// before it's going to start the Redpanda process. -func createEntrypointTmpFile() (*os.File, error) { - entrypointTmpFile, err := os.CreateTemp("", "") - if err != nil { - return nil, err - } - - if err := os.WriteFile(entrypointTmpFile.Name(), entrypoint, 0o700); err != nil { - return nil, err - } - - return entrypointTmpFile, nil -} - -// createBootstrapConfigFile renders the config template for the .bootstrap.yaml config, +// renderBootstrapConfig renders the config template for the .bootstrap.yaml config, // which configures Redpanda's cluster properties. // Reference: https://docs.redpanda.com/docs/reference/cluster-properties/ -func createBootstrapConfigFile(settings options) (*os.File, error) { +func renderBootstrapConfig(settings options) ([]byte, error) { bootstrapTplParams := redpandaBootstrapConfigTplParams{ Superusers: settings.Superusers, KafkaAPIEnableAuthorization: settings.KafkaEnableAuthorization, @@ -242,16 +245,7 @@ func createBootstrapConfigFile(settings options) (*os.File, error) { return nil, fmt.Errorf("failed to render redpanda bootstrap config template: %w", err) } - bootstrapTmpFile, err := os.CreateTemp("", "") - if err != nil { - return nil, err - } - - if err := os.WriteFile(bootstrapTmpFile.Name(), bootstrapConfig.Bytes(), 0o700); err != nil { - return nil, err - } - - return bootstrapTmpFile, nil + return bootstrapConfig.Bytes(), nil } // renderNodeConfig renders the redpanda.yaml node config and returns it as @@ -268,6 +262,7 @@ func renderNodeConfig(settings options, hostIP string, advertisedKafkaPort int) SchemaRegistry: redpandaConfigTplParamsSchemaRegistry{ AuthenticationMethod: settings.SchemaRegistryAuthenticationMethod, }, + EnableTLS: settings.EnableTLS, } ncTpl, err := template.New("redpanda.yaml").Parse(nodeConfigTpl) @@ -293,6 +288,7 @@ type redpandaConfigTplParams struct { KafkaAPI redpandaConfigTplParamsKafkaAPI SchemaRegistry redpandaConfigTplParamsSchemaRegistry AutoCreateTopics bool + EnableTLS bool } type redpandaConfigTplParamsKafkaAPI struct { diff --git a/modules/redpanda/redpanda_test.go b/modules/redpanda/redpanda_test.go index af7a5244ef..95a601c6ab 100644 --- a/modules/redpanda/redpanda_test.go +++ b/modules/redpanda/redpanda_test.go @@ -2,8 +2,11 @@ package redpanda import ( "context" + "crypto/tls" + "crypto/x509" "fmt" "net/http" + "strings" "testing" "time" @@ -47,7 +50,7 @@ func TestRedpanda(t *testing.T) { httpCl := &http.Client{Timeout: 5 * time.Second} schemaRegistryURL, err := container.SchemaRegistryAddress(ctx) require.NoError(t, err) - req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/subjects", schemaRegistryURL), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/subjects", schemaRegistryURL), nil) require.NoError(t, err) resp, err := httpCl.Do(req) require.NoError(t, err) @@ -59,7 +62,7 @@ func TestRedpanda(t *testing.T) { adminAPIURL, err := container.AdminAPIAddress(ctx) require.NoError(t, err) // } - req, err = http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/v1/cluster/health_overview", adminAPIURL), nil) + req, err = http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/v1/cluster/health_overview", adminAPIURL), nil) require.NoError(t, err) resp, err = httpCl.Do(req) require.NoError(t, err) @@ -163,7 +166,7 @@ func TestRedpandaWithAuthentication(t *testing.T) { // } // Failed authentication - req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/subjects", schemaRegistryURL), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/subjects", schemaRegistryURL), nil) require.NoError(t, err) resp, err := httpCl.Do(req) require.NoError(t, err) @@ -205,3 +208,128 @@ func TestRedpandaProduceWithAutoCreateTopics(t *testing.T) { results := kafkaCl.ProduceSync(ctx, &kgo.Record{Topic: "test", Value: []byte("test message")}) require.NoError(t, results.FirstErr()) } + +func TestRedpandaWithTLS(t *testing.T) { + cert, err := tls.X509KeyPair(localhostCert, localhostKey) + require.NoError(t, err, "failed to load key pair") + + ctx := context.Background() + + container, err := RunContainer(ctx, WithTLS(localhostCert, localhostKey)) + require.NoError(t, err) + + t.Cleanup(func() { + if err := container.Terminate(ctx); err != nil { + t.Fatalf("failed to terminate container: %s", err) + } + }) + + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM(localhostCert) + + tlsConfig := &tls.Config{ + Certificates: []tls.Certificate{cert}, + RootCAs: caCertPool, + } + + httpCl := &http.Client{ + Timeout: 5 * time.Second, + Transport: &http.Transport{ + ForceAttemptHTTP2: true, + TLSHandshakeTimeout: 10 * time.Second, + TLSClientConfig: tlsConfig, + }, + } + + // Test Admin API + adminAPIURL, err := container.AdminAPIAddress(ctx) + require.NoError(t, err) + require.True(t, strings.HasPrefix(adminAPIURL, "https://"), "AdminAPIAddress should return https url") + req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/v1/cluster/health_overview", adminAPIURL), nil) + require.NoError(t, err) + resp, err := httpCl.Do(req) + require.NoError(t, err) + assert.Equal(t, http.StatusOK, resp.StatusCode) + resp.Body.Close() + + // Test Schema Registry API + schemaRegistryURL, err := container.SchemaRegistryAddress(ctx) + require.NoError(t, err) + require.True(t, strings.HasPrefix(adminAPIURL, "https://"), "SchemaRegistryAddress should return https url") + req, err = http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/subjects", schemaRegistryURL), nil) + require.NoError(t, err) + resp, err = httpCl.Do(req) + require.NoError(t, err) + assert.Equal(t, http.StatusOK, resp.StatusCode) + resp.Body.Close() + + brokers, err := container.KafkaSeedBroker(ctx) + require.NoError(t, err) + + kafkaCl, err := kgo.NewClient( + kgo.SeedBrokers(brokers), + kgo.DialTLSConfig(tlsConfig), + ) + require.NoError(t, err) + defer kafkaCl.Close() + + // Test produce to unknown topic + results := kafkaCl.ProduceSync(ctx, &kgo.Record{Topic: "test", Value: []byte("test message")}) + require.Error(t, results.FirstErr(), kerr.UnknownTopicOrPartition) +} + +// localhostCert is a PEM-encoded TLS cert with SAN IPs +// generated from src/crypto/tls: +// go run generate_cert.go --rsa-bits 2048 --host 127.0.0.1,::1,localhost --ca --start-date "Jan 1 00:00:00 1970" --duration=1000000h +var localhostCert = []byte(`-----BEGIN CERTIFICATE----- +MIIDODCCAiCgAwIBAgIRAKMykg5qJSCb4L3WtcZznSQwDQYJKoZIhvcNAQELBQAw +EjEQMA4GA1UEChMHQWNtZSBDbzAgFw03MDAxMDEwMDAwMDBaGA8yMDg0MDEyOTE2 +MDAwMFowEjEQMA4GA1UEChMHQWNtZSBDbzCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAPYcLIhqCsrmqvsY1gWqI1jx3Ytn5Qjfvlg3BPD/YeD4UVouBhgQ +NIIERFCmDUzu52pXYZeCouBIVDWqZKixQf3PyBzAqbFvX0pTsZrOnvjuoahzjEcl +x+CfkIp58mVaV/8v9TyBYCXNuHlI7Pndu/3U5d6npSg8+dTkwW3VZzZyHpsDW+a4 +ByW02NI58LoHzQPMRg9MFToL1qNQy4PFyADf2N/3/SYOkrbSrXA0jYqXE8yvQGYe +LWcoQ+4YkurSS1TgSNEKxrzGj8w4xRjEjRNsLVNWd8uxZkHwv6LXOn4s39ix3jN4 +7OJJHA8fJAWxAP4ThrpM1j5J+Rq1PD380u8CAwEAAaOBhjCBgzAOBgNVHQ8BAf8E +BAMCAqQwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zAdBgNV +HQ4EFgQU8gMBt2leRAnGgCQ6pgIYPHY35GAwLAYDVR0RBCUwI4IJbG9jYWxob3N0 +hwR/AAABhxAAAAAAAAAAAAAAAAAAAAABMA0GCSqGSIb3DQEBCwUAA4IBAQA5F6aw +6JJMsnCjxRGYXb252zqjxOxweawZ2je4UAGSsF27Phm1Bx6/2mzPpgIB0I7xNBFL +ljtqBG/FpH6qWpkkegljL8Z5soXiye/4r1G+V6hadm32/OLQCS//dyq7W1a2uVlS +KdFjoNqRW2PacVQLjnTbP2SJV5CnrJgCsSMXVoNnKdj5gr5ltNNAt9TAJ85iFa5d +rJla/XghtqEOzYtigKPF7EVqRRl4RmPu30hxwDZMT60ptFolfCEeXpDra5uonJMv +ElEbzK8ZzXmvWCj94RjPkGKZs8+SDM2qfKPk5ZW2xJxwqS3tkEkZlj1L+b7zYOlt +aJ65OWCXHLecrgdl +-----END CERTIFICATE-----`) + +// localhostKey is the private key for localhostCert. +var localhostKey = []byte(testingKey(`-----BEGIN TESTING KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD2HCyIagrK5qr7 +GNYFqiNY8d2LZ+UI375YNwTw/2Hg+FFaLgYYEDSCBERQpg1M7udqV2GXgqLgSFQ1 +qmSosUH9z8gcwKmxb19KU7Gazp747qGoc4xHJcfgn5CKefJlWlf/L/U8gWAlzbh5 +SOz53bv91OXep6UoPPnU5MFt1Wc2ch6bA1vmuAcltNjSOfC6B80DzEYPTBU6C9aj +UMuDxcgA39jf9/0mDpK20q1wNI2KlxPMr0BmHi1nKEPuGJLq0ktU4EjRCsa8xo/M +OMUYxI0TbC1TVnfLsWZB8L+i1zp+LN/Ysd4zeOziSRwPHyQFsQD+E4a6TNY+Sfka +tTw9/NLvAgMBAAECggEBALKxAiSJ2gw4Lyzhe4PhZIjQE+uEI+etjKbAS/YvdwHB +SlAP2pzeJ0G/l1p3NnEFhUDQ8SrwzxHJclsEvNE+4otGsiUuPgd2tdlhqzKbkxFr +MjT8sH14EQgm0uu4Xyb30ayXRZgI16abF7X4HRfOxxAl5EElt+TfYQYSkd8Nc0Mz +bD7g0riSdOKVhNIkUTT1U7x8ClIgff6vbWztOVP4hGezqEKpO/8+JBkg2GLeH3lC +PyuHEb33Foxg7SX35M1a89EKC2p4ER6/nfg6wGYyIsn42gBk1JgQdg23x7c/0WOu +vcw1unNP2kCbnsCeZ6KPRRGXEjbpTqOTzAUOekOeOgECgYEA9/jwK2wrX2J3kJN7 +v6kmxazigXHCa7XmFMgTfdqiQfXfjdi/4u+4KAX04jWra3ZH4KT98ztPOGjb6KhM +hfMldsxON8S9IQPcbDyj+5R77KU4BG/JQBEOX1uzS9KjMVG5e9ZUpG5UnSoSOgyM +oN3DZto7C5ULO2U2MT8JaoGb53cCgYEA/hPNMsCXFairxKy0BCsvJFan93+GIdwM +YoAGLc4Oj67ES8TYC4h9Im5i81JYOjpY4aZeKdj8S+ozmbqqa/iJiAfOr37xOMuX +AQA2T8uhPXXNXA5s6T3LaIXtzL0NmRRZCtuyEGdCidIXub7Bz8LrfsMc+s/jv57f +4IPmW12PPkkCgYBpEdDqBT5nfzh8SRGhR1IHZlbfVE12CDACVDh2FkK0QjNETjgY +N0zHoKZ/hxAoS4jvNdnoyxOpKj0r2sv54enY6X6nALTGnXUzY4p0GhlcTzFqJ9eV +TuTRIPDaytidGCzIvStGNP2jTmVEtXaM3wphtUxZfwCwXRVWToh12Y8uxwKBgA1a +FQp5vHbS6lPnj344lr2eIC2NcgsNeUkj2S9HCNTcJkylB4Vzor/QdTq8NQ66Sjlx +eLlSQc/retK1UIdkBDY10tK+JQcLC+Btlm0TEmIccrJHv8lyCeJwR1LfDHvi6dr8 +OJtMEd8UP1Lvh1fXsnBy6G71xc4oFzPBOrXKcOChAoGACOgyYe47ZizScsUGjCC7 +xARTEolZhtqHKVd5s9oi95P0r7A1gcNx/9YW0rCT2ZD8BD9H++HTE2L+mh3R9zDn +jwDeW7wVZec+oyGdc9L+B1xU25O+88zNLxlRAX8nXJbHdgL83UclmC51GbXejloP +D4ZNvyXf/6E27Ibu6v2p/vs= +-----END TESTING KEY-----`)) + +func testingKey(s string) string { return strings.ReplaceAll(s, "TESTING KEY", "PRIVATE KEY") } From b914c67f32534587c5d91cf6d2db5e0eabd99761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 23 Aug 2023 11:51:39 +0200 Subject: [PATCH 07/26] fix: reset config in tests (#1516) * fix: reset config in tests * fix: another reset --- config_test.go | 3 +++ internal/config/config_test.go | 4 ++++ logconsumer_test.go | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/config_test.go b/config_test.go index e2c803b904..85a7f8bba7 100644 --- a/config_test.go +++ b/config_test.go @@ -17,6 +17,9 @@ func resetTestEnv(t *testing.T) { func TestReadConfig(t *testing.T) { resetTestEnv(t) + t.Cleanup(func() { + config.Reset() + }) t.Run("Config is read just once", func(t *testing.T) { t.Setenv("HOME", "") diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 6118ee881c..350c9a9ff4 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -26,6 +26,10 @@ func TestReadConfig(t *testing.T) { resetTestEnv(t) t.Run("Config is read just once", func(t *testing.T) { + t.Cleanup(func() { + Reset() + }) + t.Setenv("HOME", "") t.Setenv("USERPROFILE", "") // Windows support t.Setenv("DOCKER_HOST", "") diff --git a/logconsumer_test.go b/logconsumer_test.go index 05f8d558a6..478557828d 100644 --- a/logconsumer_test.go +++ b/logconsumer_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/internal/config" "github.com/testcontainers/testcontainers-go/wait" ) @@ -253,6 +254,10 @@ func Test_StartStop(t *testing.T) { } func TestContainerLogWithErrClosed(t *testing.T) { + t.Cleanup(func() { + config.Reset() + }) + if providerType == ProviderPodman { t.Skip("Docker-in-Docker does not work with rootless Podman") } From 34ba6ebf3a4a78d868776641597de7f83b5e69d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 23 Aug 2023 18:15:09 +0200 Subject: [PATCH 08/26] fix: do not remove the file schema in docker.host property (#1517) * fix: do not remove the file schema in docker.host property * fix: proper setup for tests * fix: refine test preparation --- internal/testcontainersdocker/docker_host.go | 7 +--- .../testcontainersdocker/docker_host_test.go | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/internal/testcontainersdocker/docker_host.go b/internal/testcontainersdocker/docker_host.go index 6d96029a9c..f6ee5b9a50 100644 --- a/internal/testcontainersdocker/docker_host.go +++ b/internal/testcontainersdocker/docker_host.go @@ -212,12 +212,7 @@ func dockerHostFromProperties(ctx context.Context) (string, error) { cfg := config.Read() socketPath := cfg.Host if socketPath != "" { - parsed, err := parseURL(socketPath) - if err != nil { - return "", err - } - - return parsed, nil + return socketPath, nil } return "", ErrDockerSocketNotSetInProperties diff --git a/internal/testcontainersdocker/docker_host_test.go b/internal/testcontainersdocker/docker_host_test.go index 45684e134b..90ded428e6 100644 --- a/internal/testcontainersdocker/docker_host_test.go +++ b/internal/testcontainersdocker/docker_host_test.go @@ -107,6 +107,18 @@ func TestExtractDockerHost(t *testing.T) { assert.Equal(t, "/this/is/a/sample.sock", host) }) + t.Run("Unix Docker Host is passed as docker.host", func(t *testing.T) { + setupDockerSocketNotFound(t) + setupRootlessNotFound(t) + content := "docker.host=" + DockerSocketSchema + "/this/is/a/sample.sock" + + setupTestcontainersProperties(t, content) + + host := extractDockerHost(context.Background()) + + assert.Equal(t, DockerSocketSchema+"/this/is/a/sample.sock", host) + }) + t.Run("Default Docker socket", func(t *testing.T) { setupRootlessNotFound(t) tmpSocket := setupDockerSocket(t) @@ -225,8 +237,8 @@ func TestExtractDockerHost(t *testing.T) { }) t.Run("Docker host is defined in properties", func(t *testing.T) { - tmpSocket := "/this/is/a/sample.sock" - content := "docker.host=unix://" + tmpSocket + tmpSocket := "unix:///this/is/a/sample.sock" + content := "docker.host=" + tmpSocket setupTestcontainersProperties(t, content) @@ -383,6 +395,22 @@ func TestExtractDockerSocketFromClient(t *testing.T) { socket = extractDockerSocketFromClient(ctx, mockCli{OS: "Ubuntu"}) assert.Equal(t, DockerSocketPath, socket) }) + + t.Run("Unix Docker Socket is passed as docker.host property", func(t *testing.T) { + content := "docker.host=" + DockerSocketSchema + "/this/is/a/sample.sock" + setupTestcontainersProperties(t, content) + setupDockerSocketNotFound(t) + + t.Cleanup(resetSocketOverrideFn) + + ctx := context.Background() + os.Unsetenv("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE") + os.Unsetenv("DOCKER_HOST") + + socket := extractDockerSocketFromClient(ctx, mockCli{OS: "Ubuntu"}) + + assert.Equal(t, "/this/is/a/sample.sock", socket) + }) } func TestInAContainer(t *testing.T) { From 98ceaee3ac636f227afd0464e70e8712d1537b35 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 24 Aug 2023 09:11:40 +0200 Subject: [PATCH 09/26] modulegen: create internal/mkdocs (#1504) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * modulegen: create internal/mkdocs Signed-off-by: Matthieu MOREL * Apply suggestions from code review Co-authored-by: Manuel de la Peña --------- Signed-off-by: Matthieu MOREL Co-authored-by: Manuel de la Peña --- modulegen/context.go | 31 +++++++ modulegen/context_test.go | 24 +---- modulegen/go.mod | 1 + modulegen/go.sum | 2 + modulegen/internal/mkdocs/main.go | 18 ++++ modulegen/internal/mkdocs/reader.go | 23 +++++ .../{mkdocs.go => internal/mkdocs/types.go} | 81 ++++++----------- modulegen/internal/mkdocs/writer.go | 15 ++++ modulegen/main.go | 65 +++++--------- modulegen/main_test.go | 89 +++++++++---------- modulegen/mkdocs_test.go | 47 +++++----- 11 files changed, 211 insertions(+), 185 deletions(-) create mode 100644 modulegen/internal/mkdocs/main.go create mode 100644 modulegen/internal/mkdocs/reader.go rename modulegen/{mkdocs.go => internal/mkdocs/types.go} (55%) create mode 100644 modulegen/internal/mkdocs/writer.go diff --git a/modulegen/context.go b/modulegen/context.go index 470cd5113c..5eb386ce2c 100644 --- a/modulegen/context.go +++ b/modulegen/context.go @@ -45,6 +45,25 @@ func (ctx *Context) getModulesByBaseDir(baseDir string) ([]string, error) { return dirs, nil } +func (ctx *Context) getMarkdownsFromDir(baseDir string) ([]string, error) { + dir := filepath.Join(ctx.DocsDir(), baseDir) + + allFiles, err := os.ReadDir(dir) + if err != nil { + return nil, err + } + + dirs := make([]string, 0) + + for _, f := range allFiles { + if !f.IsDir() && filepath.Ext(f.Name()) == ".md" { + dirs = append(dirs, f.Name()) + } + } + sort.Strings(dirs) + return dirs, nil +} + func (ctx *Context) GetExamples() ([]string, error) { return ctx.getModulesByBaseDir("examples") } @@ -53,6 +72,18 @@ func (ctx *Context) GetModules() ([]string, error) { return ctx.getModulesByBaseDir("modules") } +func (ctx *Context) GetExamplesDocs() ([]string, error) { + return ctx.getMarkdownsFromDir("examples") +} + +func (ctx *Context) GetModulesDocs() ([]string, error) { + return ctx.getMarkdownsFromDir("modules") +} + func (ctx *Context) MkdocsConfigFile() string { return filepath.Join(ctx.RootDir, "mkdocs.yml") } + +func NewContext(dir string) *Context { + return &Context{RootDir: dir} +} diff --git a/modulegen/context_test.go b/modulegen/context_test.go index 101a1a33cc..b0812a5308 100644 --- a/modulegen/context_test.go +++ b/modulegen/context_test.go @@ -1,4 +1,4 @@ -package main_test +package main import ( "os" @@ -9,14 +9,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - main "github.com/testcontainers/testcontainers-go/modulegen" "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" ) func TestGetDependabotConfigFile(t *testing.T) { - tmp := t.TempDir() - - ctx := &main.Context{RootDir: filepath.Join(tmp, "testcontainers-go")} + ctx := NewContext(filepath.Join(t.TempDir(), "testcontainers-go")) githubDir := ctx.GithubDir() cfgFile := ctx.DependabotConfigFile() @@ -33,9 +30,7 @@ func TestGetDependabotConfigFile(t *testing.T) { } func TestExamplesHasDependabotEntry(t *testing.T) { - rootDir, err := getRootDir() - require.NoError(t, err) - ctx := &main.Context{RootDir: rootDir} + ctx := getRootContext(t) examples, err := ctx.GetExamples() require.NoError(t, err) dependabotUpdates, err := dependabot.GetUpdates(ctx.DependabotConfigFile()) @@ -69,9 +64,7 @@ func TestExamplesHasDependabotEntry(t *testing.T) { } func TestModulesHasDependabotEntry(t *testing.T) { - rootDir, err := getRootDir() - require.NoError(t, err) - ctx := &main.Context{RootDir: rootDir} + ctx := getRootContext(t) modules, err := ctx.GetModules() require.NoError(t, err) dependabotUpdates, err := dependabot.GetUpdates(ctx.DependabotConfigFile()) @@ -102,12 +95,3 @@ func TestModulesHasDependabotEntry(t *testing.T) { assert.True(t, found, "module %s is not present in the dependabot updates", module) } } - -func getRootDir() (string, error) { - current, err := os.Getwd() - if err != nil { - return "", err - } - - return filepath.Dir(current), nil -} diff --git a/modulegen/go.mod b/modulegen/go.mod index df75acc582..a8af7dd31d 100644 --- a/modulegen/go.mod +++ b/modulegen/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( github.com/stretchr/testify v1.8.4 + golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb golang.org/x/text v0.12.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/modulegen/go.sum b/modulegen/go.sum index 9981e21553..0e13755d92 100644 --- a/modulegen/go.sum +++ b/modulegen/go.sum @@ -4,6 +4,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= +golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/modulegen/internal/mkdocs/main.go b/modulegen/internal/mkdocs/main.go new file mode 100644 index 0000000000..2c49480963 --- /dev/null +++ b/modulegen/internal/mkdocs/main.go @@ -0,0 +1,18 @@ +package mkdocs + +func UpdateConfig(configFile string, isModule bool, exampleMd string, indexMd string) error { + config, err := ReadConfig(configFile) + if err != nil { + return err + } + config.addExample(isModule, exampleMd, indexMd) + return writeConfig(configFile, config) +} + +func CopyConfig(configFile string, tmpFile string) error { + config, err := ReadConfig(configFile) + if err != nil { + return err + } + return writeConfig(tmpFile, config) +} diff --git a/modulegen/internal/mkdocs/reader.go b/modulegen/internal/mkdocs/reader.go new file mode 100644 index 0000000000..650d51baea --- /dev/null +++ b/modulegen/internal/mkdocs/reader.go @@ -0,0 +1,23 @@ +package mkdocs + +import ( + "os" + + "gopkg.in/yaml.v3" +) + +func ReadConfig(configFile string) (*Config, error) { + file, err := os.ReadFile(configFile) + if err != nil { + return nil, err + } + + config := &Config{} + + err = yaml.Unmarshal(file, config) + if err != nil { + return nil, err + } + + return config, nil +} diff --git a/modulegen/mkdocs.go b/modulegen/internal/mkdocs/types.go similarity index 55% rename from modulegen/mkdocs.go rename to modulegen/internal/mkdocs/types.go index ed41f3dfa8..5e6529af79 100644 --- a/modulegen/mkdocs.go +++ b/modulegen/internal/mkdocs/types.go @@ -1,13 +1,13 @@ -package main +package mkdocs import ( - "os" - "path/filepath" + "sort" + "strings" - "gopkg.in/yaml.v3" + "golang.org/x/exp/slices" ) -type MkDocsConfig struct { +type Config struct { SiteName string `yaml:"site_name"` SiteURL string `yaml:"site_url"` Plugins []string `yaml:"plugins"` @@ -44,59 +44,36 @@ type MkDocsConfig struct { } `yaml:"extra"` } -func getMkdocsConfigFile(rootDir string) string { - return filepath.Join(rootDir, "mkdocs.yml") -} - -func getExamples() ([]os.DirEntry, error) { - return getModulesOrExamples(false) -} - -func getExamplesDocs() ([]os.DirEntry, error) { - parent, err := getRootDir() - if err != nil { - return nil, err - } - - dir := filepath.Join(parent, "docs", "examples") - - return os.ReadDir(dir) -} - -func getRootDir() (string, error) { - current, err := os.Getwd() - if err != nil { - return "", err +func (c *Config) addExample(isModule bool, exampleMd string, indexMd string) { + mkdocsExamplesNav := c.Nav[4].Examples + if isModule { + mkdocsExamplesNav = c.Nav[3].Modules } - return filepath.Dir(current), nil -} - -func readMkdocsConfig(rootDir string) (*MkDocsConfig, error) { - configFile := getMkdocsConfigFile(rootDir) + if !slices.Contains(mkdocsExamplesNav, exampleMd) { - file, err := os.ReadFile(configFile) - if err != nil { - return nil, err - } + // make sure the index.md is the first element in the list of examples in the nav + examplesNav := make([]string, len(mkdocsExamplesNav)-1) + j := 0 - config := &MkDocsConfig{} + for _, exampleNav := range mkdocsExamplesNav { + // filter out the index.md file + if !strings.HasSuffix(exampleNav, "index.md") { + examplesNav[j] = exampleNav + j++ + } + } - err = yaml.Unmarshal(file, config) - if err != nil { - return nil, err - } + examplesNav = append(examplesNav, exampleMd) + sort.Strings(examplesNav) - return config, nil -} + // prepend the index.md file + examplesNav = append([]string{indexMd}, examplesNav...) -func writeMkdocsConfig(rootDir string, config *MkDocsConfig) error { - data, err := yaml.Marshal(config) - if err != nil { - return err + if isModule { + c.Nav[3].Modules = examplesNav + } else { + c.Nav[4].Examples = examplesNav + } } - - file := getMkdocsConfigFile(rootDir) - - return os.WriteFile(file, data, 0o777) } diff --git a/modulegen/internal/mkdocs/writer.go b/modulegen/internal/mkdocs/writer.go new file mode 100644 index 0000000000..a625d2ab27 --- /dev/null +++ b/modulegen/internal/mkdocs/writer.go @@ -0,0 +1,15 @@ +package mkdocs + +import ( + "os" + + "gopkg.in/yaml.v3" +) + +func writeConfig(configFile string, config *Config) error { + data, err := yaml.Marshal(config) + if err != nil { + return err + } + return os.WriteFile(configFile, data, 0o777) +} diff --git a/modulegen/main.go b/modulegen/main.go index 2b7eb9ad03..b33c67356e 100644 --- a/modulegen/main.go +++ b/modulegen/main.go @@ -17,6 +17,7 @@ import ( "golang.org/x/text/language" "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" + "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" ) var ( @@ -131,9 +132,9 @@ func main() { os.Exit(1) } - rootDir := filepath.Dir(currentDir) + ctx := NewContext(filepath.Dir(currentDir)) - mkdocsConfig, err := readMkdocsConfig(rootDir) + mkdocsConfig, err := mkdocs.ReadConfig(ctx.MkdocsConfigFile()) if err != nil { fmt.Printf(">> could not read MkDocs config: %v\n", err) os.Exit(1) @@ -147,13 +148,13 @@ func main() { TCVersion: mkdocsConfig.Extra.LatestVersion, } - err = generate(example, rootDir) + err = generate(example, ctx) if err != nil { fmt.Printf(">> error generating the example: %v\n", err) os.Exit(1) } - cmdDir := filepath.Join(rootDir, example.ParentDir(), example.Lower()) + cmdDir := filepath.Join(ctx.RootDir, example.ParentDir(), example.Lower()) err = runGoCommand(cmdDir, "mod", "tidy") if err != nil { fmt.Printf(">> error synchronizing the dependencies: %v\n", err) @@ -170,14 +171,13 @@ func main() { fmt.Println("Thanks!") } -func generate(example Example, rootDir string) error { +func generate(example Example, ctx *Context) error { if err := example.Validate(); err != nil { return err } - ctx := &Context{RootDir: rootDir} githubWorkflowsDir := ctx.GithubWorkflowsDir() - outputDir := filepath.Join(rootDir, example.ParentDir()) + outputDir := filepath.Join(ctx.RootDir, example.ParentDir()) docsOuputDir := filepath.Join(ctx.DocsDir(), example.ParentDir()) funcMap := template.FuncMap{ @@ -264,7 +264,7 @@ func generate(example Example, rootDir string) error { } // update examples in mkdocs - err = generateMkdocs(rootDir, example) + err = generateMkdocs(ctx, example) if err != nil { return err } @@ -284,43 +284,11 @@ func generateDependabotUpdates(ctx *Context, example Example) error { return dependabot.UpdateConfig(ctx.DependabotConfigFile(), directory, "gomod") } -func generateMkdocs(rootDir string, example Example) error { +func generateMkdocs(ctx *Context, example Example) error { // update examples in mkdocs - mkdocsConfig, err := readMkdocsConfig(rootDir) - if err != nil { - return err - } - - mkdocsExamplesNav := mkdocsConfig.Nav[4].Examples - if example.IsModule { - mkdocsExamplesNav = mkdocsConfig.Nav[3].Modules - } - - // make sure the index.md is the first element in the list of examples in the nav - examplesNav := make([]string, len(mkdocsExamplesNav)-1) - j := 0 - - for _, exampleNav := range mkdocsExamplesNav { - // filter out the index.md file - if !strings.HasSuffix(exampleNav, "index.md") { - examplesNav[j] = exampleNav - j++ - } - } - - examplesNav = append(examplesNav, example.ParentDir()+"/"+example.Lower()+".md") - sort.Strings(examplesNav) - - // prepend the index.md file - examplesNav = append([]string{example.ParentDir() + "/index.md"}, examplesNav...) - - if example.IsModule { - mkdocsConfig.Nav[3].Modules = examplesNav - } else { - mkdocsConfig.Nav[4].Examples = examplesNav - } - - return writeMkdocsConfig(rootDir, mkdocsConfig) + exampleMd := example.ParentDir() + "/" + example.Lower() + ".md" + indexMd := example.ParentDir() + "/index.md" + return mkdocs.UpdateConfig(ctx.MkdocsConfigFile(), example.IsModule, exampleMd, indexMd) } func getModulesOrExamples(t bool) ([]os.DirEntry, error) { @@ -375,3 +343,12 @@ func runGoCommand(cmdDir string, args ...string) error { cmd.Dir = cmdDir return cmd.Run() } + +func getRootDir() (string, error) { + current, err := os.Getwd() + if err != nil { + return "", err + } + + return filepath.Dir(current), nil +} diff --git a/modulegen/main_test.go b/modulegen/main_test.go index 617998fdb7..9e9c104d43 100644 --- a/modulegen/main_test.go +++ b/modulegen/main_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" + "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" ) func TestExample(t *testing.T) { @@ -151,10 +152,10 @@ func TestExample_Validate(outer *testing.T) { } func TestGenerateWrongExampleName(t *testing.T) { - rootTmp := t.TempDir() - examplesTmp := filepath.Join(rootTmp, "examples") - examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") - githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") + tmpCtx := NewContext(t.TempDir()) + examplesTmp := filepath.Join(tmpCtx.RootDir, "examples") + examplesDocTmp := filepath.Join(tmpCtx.DocsDir(), "examples") + githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir() err := os.MkdirAll(examplesTmp, 0o777) assert.Nil(t, err) @@ -163,7 +164,7 @@ func TestGenerateWrongExampleName(t *testing.T) { err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) - err = copyInitialMkdocsConfig(t, rootTmp) + err = copyInitialMkdocsConfig(t, tmpCtx) assert.Nil(t, err) tests := []struct { @@ -188,16 +189,16 @@ func TestGenerateWrongExampleName(t *testing.T) { TCVersion: "v0.0.0-test", } - err = generate(example, rootTmp) + err = generate(example, tmpCtx) assert.Error(t, err) } } func TestGenerateWrongExampleTitle(t *testing.T) { - rootTmp := t.TempDir() - examplesTmp := filepath.Join(rootTmp, "examples") - examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") - githubWorkflowsTmp := filepath.Join(rootTmp, ".github", "workflows") + tmpCtx := NewContext(t.TempDir()) + examplesTmp := filepath.Join(tmpCtx.RootDir, "examples") + examplesDocTmp := filepath.Join(tmpCtx.DocsDir(), "examples") + githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir() err := os.MkdirAll(examplesTmp, 0o777) assert.Nil(t, err) @@ -206,7 +207,7 @@ func TestGenerateWrongExampleTitle(t *testing.T) { err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) - err = copyInitialMkdocsConfig(t, rootTmp) + err = copyInitialMkdocsConfig(t, tmpCtx) assert.Nil(t, err) tests := []struct { @@ -232,16 +233,15 @@ func TestGenerateWrongExampleTitle(t *testing.T) { TCVersion: "v0.0.0-test", } - err = generate(example, rootTmp) + err = generate(example, tmpCtx) assert.Error(t, err) } } func TestGenerate(t *testing.T) { - rootTmp := t.TempDir() - tmpCtx := &Context{RootDir: rootTmp} - examplesTmp := filepath.Join(rootTmp, "examples") - examplesDocTmp := filepath.Join(rootTmp, "docs", "examples") + tmpCtx := NewContext(t.TempDir()) + examplesTmp := filepath.Join(tmpCtx.RootDir, "examples") + examplesDocTmp := filepath.Join(tmpCtx.DocsDir(), "examples") githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir() err := os.MkdirAll(examplesTmp, 0o777) @@ -251,13 +251,13 @@ func TestGenerate(t *testing.T) { err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) - err = copyInitialMkdocsConfig(t, rootTmp) + err = copyInitialMkdocsConfig(t, tmpCtx) assert.Nil(t, err) - originalConfig, err := readMkdocsConfig(rootTmp) + originalConfig, err := mkdocs.ReadConfig(tmpCtx.MkdocsConfigFile()) assert.Nil(t, err) - err = copyInitialDependabotConfig(t, tmpCtx.DependabotConfigFile()) + err = copyInitialDependabotConfig(t, tmpCtx) assert.Nil(t, err) originalDependabotConfigUpdates, err := dependabot.GetUpdates(tmpCtx.DependabotConfigFile()) @@ -272,7 +272,7 @@ func TestGenerate(t *testing.T) { } exampleNameLower := example.Lower() - err = generate(example, rootTmp) + err = generate(example, tmpCtx) assert.Nil(t, err) templatesDir, err := os.ReadDir(filepath.Join(".", "_template")) @@ -305,15 +305,14 @@ func TestGenerate(t *testing.T) { assertExampleContent(t, example, filepath.Join(generatedTemplatesDir, exampleNameLower+".go")) assertGoModContent(t, example, filepath.Join(generatedTemplatesDir, "go.mod")) assertMakefileContent(t, example, filepath.Join(generatedTemplatesDir, "Makefile")) - assertMkdocsExamplesNav(t, example, originalConfig, rootTmp) - assertDependabotExamplesUpdates(t, example, originalDependabotConfigUpdates, tmpCtx.DependabotConfigFile()) + assertMkdocsExamplesNav(t, example, originalConfig, tmpCtx) + assertDependabotExamplesUpdates(t, example, originalDependabotConfigUpdates, tmpCtx) } func TestGenerateModule(t *testing.T) { - rootTmp := t.TempDir() - tmpCtx := &Context{RootDir: rootTmp} - modulesTmp := filepath.Join(rootTmp, "modules") - modulesDocTmp := filepath.Join(rootTmp, "docs", "modules") + tmpCtx := NewContext(t.TempDir()) + modulesTmp := filepath.Join(tmpCtx.RootDir, "modules") + modulesDocTmp := filepath.Join(tmpCtx.DocsDir(), "modules") githubWorkflowsTmp := tmpCtx.GithubWorkflowsDir() err := os.MkdirAll(modulesTmp, 0o777) @@ -323,13 +322,13 @@ func TestGenerateModule(t *testing.T) { err = os.MkdirAll(githubWorkflowsTmp, 0o777) assert.Nil(t, err) - err = copyInitialMkdocsConfig(t, rootTmp) + err = copyInitialMkdocsConfig(t, tmpCtx) assert.Nil(t, err) - originalConfig, err := readMkdocsConfig(rootTmp) + originalConfig, err := mkdocs.ReadConfig(tmpCtx.MkdocsConfigFile()) assert.Nil(t, err) - err = copyInitialDependabotConfig(t, tmpCtx.DependabotConfigFile()) + err = copyInitialDependabotConfig(t, tmpCtx) assert.Nil(t, err) originalDependabotConfigUpdates, err := dependabot.GetUpdates(tmpCtx.DependabotConfigFile()) @@ -344,7 +343,7 @@ func TestGenerateModule(t *testing.T) { } exampleNameLower := example.Lower() - err = generate(example, rootTmp) + err = generate(example, tmpCtx) assert.Nil(t, err) templatesDir, err := os.ReadDir(filepath.Join(".", "_template")) @@ -377,13 +376,13 @@ func TestGenerateModule(t *testing.T) { assertExampleContent(t, example, filepath.Join(generatedTemplatesDir, exampleNameLower+".go")) assertGoModContent(t, example, filepath.Join(generatedTemplatesDir, "go.mod")) assertMakefileContent(t, example, filepath.Join(generatedTemplatesDir, "Makefile")) - assertMkdocsExamplesNav(t, example, originalConfig, rootTmp) - assertDependabotExamplesUpdates(t, example, originalDependabotConfigUpdates, tmpCtx.DependabotConfigFile()) + assertMkdocsExamplesNav(t, example, originalConfig, tmpCtx) + assertDependabotExamplesUpdates(t, example, originalDependabotConfigUpdates, tmpCtx) } // assert content in the Examples nav from mkdocs.yml -func assertDependabotExamplesUpdates(t *testing.T, example Example, originalConfigUpdates dependabot.Updates, tmpFile string) { - examples, err := dependabot.GetUpdates(tmpFile) +func assertDependabotExamplesUpdates(t *testing.T, example Example, originalConfigUpdates dependabot.Updates, tmpCtx *Context) { + examples, err := dependabot.GetUpdates(tmpCtx.DependabotConfigFile()) assert.Nil(t, err) assert.Equal(t, len(originalConfigUpdates)+1, len(examples)) @@ -476,14 +475,15 @@ func assertExampleGithubWorkflowContent(t *testing.T, example Example, exampleWo assert.Nil(t, err) data := sanitiseContent(content) + ctx := getRootContext(t) - modulesList, err := getModulesOrExamplesAsString(true) + modulesList, err := ctx.GetModules() assert.Nil(t, err) - assert.Equal(t, " module: ["+modulesList+"]", data[88]) + assert.Equal(t, " module: ["+strings.Join(modulesList, ", ")+"]", data[88]) - examplesList, err := getModulesOrExamplesAsString(false) + examplesList, err := ctx.GetExamples() assert.Nil(t, err) - assert.Equal(t, " module: ["+examplesList+"]", data[104]) + assert.Equal(t, " module: ["+strings.Join(examplesList, ", ")+"]", data[104]) } // assert content go.mod @@ -506,8 +506,8 @@ func assertMakefileContent(t *testing.T, example Example, makefile string) { } // assert content in the Examples nav from mkdocs.yml -func assertMkdocsExamplesNav(t *testing.T, example Example, originalConfig *MkDocsConfig, rootDir string) { - config, err := readMkdocsConfig(rootDir) +func assertMkdocsExamplesNav(t *testing.T, example Example, originalConfig *mkdocs.Config, tmpCtx *Context) { + config, err := mkdocs.ReadConfig(tmpCtx.MkdocsConfigFile()) assert.Nil(t, err) parentDir := example.ParentDir() @@ -547,11 +547,8 @@ func sanitiseContent(bytes []byte) []string { return data } -func copyInitialDependabotConfig(t *testing.T, tmpFile string) error { - projectDir, err := getRootDir() - assert.Nil(t, err) - - ctx := &Context{RootDir: projectDir} +func copyInitialDependabotConfig(t *testing.T, tmpCtx *Context) error { + ctx := getRootContext(t) - return dependabot.CopyConfig(ctx.DependabotConfigFile(), tmpFile) + return dependabot.CopyConfig(ctx.DependabotConfigFile(), tmpCtx.DependabotConfigFile()) } diff --git a/modulegen/mkdocs_test.go b/modulegen/mkdocs_test.go index d996ecac7c..b8314a12a0 100644 --- a/modulegen/mkdocs_test.go +++ b/modulegen/mkdocs_test.go @@ -8,36 +8,34 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" ) func TestGetMkDocsConfigFile(t *testing.T) { - tmp := t.TempDir() - - rootDir := filepath.Join(tmp, "testcontainers-go") - cfgFile := filepath.Join(rootDir, "mkdocs.yml") - err := os.MkdirAll(rootDir, 0o777) + tmpCtx := NewContext(filepath.Join(t.TempDir(), "testcontainers-go")) + cfgFile := tmpCtx.MkdocsConfigFile() + err := os.MkdirAll(tmpCtx.RootDir, 0o777) require.NoError(t, err) err = os.WriteFile(cfgFile, []byte{}, 0o777) require.NoError(t, err) - file := getMkdocsConfigFile(rootDir) + file := tmpCtx.MkdocsConfigFile() require.NotNil(t, file) assert.True(t, strings.HasSuffix(file, filepath.Join("testcontainers-go", "mkdocs.yml"))) } func TestReadMkDocsConfig(t *testing.T) { - tmp := t.TempDir() - - rootDir := filepath.Join(tmp, "testcontainers-go") - err := os.MkdirAll(rootDir, 0o777) + tmpCtx := NewContext(filepath.Join(t.TempDir(), "testcontainers-go")) + err := os.MkdirAll(tmpCtx.RootDir, 0o777) require.NoError(t, err) - err = copyInitialMkdocsConfig(t, rootDir) + err = copyInitialMkdocsConfig(t, tmpCtx) require.NoError(t, err) - config, err := readMkdocsConfig(rootDir) + config, err := mkdocs.ReadConfig(tmpCtx.MkdocsConfigFile()) require.NoError(t, err) require.NotNil(t, config) @@ -58,9 +56,10 @@ func TestReadMkDocsConfig(t *testing.T) { } func TestExamples(t *testing.T) { - examples, err := getExamples() + ctx := getRootContext(t) + examples, err := ctx.GetExamples() require.NoError(t, err) - examplesDocs, err := getExamplesDocs() + examplesDocs, err := ctx.GetExamplesDocs() require.NoError(t, err) // we have to remove the index.md file from the examples docs @@ -70,23 +69,25 @@ func TestExamples(t *testing.T) { for _, example := range examples { found := false for _, exampleDoc := range examplesDocs { - markdownName := example.Name() + ".md" + markdownName := example + ".md" - if markdownName == exampleDoc.Name() { + if markdownName == exampleDoc { found = true continue } } - assert.True(t, found, "example %s is not present in the docs", example.Name()) + assert.True(t, found, "example %s is not present in the docs", example) } } -func copyInitialMkdocsConfig(t *testing.T, tmpDir string) error { - projectDir, err := getRootDir() - require.NoError(t, err) +func copyInitialMkdocsConfig(t *testing.T, tmpCtx *Context) error { + ctx := getRootContext(t) - initialConfig, err := readMkdocsConfig(projectDir) - require.NoError(t, err) + return mkdocs.CopyConfig(ctx.MkdocsConfigFile(), tmpCtx.MkdocsConfigFile()) +} - return writeMkdocsConfig(tmpDir, initialConfig) +func getRootContext(t *testing.T) *Context { + current, err := os.Getwd() + require.NoError(t, err) + return NewContext(filepath.Dir(current)) } From 94c8cb69eb31d00104c1d3efac5466ac79c421e5 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 24 Aug 2023 10:51:27 +0200 Subject: [PATCH 10/26] modulegen: create internal/module (#1505) Signed-off-by: Matthieu MOREL --- modulegen/internal/tools/exec.go | 19 +++++++++++++++++++ modulegen/main.go | 12 +++--------- 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 modulegen/internal/tools/exec.go diff --git a/modulegen/internal/tools/exec.go b/modulegen/internal/tools/exec.go new file mode 100644 index 0000000000..5d5136ddaa --- /dev/null +++ b/modulegen/internal/tools/exec.go @@ -0,0 +1,19 @@ +package tools + +import ( + "os/exec" +) + +func GoModTidy(cmdDir string) error { + return runGoCommand(cmdDir, "mod", "tidy") +} + +func GoVet(cmdDir string) error { + return runGoCommand(cmdDir, "vet", "./...") +} + +func runGoCommand(cmdDir string, args ...string) error { + cmd := exec.Command("go", args...) + cmd.Dir = cmdDir + return cmd.Run() +} diff --git a/modulegen/main.go b/modulegen/main.go index b33c67356e..28976b2e7f 100644 --- a/modulegen/main.go +++ b/modulegen/main.go @@ -5,7 +5,6 @@ import ( "fmt" "html/template" "os" - "os/exec" "path/filepath" "regexp" "sort" @@ -18,6 +17,7 @@ import ( "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" + "github.com/testcontainers/testcontainers-go/modulegen/internal/tools" ) var ( @@ -155,12 +155,12 @@ func main() { } cmdDir := filepath.Join(ctx.RootDir, example.ParentDir(), example.Lower()) - err = runGoCommand(cmdDir, "mod", "tidy") + err = tools.GoModTidy(cmdDir) if err != nil { fmt.Printf(">> error synchronizing the dependencies: %v\n", err) os.Exit(1) } - err = runGoCommand(cmdDir, "vet", "./...") + err = tools.GoVet(cmdDir) if err != nil { fmt.Printf(">> error checking generated code: %v\n", err) os.Exit(1) @@ -338,12 +338,6 @@ func getModulesOrExamplesAsString(t bool) (string, error) { return strings.Join(names, ", "), nil } -func runGoCommand(cmdDir string, args ...string) error { - cmd := exec.Command("go", args...) - cmd.Dir = cmdDir - return cmd.Run() -} - func getRootDir() (string, error) { current, err := os.Getwd() if err != nil { From 9ef033f5aece18a12feb5ed5d0cfdc29a8679e03 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Fri, 25 Aug 2023 09:09:06 +0200 Subject: [PATCH 11/26] modulegen: create internal/workflow (#1520) Signed-off-by: Matthieu MOREL --- .github/workflows/ci.yml | 2 + modulegen/_template/ci.yml.tmpl | 4 +- modulegen/context_test.go | 10 ++- modulegen/internal/template/main.go | 22 +++++++ modulegen/internal/workflow/main.go | 18 ++++++ modulegen/internal/workflow/types.go | 17 ++++++ modulegen/main.go | 91 ++++++---------------------- modulegen/main_test.go | 9 ++- modulegen/mkdocs_test.go | 11 +--- 9 files changed, 94 insertions(+), 90 deletions(-) create mode 100644 modulegen/internal/template/main.go create mode 100644 modulegen/internal/workflow/main.go create mode 100644 modulegen/internal/workflow/types.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3adf6cc31..a93ebd6f26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,5 @@ +# This file is autogenerated by the 'modulegen' tool. +# Please update the 'ci.yml' template instead. name: Main pipeline on: diff --git a/modulegen/_template/ci.yml.tmpl b/modulegen/_template/ci.yml.tmpl index 388d891bfc..2038cdb0e4 100644 --- a/modulegen/_template/ci.yml.tmpl +++ b/modulegen/_template/ci.yml.tmpl @@ -1,3 +1,5 @@ +# This file is autogenerated by the 'modulegen' tool. +# Please update the 'ci.yml' template instead. name: Main pipeline on: @@ -70,7 +72,7 @@ jobs: strategy: matrix: go-version: [1.20.x, 1.x] - platform: [ubuntu-latest, macos-latest] + platform: [ubuntu-latest, macos-latest, windows-latest] uses: ./.github/workflows/ci-test-go.yml with: go-version: {{ "${{ matrix.go-version }}" }} diff --git a/modulegen/context_test.go b/modulegen/context_test.go index b0812a5308..2ec8acc2dd 100644 --- a/modulegen/context_test.go +++ b/modulegen/context_test.go @@ -30,7 +30,7 @@ func TestGetDependabotConfigFile(t *testing.T) { } func TestExamplesHasDependabotEntry(t *testing.T) { - ctx := getRootContext(t) + ctx := getTestRootContext(t) examples, err := ctx.GetExamples() require.NoError(t, err) dependabotUpdates, err := dependabot.GetUpdates(ctx.DependabotConfigFile()) @@ -64,7 +64,7 @@ func TestExamplesHasDependabotEntry(t *testing.T) { } func TestModulesHasDependabotEntry(t *testing.T) { - ctx := getRootContext(t) + ctx := getTestRootContext(t) modules, err := ctx.GetModules() require.NoError(t, err) dependabotUpdates, err := dependabot.GetUpdates(ctx.DependabotConfigFile()) @@ -95,3 +95,9 @@ func TestModulesHasDependabotEntry(t *testing.T) { assert.True(t, found, "module %s is not present in the dependabot updates", module) } } + +func getTestRootContext(t *testing.T) *Context { + current, err := os.Getwd() + require.NoError(t, err) + return NewContext(filepath.Dir(current)) +} diff --git a/modulegen/internal/template/main.go b/modulegen/internal/template/main.go new file mode 100644 index 0000000000..0198cb6465 --- /dev/null +++ b/modulegen/internal/template/main.go @@ -0,0 +1,22 @@ +package template + +import ( + "os" + "path/filepath" + "text/template" +) + +func Generate(t *template.Template, exampleFilePath string, name string, data any) error { + err := os.MkdirAll(filepath.Dir(exampleFilePath), 0o755) + if err != nil { + return err + } + exampleFile, _ := os.Create(exampleFilePath) + defer exampleFile.Close() + + err = t.ExecuteTemplate(exampleFile, name, data) + if err != nil { + return err + } + return nil +} diff --git a/modulegen/internal/workflow/main.go b/modulegen/internal/workflow/main.go new file mode 100644 index 0000000000..098fe2ab75 --- /dev/null +++ b/modulegen/internal/workflow/main.go @@ -0,0 +1,18 @@ +package workflow + +import ( + "path/filepath" + "text/template" + + internal_template "github.com/testcontainers/testcontainers-go/modulegen/internal/template" +) + +func Generate(githubWorkflowsDir string, examples []string, modules []string) error { + projectDirectories := newProjectDirectories(examples, modules) + name := "ci.yml.tmpl" + t, err := template.New(name).ParseFiles(filepath.Join("_template", name)) + if err != nil { + return err + } + return internal_template.Generate(t, filepath.Join(githubWorkflowsDir, "ci.yml"), name, projectDirectories) +} diff --git a/modulegen/internal/workflow/types.go b/modulegen/internal/workflow/types.go new file mode 100644 index 0000000000..77433613fb --- /dev/null +++ b/modulegen/internal/workflow/types.go @@ -0,0 +1,17 @@ +package workflow + +import ( + "strings" +) + +type ProjectDirectories struct { + Examples string + Modules string +} + +func newProjectDirectories(examples []string, modules []string) *ProjectDirectories { + return &ProjectDirectories{ + Examples: strings.Join(examples, ", "), + Modules: strings.Join(modules, ", "), + } +} diff --git a/modulegen/main.go b/modulegen/main.go index 28976b2e7f..65eb2762ad 100644 --- a/modulegen/main.go +++ b/modulegen/main.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" "regexp" - "sort" "strings" "unicode" "unicode/utf8" @@ -18,6 +17,7 @@ import ( "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" "github.com/testcontainers/testcontainers-go/modulegen/internal/tools" + "github.com/testcontainers/testcontainers-go/modulegen/internal/workflow" ) var ( @@ -28,7 +28,7 @@ var ( ) var templates = []string{ - "ci.yml", "docs_example.md", "example_test.go", "example.go", "go.mod", "Makefile", + "docs_example.md", "example_test.go", "example.go", "go.mod", "Makefile", } func init() { @@ -176,7 +176,6 @@ func generate(example Example, ctx *Context) error { return err } - githubWorkflowsDir := ctx.GithubWorkflowsDir() outputDir := filepath.Join(ctx.RootDir, example.ParentDir()) docsOuputDir := filepath.Join(ctx.DocsDir(), example.ParentDir()) @@ -219,30 +218,6 @@ func generate(example Example, ctx *Context) error { if strings.EqualFold(tmpl, "docs_example.md") { // docs example file will go into the docs directory exampleFilePath = filepath.Join(docsOuputDir, exampleLower+".md") - } else if strings.EqualFold(tmpl, "ci.yml") { - // GitHub workflow file will go into the .github/workflows directory - exampleFilePath = filepath.Join(githubWorkflowsDir, "ci.yml") - - type stringsList struct { - Examples string - Modules string - } - - syncDataFn = func() any { - modulesList, err := getModulesOrExamplesAsString(true) - if err != nil { - return "" - } - examplesList, err := getModulesOrExamplesAsString(false) - if err != nil { - return "" - } - - return stringsList{ - Examples: examplesList, - Modules: modulesList, - } - } } else { exampleFilePath = filepath.Join(outputDir, exampleLower, strings.ReplaceAll(tmpl, "example", exampleLower)) } @@ -262,19 +237,21 @@ func generate(example Example, ctx *Context) error { return err } } - + // update github ci workflow + err = generateWorkFlow(ctx) + if err != nil { + return err + } // update examples in mkdocs err = generateMkdocs(ctx, example) if err != nil { return err } - // update examples in dependabot err = generateDependabotUpdates(ctx, example) if err != nil { return err } - return nil } @@ -291,58 +268,26 @@ func generateMkdocs(ctx *Context, example Example) error { return mkdocs.UpdateConfig(ctx.MkdocsConfigFile(), example.IsModule, exampleMd, indexMd) } -func getModulesOrExamples(t bool) ([]os.DirEntry, error) { - baseDir := "examples" - if t { - baseDir = "modules" - } - - parent, err := getRootDir() +func generateWorkFlow(ctx *Context) error { + rootCtx, err := getRootContext() if err != nil { - return nil, err + return err } - - dir := filepath.Join(parent, baseDir) - - allFiles, err := os.ReadDir(dir) + examples, err := rootCtx.GetExamples() if err != nil { - return nil, err - } - - dirs := make([]os.DirEntry, 0) - - for _, f := range allFiles { - // only accept the directories and not the template - if f.IsDir() && f.Name() != "_template" { - dirs = append(dirs, f) - } + return err } - - return dirs, nil -} - -func getModulesOrExamplesAsString(t bool) (string, error) { - dirs, err := getModulesOrExamples(t) + modules, err := rootCtx.GetModules() if err != nil { - return "", err - } - - // sort the dir names by name - names := make([]string, len(dirs)) - for i, f := range dirs { - names[i] = f.Name() + return err } - - sort.Strings(names) - - return strings.Join(names, ", "), nil + return workflow.Generate(ctx.GithubWorkflowsDir(), examples, modules) } -func getRootDir() (string, error) { +func getRootContext() (*Context, error) { current, err := os.Getwd() if err != nil { - return "", err + return nil, err } - - return filepath.Dir(current), nil + return NewContext(filepath.Dir(current)), nil } diff --git a/modulegen/main_test.go b/modulegen/main_test.go index 9e9c104d43..883054890e 100644 --- a/modulegen/main_test.go +++ b/modulegen/main_test.go @@ -475,15 +475,15 @@ func assertExampleGithubWorkflowContent(t *testing.T, example Example, exampleWo assert.Nil(t, err) data := sanitiseContent(content) - ctx := getRootContext(t) + ctx := getTestRootContext(t) modulesList, err := ctx.GetModules() assert.Nil(t, err) - assert.Equal(t, " module: ["+strings.Join(modulesList, ", ")+"]", data[88]) + assert.Equal(t, " module: ["+strings.Join(modulesList, ", ")+"]", data[90]) examplesList, err := ctx.GetExamples() assert.Nil(t, err) - assert.Equal(t, " module: ["+strings.Join(examplesList, ", ")+"]", data[104]) + assert.Equal(t, " module: ["+strings.Join(examplesList, ", ")+"]", data[106]) } // assert content go.mod @@ -548,7 +548,6 @@ func sanitiseContent(bytes []byte) []string { } func copyInitialDependabotConfig(t *testing.T, tmpCtx *Context) error { - ctx := getRootContext(t) - + ctx := getTestRootContext(t) return dependabot.CopyConfig(ctx.DependabotConfigFile(), tmpCtx.DependabotConfigFile()) } diff --git a/modulegen/mkdocs_test.go b/modulegen/mkdocs_test.go index b8314a12a0..badce9e442 100644 --- a/modulegen/mkdocs_test.go +++ b/modulegen/mkdocs_test.go @@ -56,7 +56,7 @@ func TestReadMkDocsConfig(t *testing.T) { } func TestExamples(t *testing.T) { - ctx := getRootContext(t) + ctx := getTestRootContext(t) examples, err := ctx.GetExamples() require.NoError(t, err) examplesDocs, err := ctx.GetExamplesDocs() @@ -81,13 +81,6 @@ func TestExamples(t *testing.T) { } func copyInitialMkdocsConfig(t *testing.T, tmpCtx *Context) error { - ctx := getRootContext(t) - + ctx := getTestRootContext(t) return mkdocs.CopyConfig(ctx.MkdocsConfigFile(), tmpCtx.MkdocsConfigFile()) } - -func getRootContext(t *testing.T) *Context { - current, err := os.Getwd() - require.NoError(t, err) - return NewContext(filepath.Dir(current)) -} From cb9e467a18190c6cb581db6911194e0513968d96 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Fri, 25 Aug 2023 09:19:53 +0200 Subject: [PATCH 12/26] chore: properly render mkdocs.yml (#1521) Signed-off-by: Matthieu MOREL --- .github/dependabot.yml | 3 ++- mkdocs.yml | 3 ++- modulegen/internal/dependabot/writer.go | 9 +++++++-- modulegen/internal/mkdocs/writer.go | 23 ++++++++++++++++++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1231cabf86..317b9dc0ef 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,5 @@ -# This file is autogenerated by the modulegen code generator. Please look at the generator code when updating it. +# This file is autogenerated by the 'modulegen' tool. +# Please look at the generator code when updating it. version: 2 updates: - package-ecosystem: github-actions diff --git a/mkdocs.yml b/mkdocs.yml index 99b10620e7..bdcdf7ad17 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,3 +1,4 @@ +# This file is autogenerated by the 'modulegen' tool. site_name: Testcontainers for Go site_url: https://golang.testcontainers.org plugins: @@ -31,8 +32,8 @@ markdown_extensions: permalink: true - attr_list - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:materialx.emoji.twemoji nav: - Home: index.md - Quickstart: quickstart.md diff --git a/modulegen/internal/dependabot/writer.go b/modulegen/internal/dependabot/writer.go index 611bd63783..0a134f827a 100644 --- a/modulegen/internal/dependabot/writer.go +++ b/modulegen/internal/dependabot/writer.go @@ -2,16 +2,21 @@ package dependabot import ( "os" + "path/filepath" "gopkg.in/yaml.v3" ) func writeConfig(configFile string, config *Config) error { + err := os.MkdirAll(filepath.Dir(configFile), 0o755) + if err != nil { + return err + } data, err := yaml.Marshal(config) if err != nil { return err } - header := "# This file is autogenerated by the modulegen code generator. Please look at the generator code when updating it.\n" + header := "# This file is autogenerated by the 'modulegen' tool.\n# Please look at the generator code when updating it.\n" data = append([]byte(header), data...) - return os.WriteFile(configFile, data, 0o777) + return os.WriteFile(configFile, data, 0o644) } diff --git a/modulegen/internal/mkdocs/writer.go b/modulegen/internal/mkdocs/writer.go index a625d2ab27..4d6a685af6 100644 --- a/modulegen/internal/mkdocs/writer.go +++ b/modulegen/internal/mkdocs/writer.go @@ -2,14 +2,35 @@ package mkdocs import ( "os" + "path/filepath" + "strings" "gopkg.in/yaml.v3" ) func writeConfig(configFile string, config *Config) error { + err := os.MkdirAll(filepath.Dir(configFile), 0o755) + if err != nil { + return err + } data, err := yaml.Marshal(config) if err != nil { return err } - return os.WriteFile(configFile, data, 0o777) + return os.WriteFile(configFile, overrideData(data), 0o644) +} + +// simple solution to replace the empty strings, as mapping those fields +// into the MkDocs config is not supported yet +func overrideData(data []byte) []byte { + content := "# This file is autogenerated by the 'modulegen' tool.\n" + string(data) + content = setEmoji(content, "generator", "to_svg") + content = setEmoji(content, "index", "twemoji") + return []byte(content) +} + +func setEmoji(content string, key string, value string) string { + old := "emoji_" + key + `: ""` + new := "emoji_" + key + ": !!python/name:materialx.emoji." + value + return strings.ReplaceAll(content, old, new) } From 0cff66a6ce7b824ba9546b0d12f182eadb1549e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:39:04 +0200 Subject: [PATCH 13/26] chore(deps): bump the all group in /modules/redpanda with 1 update (#1527) Bumps the all group in /modules/redpanda with 1 update: [github.com/twmb/franz-go](https://github.com/twmb/franz-go). - [Changelog](https://github.com/twmb/franz-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/twmb/franz-go/compare/v1.14.3...v1.14.4) --- updated-dependencies: - dependency-name: github.com/twmb/franz-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- modules/redpanda/go.mod | 2 +- modules/redpanda/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/redpanda/go.mod b/modules/redpanda/go.mod index c1a45d2d51..8b6cccee37 100644 --- a/modules/redpanda/go.mod +++ b/modules/redpanda/go.mod @@ -6,7 +6,7 @@ require ( github.com/docker/go-connections v0.4.0 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 - github.com/twmb/franz-go v1.14.3 + github.com/twmb/franz-go v1.14.4 github.com/twmb/franz-go/pkg/kadm v1.9.0 ) diff --git a/modules/redpanda/go.sum b/modules/redpanda/go.sum index 13efb0fac0..02a6adc7c2 100644 --- a/modules/redpanda/go.sum +++ b/modules/redpanda/go.sum @@ -94,8 +94,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/twmb/franz-go v1.14.3 h1:cq8rxAnVYU1uF3SRVn8eEaUf+AaXKWlB0Cl3Ca7JSa4= -github.com/twmb/franz-go v1.14.3/go.mod h1:nMAvTC2kHtK+ceaSHeHm4dlxC78389M/1DjpOswEgu4= +github.com/twmb/franz-go v1.14.4 h1:Bt8hyF8zOmZ/7sYD15Do1gdi3uKT9XQreBbFkMS+skA= +github.com/twmb/franz-go v1.14.4/go.mod h1:nMAvTC2kHtK+ceaSHeHm4dlxC78389M/1DjpOswEgu4= github.com/twmb/franz-go/pkg/kadm v1.9.0 h1:UgwBu0YCd6P8HLdg6ZRA4v9W6/zoI1042fOd2CvvLBE= github.com/twmb/franz-go/pkg/kadm v1.9.0/go.mod h1:eG3f+GHUndq1CUSVvjp+WdNq5zePeJi3tEHzyTkao6g= github.com/twmb/franz-go/pkg/kmsg v1.6.1 h1:tm6hXPv5antMHLasTfKv9R+X03AjHSkSkXhQo2c5ALM= From e0d3e29891b8f936a1c19524f78d0f372631b988 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:39:24 +0200 Subject: [PATCH 14/26] chore(deps): bump the all group in /examples/datastore with 2 updates (#1530) Bumps the all group in /examples/datastore with 2 updates: [cloud.google.com/go/datastore](https://github.com/googleapis/google-cloud-go) and [google.golang.org/api](https://github.com/googleapis/google-api-go-client). Updates `cloud.google.com/go/datastore` from 1.13.0 to 1.14.0 - [Release notes](https://github.com/googleapis/google-cloud-go/releases) - [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/documentai/CHANGES.md) - [Commits](https://github.com/googleapis/google-cloud-go/compare/kms/v1.13.0...kms/v1.14.0) Updates `google.golang.org/api` from 0.136.0 to 0.138.0 - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.136.0...v0.138.0) --- updated-dependencies: - dependency-name: cloud.google.com/go/datastore dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/datastore/go.mod | 10 +++++----- examples/datastore/go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/datastore/go.mod b/examples/datastore/go.mod index 7f38964de4..4910b32636 100644 --- a/examples/datastore/go.mod +++ b/examples/datastore/go.mod @@ -3,14 +3,14 @@ module github.com/testcontainers/testcontainers-go/examples/datastore go 1.20 require ( - cloud.google.com/go/datastore v1.13.0 + cloud.google.com/go/datastore v1.14.0 github.com/testcontainers/testcontainers-go v0.23.0 - google.golang.org/api v0.136.0 + google.golang.org/api v0.138.0 google.golang.org/grpc v1.57.0 ) require ( - cloud.google.com/go v0.110.6 // indirect + cloud.google.com/go v0.110.7 // indirect cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect dario.cat/mergo v1.0.0 // indirect @@ -27,7 +27,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/s2a-go v0.1.4 // indirect + github.com/google/s2a-go v0.1.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect @@ -54,7 +54,7 @@ require ( golang.org/x/tools v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect + google.golang.org/genproto v0.0.0-20230821184602-ccc8af3d0e93 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/examples/datastore/go.sum b/examples/datastore/go.sum index e039600ed7..c3ff0bc989 100644 --- a/examples/datastore/go.sum +++ b/examples/datastore/go.sum @@ -1,13 +1,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.110.6 h1:8uYAkj3YHTP/1iwReuHPxLSbdcyc+dSBbzFMrVwDR6Q= -cloud.google.com/go v0.110.6/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= +cloud.google.com/go v0.110.7 h1:rJyC7nWRg2jWGZ4wSJ5nY65GTdYJkg0cd/uXb+ACI6o= +cloud.google.com/go v0.110.7/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/datastore v1.13.0 h1:ktbC66bOQB3HJPQe8qNI1/aiQ77PMu7hD4mzE6uxe3w= -cloud.google.com/go/datastore v1.13.0/go.mod h1:KjdB88W897MRITkvWWJrg2OUtrR5XVj1EoLgSp6/N70= +cloud.google.com/go/datastore v1.14.0 h1:Mq0ApTRdLW3/dyiw+DkjTk0+iGIUvkbzaC8sfPwWTH4= +cloud.google.com/go/datastore v1.14.0/go.mod h1:GAeStMBIt9bPS7jMJA85kgkpsMkvseWWXiaHya9Jes8= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= @@ -96,8 +96,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg= +github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -263,8 +263,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.136.0 h1:e/6enzUE1s4tGPa6Q3ZYShKTtvRc+1Jq0rrafhppmOs= -google.golang.org/api v0.136.0/go.mod h1:XtJfF+V2zgUxelOn5Zs3kECtluMxneJG8ZxUTlLNTPA= +google.golang.org/api v0.138.0 h1:K/tVp05MxNVbHShRw9m7e9VJGdagNeTdMzqPH7AUqr0= +google.golang.org/api v0.138.0/go.mod h1:4xyob8CxC+0GChNBvEUAk8VBKNvYOTWM9T3v3UfRxuY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= @@ -273,8 +273,8 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g= -google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8= +google.golang.org/genproto v0.0.0-20230821184602-ccc8af3d0e93 h1:zv6ieVm8jNcN33At1+APsRISkRgynuWUxUhv6G123jY= +google.golang.org/genproto v0.0.0-20230821184602-ccc8af3d0e93/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 h1:nIgk/EEq3/YlnmVVXVnm14rC2oxgs1o0ong4sD/rd44= google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5/go.mod h1:5DZzOUPCLYL3mNkQ0ms0F3EuUNZ7py1Bqeq6sxzI7/Q= google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 h1:wukfNtZmZUurLN/atp2hiIeTKn7QJWIQdHzqmsOnAOk= From 87e42fc9dc19b7d6ed7baf905f18253e4803ab12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:39:43 +0200 Subject: [PATCH 15/26] chore(deps): bump the all group in /examples/pubsub with 1 update (#1531) Bumps the all group in /examples/pubsub with 1 update: [google.golang.org/api](https://github.com/googleapis/google-api-go-client). - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.136.0...v0.138.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/pubsub/go.mod | 4 ++-- examples/pubsub/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/pubsub/go.mod b/examples/pubsub/go.mod index bf2a83bf1a..24c18f551f 100644 --- a/examples/pubsub/go.mod +++ b/examples/pubsub/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cloud.google.com/go/pubsub v1.33.0 github.com/testcontainers/testcontainers-go v0.23.0 - google.golang.org/api v0.136.0 + google.golang.org/api v0.138.0 google.golang.org/grpc v1.57.0 ) @@ -28,7 +28,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/s2a-go v0.1.4 // indirect + github.com/google/s2a-go v0.1.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect diff --git a/examples/pubsub/go.sum b/examples/pubsub/go.sum index 84dc02ba2e..948df7df89 100644 --- a/examples/pubsub/go.sum +++ b/examples/pubsub/go.sum @@ -99,8 +99,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg= +github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -264,8 +264,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.136.0 h1:e/6enzUE1s4tGPa6Q3ZYShKTtvRc+1Jq0rrafhppmOs= -google.golang.org/api v0.136.0/go.mod h1:XtJfF+V2zgUxelOn5Zs3kECtluMxneJG8ZxUTlLNTPA= +google.golang.org/api v0.138.0 h1:K/tVp05MxNVbHShRw9m7e9VJGdagNeTdMzqPH7AUqr0= +google.golang.org/api v0.138.0/go.mod h1:4xyob8CxC+0GChNBvEUAk8VBKNvYOTWM9T3v3UfRxuY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= From f682a608515097e20e53d1103f6d1c63fae6508b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:40:07 +0200 Subject: [PATCH 16/26] chore(deps): bump the all group in /examples/toxiproxy with 2 updates (#1528) Bumps the all group in /examples/toxiproxy with 2 updates: [github.com/Shopify/toxiproxy/v2](https://github.com/Shopify/toxiproxy) and [github.com/google/uuid](https://github.com/google/uuid). Updates `github.com/Shopify/toxiproxy/v2` from 2.5.0 to 2.6.0 - [Release notes](https://github.com/Shopify/toxiproxy/releases) - [Changelog](https://github.com/Shopify/toxiproxy/blob/main/CHANGELOG.md) - [Commits](https://github.com/Shopify/toxiproxy/compare/v2.5.0...v2.6.0) Updates `github.com/google/uuid` from 1.3.0 to 1.3.1 - [Release notes](https://github.com/google/uuid/releases) - [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/Shopify/toxiproxy/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: github.com/google/uuid dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/toxiproxy/go.mod | 5 +++-- examples/toxiproxy/go.sum | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/toxiproxy/go.mod b/examples/toxiproxy/go.mod index 0afad0d44e..ef101f1e8f 100644 --- a/examples/toxiproxy/go.mod +++ b/examples/toxiproxy/go.mod @@ -3,9 +3,9 @@ module github.com/testcontainers/testcontainers-go/examples/toxiproxy go 1.20 require ( - github.com/Shopify/toxiproxy/v2 v2.5.0 + github.com/Shopify/toxiproxy/v2 v2.6.0 github.com/go-redis/redis/v8 v8.11.5 - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.3.1 github.com/testcontainers/testcontainers-go v0.23.0 ) @@ -38,6 +38,7 @@ require ( golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect golang.org/x/mod v0.9.0 // indirect golang.org/x/net v0.9.0 // indirect + golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/tools v0.7.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect diff --git a/examples/toxiproxy/go.sum b/examples/toxiproxy/go.sum index d86c89d1d5..f495b26844 100644 --- a/examples/toxiproxy/go.sum +++ b/examples/toxiproxy/go.sum @@ -7,8 +7,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= -github.com/Shopify/toxiproxy/v2 v2.5.0 h1:i4LPT+qrSlKNtQf5QliVjdP08GyAH8+BUIc9gT0eahc= -github.com/Shopify/toxiproxy/v2 v2.5.0/go.mod h1:yhM2epWtAmel9CB8r2+L+PCmhH6yH2pITaPAo7jxJl0= +github.com/Shopify/toxiproxy/v2 v2.6.0 h1:qAHKkHlGuB31epYq/nE7CJsdVVn8Nn88vBRuRhNWC9g= +github.com/Shopify/toxiproxy/v2 v2.6.0/go.mod h1:RQ4MED2Cw96l+VbfXq85MXYSwVyXoZvaZKkVznD+yrc= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -53,8 +53,8 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= @@ -124,7 +124,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From cb8eddbd5d9ced05336d8f2bcdee07a80683baac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:40:30 +0200 Subject: [PATCH 17/26] chore(deps): bump the all group in /modules/clickhouse with 1 update (#1525) Bumps the all group in /modules/clickhouse with 1 update: [github.com/ClickHouse/clickhouse-go/v2](https://github.com/ClickHouse/clickhouse-go). - [Release notes](https://github.com/ClickHouse/clickhouse-go/releases) - [Changelog](https://github.com/ClickHouse/clickhouse-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/ClickHouse/clickhouse-go/compare/v2.13.0...v2.13.3) --- updated-dependencies: - dependency-name: github.com/ClickHouse/clickhouse-go/v2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- modules/clickhouse/go.mod | 10 +++++----- modules/clickhouse/go.sum | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/clickhouse/go.mod b/modules/clickhouse/go.mod index a3bd27e6bc..1673a256b0 100644 --- a/modules/clickhouse/go.mod +++ b/modules/clickhouse/go.mod @@ -3,7 +3,7 @@ module github.com/testcontainers/testcontainers-go/modules/clickhouse go 1.20 require ( - github.com/ClickHouse/clickhouse-go/v2 v2.13.0 + github.com/ClickHouse/clickhouse-go/v2 v2.13.3 github.com/docker/go-connections v0.4.0 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 @@ -12,7 +12,7 @@ require ( require ( dario.cat/mergo v1.0.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/ClickHouse/ch-go v0.52.1 // indirect + github.com/ClickHouse/ch-go v0.58.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/andybalholm/brotli v1.0.5 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect @@ -26,8 +26,8 @@ require ( github.com/go-faster/errors v0.6.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/klauspost/compress v1.16.7 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/moby/patternmatcher v0.5.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect @@ -37,7 +37,7 @@ require ( github.com/opencontainers/image-spec v1.1.0-rc4 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/paulmach/orb v0.10.0 // indirect - github.com/pierrec/lz4/v4 v4.1.17 // indirect + github.com/pierrec/lz4/v4 v4.1.18 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/segmentio/asm v1.2.0 // indirect diff --git a/modules/clickhouse/go.sum b/modules/clickhouse/go.sum index 296a57f691..c9680dfedc 100644 --- a/modules/clickhouse/go.sum +++ b/modules/clickhouse/go.sum @@ -4,10 +4,10 @@ github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1 github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ClickHouse/ch-go v0.52.1 h1:nucdgfD1BDSHjbNaG3VNebonxJzD8fX8jbuBpfo5VY0= -github.com/ClickHouse/ch-go v0.52.1/go.mod h1:B9htMJ0hii/zrC2hljUKdnagRBuLqtRG/GrU3jqCwRk= -github.com/ClickHouse/clickhouse-go/v2 v2.13.0 h1:oP1OlTQIbQKKLnqLzyDhiyNFvN3pbOtM+e/3qdexG9k= -github.com/ClickHouse/clickhouse-go/v2 v2.13.0/go.mod h1:xyL0De2K54/n+HGsdtPuyYJq76wefafaHfGUXTDEq/0= +github.com/ClickHouse/ch-go v0.58.2 h1:jSm2szHbT9MCAB1rJ3WuCJqmGLi5UTjlNu+f530UTS0= +github.com/ClickHouse/ch-go v0.58.2/go.mod h1:Ap/0bEmiLa14gYjCiRkYGbXvbe8vwdrfTYWhsuQ99aw= +github.com/ClickHouse/clickhouse-go/v2 v2.13.3 h1:/esk41SjVLIDQs2rkOmRKXJ1FIFArIJiX6sYG0DUavE= +github.com/ClickHouse/clickhouse-go/v2 v2.13.3/go.mod h1:yoCB//XLqbyqaYvXzdbIdmMafOSomU3erh3r06NLCZU= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= @@ -56,16 +56,16 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -93,13 +93,13 @@ github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuh github.com/paulmach/orb v0.10.0 h1:guVYVqzxHE/CQ1KpfGO077TR0ATHSNjp4s6XGLn3W9s= github.com/paulmach/orb v0.10.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= -github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= -github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= +github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= 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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= @@ -154,7 +154,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From 4c0e79b9b94938a7207c70814b82ef83755c3e67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:44:31 +0200 Subject: [PATCH 18/26] chore(deps): bump the all group in /modules/redis with 1 update (#1524) Bumps the all group in /modules/redis with 1 update: [github.com/google/uuid](https://github.com/google/uuid). - [Release notes](https://github.com/google/uuid/releases) - [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/google/uuid dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- modules/redis/go.mod | 2 +- modules/redis/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/redis/go.mod b/modules/redis/go.mod index a4a824180d..bd161d6b5e 100644 --- a/modules/redis/go.mod +++ b/modules/redis/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-redis/redis/v8 v8.11.5 - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.3.1 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 diff --git a/modules/redis/go.sum b/modules/redis/go.sum index 55f68a2d06..6b1694ff54 100644 --- a/modules/redis/go.sum +++ b/modules/redis/go.sum @@ -51,8 +51,8 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= From 4a415227350ac8eab2f85ae13c830f2668e1d27d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:54:47 +0200 Subject: [PATCH 19/26] chore(deps): bump the all group in /examples/firestore with 1 update (#1523) Bumps the all group in /examples/firestore with 1 update: [google.golang.org/api](https://github.com/googleapis/google-api-go-client). - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.136.0...v0.138.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/firestore/go.mod | 4 ++-- examples/firestore/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/firestore/go.mod b/examples/firestore/go.mod index 6ac1c786ce..fc77a2f82e 100644 --- a/examples/firestore/go.mod +++ b/examples/firestore/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cloud.google.com/go/firestore v1.12.0 github.com/testcontainers/testcontainers-go v0.23.0 - google.golang.org/api v0.136.0 + google.golang.org/api v0.138.0 google.golang.org/grpc v1.57.0 ) @@ -28,7 +28,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/s2a-go v0.1.4 // indirect + github.com/google/s2a-go v0.1.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect diff --git a/examples/firestore/go.sum b/examples/firestore/go.sum index 7b9cdcd210..e559a7b397 100644 --- a/examples/firestore/go.sum +++ b/examples/firestore/go.sum @@ -98,8 +98,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg= +github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -266,8 +266,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.136.0 h1:e/6enzUE1s4tGPa6Q3ZYShKTtvRc+1Jq0rrafhppmOs= -google.golang.org/api v0.136.0/go.mod h1:XtJfF+V2zgUxelOn5Zs3kECtluMxneJG8ZxUTlLNTPA= +google.golang.org/api v0.138.0 h1:K/tVp05MxNVbHShRw9m7e9VJGdagNeTdMzqPH7AUqr0= +google.golang.org/api v0.138.0/go.mod h1:4xyob8CxC+0GChNBvEUAk8VBKNvYOTWM9T3v3UfRxuY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= From d1e188c4a6a6364aff7b6c11380a6f76eec5eb82 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:00:58 +0200 Subject: [PATCH 20/26] chore(deps): bump the all group in /examples/spanner with 2 updates (#1532) Bumps the all group in /examples/spanner with 2 updates: [cloud.google.com/go/spanner](https://github.com/googleapis/google-cloud-go) and [google.golang.org/api](https://github.com/googleapis/google-api-go-client). Updates `cloud.google.com/go/spanner` from 1.47.0 to 1.49.0 - [Release notes](https://github.com/googleapis/google-cloud-go/releases) - [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-cloud-go/compare/spanner/v1.47.0...spanner/v1.49.0) Updates `google.golang.org/api` from 0.136.0 to 0.138.0 - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.136.0...v0.138.0) --- updated-dependencies: - dependency-name: cloud.google.com/go/spanner dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/spanner/go.mod | 6 +++--- examples/spanner/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/spanner/go.mod b/examples/spanner/go.mod index a0ce3ef922..3a0460c9e3 100644 --- a/examples/spanner/go.mod +++ b/examples/spanner/go.mod @@ -3,9 +3,9 @@ module github.com/testcontainers/testcontainers-go/examples/spanner go 1.20 require ( - cloud.google.com/go/spanner v1.47.0 + cloud.google.com/go/spanner v1.49.0 github.com/testcontainers/testcontainers-go v0.23.0 - google.golang.org/api v0.136.0 + google.golang.org/api v0.138.0 google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 google.golang.org/grpc v1.57.0 ) @@ -36,7 +36,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/s2a-go v0.1.4 // indirect + github.com/google/s2a-go v0.1.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect diff --git a/examples/spanner/go.sum b/examples/spanner/go.sum index 2280f42655..1ea5f7034d 100644 --- a/examples/spanner/go.sum +++ b/examples/spanner/go.sum @@ -10,8 +10,8 @@ cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= cloud.google.com/go/longrunning v0.5.1 h1:Fr7TXftcqTudoyRJa113hyaqlGdiBQkp0Gq7tErFDWI= cloud.google.com/go/longrunning v0.5.1/go.mod h1:spvimkwdz6SPWKEt/XBij79E9fiTkHSQl/fRUUQJYJc= -cloud.google.com/go/spanner v1.47.0 h1:aqiMP8dhsEXgn9K5EZBWxPG7dxIiyM2VaikqeU4iteg= -cloud.google.com/go/spanner v1.47.0/go.mod h1:IXsJwVW2j4UKs0eYDqodab6HgGuA1bViSqW4uH9lfUI= +cloud.google.com/go/spanner v1.49.0 h1:+HY8C4uztU7XyLz3xMi/LCXdetLEOExhvRFJu2NiVXM= +cloud.google.com/go/spanner v1.49.0/go.mod h1:eGj9mQGK8+hkgSVbHNQ06pQ4oS+cyc4tXXd6Dif1KoM= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= @@ -112,8 +112,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg= +github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -279,8 +279,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.136.0 h1:e/6enzUE1s4tGPa6Q3ZYShKTtvRc+1Jq0rrafhppmOs= -google.golang.org/api v0.136.0/go.mod h1:XtJfF+V2zgUxelOn5Zs3kECtluMxneJG8ZxUTlLNTPA= +google.golang.org/api v0.138.0 h1:K/tVp05MxNVbHShRw9m7e9VJGdagNeTdMzqPH7AUqr0= +google.golang.org/api v0.138.0/go.mod h1:4xyob8CxC+0GChNBvEUAk8VBKNvYOTWM9T3v3UfRxuY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= From 1c61a42054b8b42e95a2fa7ef20c8426328bd7d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:03:11 +0200 Subject: [PATCH 21/26] chore(deps): bump the all group in /modules/k3s with 2 updates (#1526) Bumps the all group in /modules/k3s with 2 updates: [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [k8s.io/client-go](https://github.com/kubernetes/client-go). Updates `k8s.io/apimachinery` from 0.27.4 to 0.28.1 - [Commits](https://github.com/kubernetes/apimachinery/compare/v0.27.4...v0.28.1) Updates `k8s.io/client-go` from 0.27.4 to 0.28.1 - [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes/client-go/compare/v0.27.4...v0.28.1) --- updated-dependencies: - dependency-name: k8s.io/apimachinery dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: k8s.io/client-go dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- modules/k3s/go.mod | 32 +++++------ modules/k3s/go.sum | 136 ++++++++++++--------------------------------- 2 files changed, 53 insertions(+), 115 deletions(-) diff --git a/modules/k3s/go.mod b/modules/k3s/go.mod index b0dcf32784..67d3dded6e 100644 --- a/modules/k3s/go.mod +++ b/modules/k3s/go.mod @@ -8,8 +8,8 @@ require ( github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/apimachinery v0.27.4 - k8s.io/client-go v0.27.4 + k8s.io/apimachinery v0.28.1 + k8s.io/client-go v0.28.1 ) require ( @@ -23,13 +23,13 @@ require ( github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.1 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/gnostic v0.5.7-v3refs // indirect + github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.3.0 // indirect @@ -54,24 +54,24 @@ require ( github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect - golang.org/x/mod v0.9.0 // indirect - golang.org/x/net v0.9.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.13.0 // indirect + golang.org/x/oauth2 v0.8.0 // indirect golang.org/x/sys v0.11.0 // indirect - golang.org/x/term v0.7.0 // indirect - golang.org/x/text v0.9.0 // indirect - golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect - golang.org/x/tools v0.7.0 // indirect + golang.org/x/term v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.8.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect google.golang.org/grpc v1.57.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/api v0.27.4 // indirect - k8s.io/klog/v2 v2.90.1 // indirect - k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 // indirect + k8s.io/api v0.28.1 // indirect + k8s.io/klog/v2 v2.100.1 // indirect + k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect + k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/modules/k3s/go.sum b/modules/k3s/go.sum index 951b963777..456cf736d9 100644 --- a/modules/k3s/go.sum +++ b/modules/k3s/go.sum @@ -1,4 +1,3 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic= @@ -10,10 +9,8 @@ github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5 github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/containerd v1.7.3 h1:cKwYKkP1eTj54bP3wCdXXBymmKRQMrWjkLSWZZJDa8o= github.com/containerd/containerd v1.7.3/go.mod h1:32FOM4/O0RkNg7AjQj3hDzN9cUGtu+HMvaKUNiqCZB8= @@ -37,47 +34,29 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTrLC1F86HID8= -github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= -github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= @@ -98,9 +77,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 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= @@ -126,8 +104,8 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= -github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE= +github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= @@ -140,8 +118,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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -150,13 +127,11 @@ github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0 github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -172,38 +147,26 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= +golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -220,59 +183,37 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= -golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= +golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 h1:0nDDozoAU19Qb2HwhXadU8OcsiO/09cnTqhUtq2MEOM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= 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/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= @@ -282,25 +223,22 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.27.4 h1:0pCo/AN9hONazBKlNUdhQymmnfLRbSZjd5H5H3f0bSs= -k8s.io/api v0.27.4/go.mod h1:O3smaaX15NfxjzILfiln1D8Z3+gEYpjEpiNA/1EVK1Y= -k8s.io/apimachinery v0.27.4 h1:CdxflD4AF61yewuid0fLl6bM4a3q04jWel0IlP+aYjs= -k8s.io/apimachinery v0.27.4/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= -k8s.io/client-go v0.27.4 h1:vj2YTtSJ6J4KxaC88P4pMPEQECWMY8gqPqsTgUKzvjk= -k8s.io/client-go v0.27.4/go.mod h1:ragcly7lUlN0SRPk5/ZkGnDjPknzb37TICq07WhI6Xc= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= -k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= -k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= -k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/api v0.28.1 h1:i+0O8k2NPBCPYaMB+uCkseEbawEt/eFaiRqUx8aB108= +k8s.io/api v0.28.1/go.mod h1:uBYwID+66wiL28Kn2tBjBYQdEU0Xk0z5qF8bIBqk/Dg= +k8s.io/apimachinery v0.28.1 h1:EJD40og3GizBSV3mkIoXQBsws32okPOy+MkRyzh6nPY= +k8s.io/apimachinery v0.28.1/go.mod h1:X0xh/chESs2hP9koe+SdIAcXWcQ+RM5hy0ZynB+yEvw= +k8s.io/client-go v0.28.1 h1:pRhMzB8HyLfVwpngWKE8hDcXRqifh1ga2Z/PU9SXVK8= +k8s.io/client-go v0.28.1/go.mod h1:pEZA3FqOsVkCc07pFVzK076R+P/eXqsgx5zuuRWukNE= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= +k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= +k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= +k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= From d1444d1697be5665e16e2b2eef62fe263c83cd0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:28:13 +0200 Subject: [PATCH 22/26] chore(deps): bump the all group in /modules/localstack with 4 updates (#1535) Bumps the all group in /modules/localstack with 4 updates: [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go), [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2), [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) and [github.com/aws/aws-sdk-go-v2/service/s3](https://github.com/aws/aws-sdk-go-v2). Updates `github.com/aws/aws-sdk-go` from 1.44.322 to 1.44.331 - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.322...v1.44.331) Updates `github.com/aws/aws-sdk-go-v2` from 1.20.1 to 1.21.0 - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.20.1...v1.21.0) Updates `github.com/aws/aws-sdk-go-v2/config` from 1.18.33 to 1.18.37 - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.33...config/v1.18.37) Updates `github.com/aws/aws-sdk-go-v2/service/s3` from 1.38.2 to 1.38.5 - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/s3/v1.38.2...service/s3/v1.38.5) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all - dependency-name: github.com/aws/aws-sdk-go-v2/service/s3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- modules/localstack/go.mod | 38 ++++++++++---------- modules/localstack/go.sum | 76 +++++++++++++++++++-------------------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/modules/localstack/go.mod b/modules/localstack/go.mod index e8029bbc17..77aa576afa 100644 --- a/modules/localstack/go.mod +++ b/modules/localstack/go.mod @@ -3,11 +3,11 @@ module github.com/testcontainers/testcontainers-go/modules/localstack go 1.20 require ( - github.com/aws/aws-sdk-go v1.44.322 - github.com/aws/aws-sdk-go-v2 v1.20.1 - github.com/aws/aws-sdk-go-v2/config v1.18.33 - github.com/aws/aws-sdk-go-v2/credentials v1.13.32 - github.com/aws/aws-sdk-go-v2/service/s3 v1.38.2 + github.com/aws/aws-sdk-go v1.44.331 + github.com/aws/aws-sdk-go-v2 v1.21.0 + github.com/aws/aws-sdk-go-v2/config v1.18.37 + github.com/aws/aws-sdk-go-v2/credentials v1.13.35 + github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 github.com/docker/go-connections v0.4.0 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 @@ -18,20 +18,20 @@ require ( dario.cat/mergo v1.0.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.12 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.13 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.33 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.1 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.13.2 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.21.2 // indirect - github.com/aws/smithy-go v1.14.1 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect + github.com/aws/smithy-go v1.14.2 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/containerd/containerd v1.7.3 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect diff --git a/modules/localstack/go.sum b/modules/localstack/go.sum index 00f2622de9..9331496db1 100644 --- a/modules/localstack/go.sum +++ b/modules/localstack/go.sum @@ -7,44 +7,44 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= -github.com/aws/aws-sdk-go v1.44.322 h1:7JfwifGRGQMHd99PvfXqxBaZsjuRaOF6e3X9zRx2uYo= -github.com/aws/aws-sdk-go v1.44.322/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg= -github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.12 h1:lN6L3LrYHeZ6xCxaIYtoWCx4GMLk4nRknsh29OMSqHY= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.12/go.mod h1:TDCkEAkMTXxTs0oLBGBKpBZbk3NLh8EvAfF0Q3x8/0c= -github.com/aws/aws-sdk-go-v2/config v1.18.33 h1:JKcw5SFxFW/rpM4mOPjv0VQ11E2kxW13F3exWOy7VZU= -github.com/aws/aws-sdk-go-v2/config v1.18.33/go.mod h1:hXO/l9pgY3K5oZJldamP0pbZHdPqqk+4/maa7DSD3cA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.32 h1:lIH1eKPcCY1ylR4B6PkBGRWMHO3aVenOKJHWiS4/G2w= -github.com/aws/aws-sdk-go-v2/credentials v1.13.32/go.mod h1:lL8U3v/Y79YRG69WlAho0OHIKUXCyFvSXaIvfo81sls= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8 h1:DK/9C+UN/X+1+Wm8pqaDksQr2tSLzq+8X1/rI/ZxKEQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8/go.mod h1:ce7BgLQfYr5hQFdy67oX2svto3ufGtm6oBvmsHScI1Q= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38 h1:c8ed/T9T2K5I+h/JzmF5tpI46+OODQ74dzmdo+QnaMg= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38/go.mod h1:qggunOChCMu9ZF/UkAfhTz25+U2rLVb3ya0Ua6TTfCA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32 h1:hNeAAymUY5gu11WrrmFb3CVIp9Dar9hbo44yzzcQpzA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32/go.mod h1:0ZXSqrty4FtQ7p8TEuRde/SZm9X05KT18LAUlR40Ln0= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39 h1:fc0ukRAiP1syoSGZYu+DaE+FulSYhTiJ8WpVu5jElU4= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39/go.mod h1:WLAW8PT7+JhjZfLSWe7WEJaJu0GNo0cKc2Zyo003RBs= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.1 h1:vUh7dBFNS3oFCtVv6CiYKh5hP9ls8+kIpKLeFruIBLk= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.1/go.mod h1:sFMeinkhj/SZKQM8BxtvNtSPjJEo0Xrz+w3g2e4FSKI= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.13 h1:iV/W5OMBys+66OeXJi/7xIRrKZNsu0ylsLGu+6nbmQE= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.13/go.mod h1:ReJb6xYmtGyu9KoFtRreWegbN9dZqvZIIv4vWnhcsyI= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.33 h1:QviNkc+vGSuEHx8P+pVNKOdWLXBPIwMFv7p0fphgE4U= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.33/go.mod h1:fABTUmOrAgAalG2i9WJpjBvlnk7UK8YmnYaxN+Q2CwE= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32 h1:dGAseBFEYxth10V23b5e2mAS+tX7oVbfYHD6dnDdAsg= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32/go.mod h1:4jwAWKEkCR0anWk5+1RbfSg1R5Gzld7NLiuaq5bTR/Y= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.1 h1:PT6PBCycRwhpEW5hJnRiceCeoWJ+r3bdgXtV+VKG7Pk= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.1/go.mod h1:TqoxCLwT2nrxrBGA+z7t6OWM7LBkgRckK3gOjYE+7JA= -github.com/aws/aws-sdk-go-v2/service/s3 v1.38.2 h1:v346f1h8sUBKXnEbrv43L37MTBlFHyKXQPIZHNAaghA= -github.com/aws/aws-sdk-go-v2/service/s3 v1.38.2/go.mod h1:cwCATiyNrXK9P2FsWdZ89g9mpsYv2rhk0UA/KByl5fY= -github.com/aws/aws-sdk-go-v2/service/sso v1.13.2 h1:A2RlEMo4SJSwbNoUUgkxTAEMduAy/8wG3eB2b2lP4gY= -github.com/aws/aws-sdk-go-v2/service/sso v1.13.2/go.mod h1:ju+nNXUunfIFamXUIZQiICjnO/TPlOmWcYhZcSy7xaE= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2 h1:OJELEgyaT2kmaBGZ+myyZbTTLobfe3ox3FSh5eYK9Qs= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2/go.mod h1:ubDBBaDFs1GHijSOTi8ljppML15GLG0HxhILtbjNNYQ= -github.com/aws/aws-sdk-go-v2/service/sts v1.21.2 h1:ympg1+Lnq33XLhcK/xTG4yZHPs1Oyxu+6DEWbl7qOzA= -github.com/aws/aws-sdk-go-v2/service/sts v1.21.2/go.mod h1:FQ/DQcOfESELfJi5ED+IPPAjI5xC6nxtSolVVB773jM= -github.com/aws/smithy-go v1.14.1 h1:EFKMUmH/iHMqLiwoEDx2rRjRQpI1YCn5jTysoaDujFs= -github.com/aws/smithy-go v1.14.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/aws-sdk-go v1.44.331 h1:hEwdOTv6973uegCUY2EY8jyyq0OUg9INc0HOzcu2bjw= +github.com/aws/aws-sdk-go v1.44.331/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 h1:OPLEkmhXf6xFPiz0bLeDArZIDx1NNS4oJyG4nv3Gct0= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13/go.mod h1:gpAbvyDGQFozTEmlTFO8XcQKHzubdq0LzRyJpG6MiXM= +github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI= +github.com/aws/aws-sdk-go-v2/config v1.18.37/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 h1:6lJvvkQ9HmbHZ4h/IEwclwv2mrTW8Uq1SOB/kXy0mfw= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4/go.mod h1:1PrKYwxTM+zjpw9Y41KFtoJCQrJ34Z47Y4VgVbfndjo= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 h1:m0QTSI6pZYJTk5WSKx3fm5cNW/DCicVzULBgU/6IyD0= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14/go.mod h1:dDilntgHy9WnHXsh7dDtUPgHKEfTJIBUTHM8OWm0f/0= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 h1:eev2yZX7esGRjqRbnVk1UxMLw4CyVZDpZXRCcy75oQk= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36/go.mod h1:lGnOkH9NJATw0XEPcAknFBj3zzNTEGRHtSw+CwC1YTg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4 h1:v0jkRigbSD6uOdwcaUQmgEwG1BkPfAPDqaeNt/29ghg= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4/go.mod h1:LhTyt8J04LL+9cIt7pYJ5lbS/U98ZmXovLOR/4LUsk8= +github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 h1:A42xdtStObqy7NGvzZKpnyNXvoOmm+FENobZ0/ssHWk= +github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5/go.mod h1:rDGMZA7f4pbmTtPOk5v5UM2lmX6UAbRnMDJeDvnH7AM= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= From 77e86e54bc575fd732b50c3055bcf521390d35f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:28:25 +0200 Subject: [PATCH 23/26] chore(deps): bump the all group in /examples/bigtable with 1 update (#1534) Bumps the all group in /examples/bigtable with 1 update: [google.golang.org/api](https://github.com/googleapis/google-api-go-client). - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.136.0...v0.138.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bigtable/go.mod | 4 ++-- examples/bigtable/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/bigtable/go.mod b/examples/bigtable/go.mod index c795f7ed57..10488a596d 100644 --- a/examples/bigtable/go.mod +++ b/examples/bigtable/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cloud.google.com/go/bigtable v1.19.0 github.com/testcontainers/testcontainers-go v0.23.0 - google.golang.org/api v0.136.0 + google.golang.org/api v0.138.0 google.golang.org/grpc v1.57.0 ) @@ -35,7 +35,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/s2a-go v0.1.4 // indirect + github.com/google/s2a-go v0.1.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect diff --git a/examples/bigtable/go.sum b/examples/bigtable/go.sum index 89bc4ea592..723b24d6f7 100644 --- a/examples/bigtable/go.sum +++ b/examples/bigtable/go.sum @@ -113,8 +113,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= -github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.5 h1:8IYp3w9nysqv3JH+NJgXJzGbDHzLOTj43BmSkp+O7qg= +github.com/google/s2a-go v0.1.5/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -280,8 +280,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.136.0 h1:e/6enzUE1s4tGPa6Q3ZYShKTtvRc+1Jq0rrafhppmOs= -google.golang.org/api v0.136.0/go.mod h1:XtJfF+V2zgUxelOn5Zs3kECtluMxneJG8ZxUTlLNTPA= +google.golang.org/api v0.138.0 h1:K/tVp05MxNVbHShRw9m7e9VJGdagNeTdMzqPH7AUqr0= +google.golang.org/api v0.138.0/go.mod h1:4xyob8CxC+0GChNBvEUAk8VBKNvYOTWM9T3v3UfRxuY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= From 3e17ce75563c50441389b38a67ec8c9c90c4cff8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:28:37 +0200 Subject: [PATCH 24/26] chore(deps): bump the all group in /examples/cockroachdb with 1 update (#1522) Bumps the all group in /examples/cockroachdb with 1 update: [github.com/google/uuid](https://github.com/google/uuid). - [Release notes](https://github.com/google/uuid/releases) - [Changelog](https://github.com/google/uuid/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/google/uuid dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/cockroachdb/go.mod | 2 +- examples/cockroachdb/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/cockroachdb/go.mod b/examples/cockroachdb/go.mod index 8efc2494bf..b57d481c0e 100644 --- a/examples/cockroachdb/go.mod +++ b/examples/cockroachdb/go.mod @@ -3,7 +3,7 @@ module github.com/testcontainers/testcontainers-go/examples/cockroachdb go 1.20 require ( - github.com/google/uuid v1.3.0 + github.com/google/uuid v1.3.1 github.com/jackc/pgx/v4 v4.18.1 github.com/stretchr/testify v1.8.4 github.com/testcontainers/testcontainers-go v0.23.0 diff --git a/examples/cockroachdb/go.sum b/examples/cockroachdb/go.sum index 8f795bc7f6..9912d7d114 100644 --- a/examples/cockroachdb/go.sum +++ b/examples/cockroachdb/go.sum @@ -58,8 +58,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= From 1dddc0ef39a93c26884354dd19e6a23f4ceefe29 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 26 Aug 2023 12:09:34 +0200 Subject: [PATCH 25/26] chore: fix workflow (#1538) Trigger tests only on push on main branch will avoid doubling the number of tests for dependabot updates Signed-off-by: Matthieu MOREL --- .github/workflows/ci.yml | 14 ++++++++------ modulegen/_template/ci.yml.tmpl | 14 ++++++++------ modulegen/main_test.go | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a93ebd6f26..35b3de5ae3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,15 +4,17 @@ name: Main pipeline on: push: + branches: + - main paths-ignore: - - 'mkdocs.yml' - - 'docs/**' - - 'README.md' + - 'mkdocs.yml' + - 'docs/**' + - 'README.md' pull_request: paths-ignore: - - 'mkdocs.yml' - - 'docs/**' - - 'README.md' + - 'mkdocs.yml' + - 'docs/**' + - 'README.md' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} diff --git a/modulegen/_template/ci.yml.tmpl b/modulegen/_template/ci.yml.tmpl index 2038cdb0e4..8851177a99 100644 --- a/modulegen/_template/ci.yml.tmpl +++ b/modulegen/_template/ci.yml.tmpl @@ -4,15 +4,17 @@ name: Main pipeline on: push: + branches: + - main paths-ignore: - - 'mkdocs.yml' - - 'docs/**' - - 'README.md' + - 'mkdocs.yml' + - 'docs/**' + - 'README.md' pull_request: paths-ignore: - - 'mkdocs.yml' - - 'docs/**' - - 'README.md' + - 'mkdocs.yml' + - 'docs/**' + - 'README.md' concurrency: group: {{ "${{ github.workflow }}-${{ github.head_ref || github.sha }}" }} diff --git a/modulegen/main_test.go b/modulegen/main_test.go index 883054890e..123dab85de 100644 --- a/modulegen/main_test.go +++ b/modulegen/main_test.go @@ -479,11 +479,11 @@ func assertExampleGithubWorkflowContent(t *testing.T, example Example, exampleWo modulesList, err := ctx.GetModules() assert.Nil(t, err) - assert.Equal(t, " module: ["+strings.Join(modulesList, ", ")+"]", data[90]) + assert.Equal(t, " module: ["+strings.Join(modulesList, ", ")+"]", data[92]) examplesList, err := ctx.GetExamples() assert.Nil(t, err) - assert.Equal(t, " module: ["+strings.Join(examplesList, ", ")+"]", data[106]) + assert.Equal(t, " module: ["+strings.Join(examplesList, ", ")+"]", data[108]) } // assert content go.mod From 04a60838bb7a673e64b97063ae7510fdc3c1e063 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Mon, 28 Aug 2023 14:07:13 +0200 Subject: [PATCH 26/26] modulegen: create internal/make (#1537) Signed-off-by: Matthieu MOREL --- modulegen/_template/Makefile.tmpl | 4 +- modulegen/dependabot.go | 11 +++ modulegen/internal/make/main.go | 17 +++++ modulegen/main.go | 121 ++---------------------------- modulegen/make.go | 14 ++++ modulegen/mkdocs.go | 12 +++ modulegen/types.go | 86 +++++++++++++++++++++ modulegen/workflow.go | 22 ++++++ 8 files changed, 171 insertions(+), 116 deletions(-) create mode 100644 modulegen/dependabot.go create mode 100644 modulegen/internal/make/main.go create mode 100644 modulegen/make.go create mode 100644 modulegen/mkdocs.go create mode 100644 modulegen/types.go create mode 100644 modulegen/workflow.go diff --git a/modulegen/_template/Makefile.tmpl b/modulegen/_template/Makefile.tmpl index 1435c0a6e5..428c72e006 100644 --- a/modulegen/_template/Makefile.tmpl +++ b/modulegen/_template/Makefile.tmpl @@ -1,5 +1,5 @@ -{{ $lower := ToLower }}include ../../commons-test.mk +include ../../commons-test.mk .PHONY: test test: - $(MAKE) test-{{ $lower }} + $(MAKE) test-{{ . }} diff --git a/modulegen/dependabot.go b/modulegen/dependabot.go new file mode 100644 index 0000000000..4c05b90a17 --- /dev/null +++ b/modulegen/dependabot.go @@ -0,0 +1,11 @@ +package main + +import ( + "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" +) + +// update examples in dependabot +func generateDependabotUpdates(ctx *Context, example Example) error { + directory := "/" + example.ParentDir() + "/" + example.Lower() + return dependabot.UpdateConfig(ctx.DependabotConfigFile(), directory, "gomod") +} diff --git a/modulegen/internal/make/main.go b/modulegen/internal/make/main.go new file mode 100644 index 0000000000..4f31e07f24 --- /dev/null +++ b/modulegen/internal/make/main.go @@ -0,0 +1,17 @@ +package make + +import ( + "path/filepath" + "text/template" + + internal_template "github.com/testcontainers/testcontainers-go/modulegen/internal/template" +) + +func Generate(exampleDir string, exampleName string) error { + name := "Makefile.tmpl" + t, err := template.New(name).ParseFiles(filepath.Join("_template", name)) + if err != nil { + return err + } + return internal_template.Generate(t, filepath.Join(exampleDir, "Makefile"), name, exampleName) +} diff --git a/modulegen/main.go b/modulegen/main.go index 65eb2762ad..ab22c51efa 100644 --- a/modulegen/main.go +++ b/modulegen/main.go @@ -6,18 +6,10 @@ import ( "html/template" "os" "path/filepath" - "regexp" "strings" - "unicode" - "unicode/utf8" - "golang.org/x/text/cases" - "golang.org/x/text/language" - - "github.com/testcontainers/testcontainers-go/modulegen/internal/dependabot" "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" "github.com/testcontainers/testcontainers-go/modulegen/internal/tools" - "github.com/testcontainers/testcontainers-go/modulegen/internal/workflow" ) var ( @@ -27,9 +19,7 @@ var ( imageVar string ) -var templates = []string{ - "docs_example.md", "example_test.go", "example.go", "go.mod", "Makefile", -} +var templates = []string{"docs_example.md", "example_test.go", "example.go", "go.mod"} func init() { flag.StringVar(&nameVar, "name", "", "Name of the example. Only alphabetical characters are allowed.") @@ -38,80 +28,6 @@ func init() { flag.BoolVar(&asModuleVar, "as-module", false, "If set, the example will be generated as a Go module, under the modules directory. Otherwise, it will be generated as a subdirectory of the examples directory.") } -type Example struct { - Image string // fully qualified name of the Docker image - IsModule bool // if true, the example will be generated as a Go module - Name string - TitleName string // title of the name: e.g. "mongodb" -> "MongoDB" - TCVersion string // Testcontainers for Go version -} - -// ContainerName returns the name of the container, which is the lower-cased title of the example -// If the title is set, it will be used instead of the name -func (e *Example) ContainerName() string { - name := e.Lower() - - if e.IsModule { - name = e.Title() - } else { - if e.TitleName != "" { - r, n := utf8.DecodeRuneInString(e.TitleName) - name = string(unicode.ToLower(r)) + e.TitleName[n:] - } - } - - return name + "Container" -} - -// Entrypoint returns the name of the entrypoint function, which is the lower-cased title of the example -// If the example is a module, the entrypoint will be "RunContainer" -func (e *Example) Entrypoint() string { - if e.IsModule { - return "RunContainer" - } - - return "runContainer" -} - -func (e *Example) Lower() string { - return strings.ToLower(e.Name) -} - -func (e *Example) ParentDir() string { - if e.IsModule { - return "modules" - } - - return "examples" -} - -func (e *Example) Title() string { - if e.TitleName != "" { - return e.TitleName - } - - return cases.Title(language.Und, cases.NoLower).String(e.Lower()) -} - -func (e *Example) Type() string { - if e.IsModule { - return "module" - } - return "example" -} - -func (e *Example) Validate() error { - if !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]*$`).MatchString(e.Name) { - return fmt.Errorf("invalid name: %s. Only alphanumerical characters are allowed (leading character must be a letter)", e.Name) - } - - if !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]*$`).MatchString(e.TitleName) { - return fmt.Errorf("invalid title: %s. Only alphanumerical characters are allowed (leading character must be a letter)", e.TitleName) - } - - return nil -} - func main() { required := []string{"name", "image"} flag.Parse() @@ -237,6 +153,12 @@ func generate(example Example, ctx *Context) error { return err } } + // creates Makefile for example + err = generateMakefile(ctx, example) + if err != nil { + return err + } + // update github ci workflow err = generateWorkFlow(ctx) if err != nil { @@ -255,35 +177,6 @@ func generate(example Example, ctx *Context) error { return nil } -func generateDependabotUpdates(ctx *Context, example Example) error { - // update examples in dependabot - directory := "/" + example.ParentDir() + "/" + example.Lower() - return dependabot.UpdateConfig(ctx.DependabotConfigFile(), directory, "gomod") -} - -func generateMkdocs(ctx *Context, example Example) error { - // update examples in mkdocs - exampleMd := example.ParentDir() + "/" + example.Lower() + ".md" - indexMd := example.ParentDir() + "/index.md" - return mkdocs.UpdateConfig(ctx.MkdocsConfigFile(), example.IsModule, exampleMd, indexMd) -} - -func generateWorkFlow(ctx *Context) error { - rootCtx, err := getRootContext() - if err != nil { - return err - } - examples, err := rootCtx.GetExamples() - if err != nil { - return err - } - modules, err := rootCtx.GetModules() - if err != nil { - return err - } - return workflow.Generate(ctx.GithubWorkflowsDir(), examples, modules) -} - func getRootContext() (*Context, error) { current, err := os.Getwd() if err != nil { diff --git a/modulegen/make.go b/modulegen/make.go new file mode 100644 index 0000000000..49bf4d8533 --- /dev/null +++ b/modulegen/make.go @@ -0,0 +1,14 @@ +package main + +import ( + "path/filepath" + + "github.com/testcontainers/testcontainers-go/modulegen/internal/make" +) + +// creates Makefile for example +func generateMakefile(ctx *Context, example Example) error { + exampleDir := filepath.Join(ctx.RootDir, example.ParentDir(), example.Lower()) + exampleName := example.Lower() + return make.Generate(exampleDir, exampleName) +} diff --git a/modulegen/mkdocs.go b/modulegen/mkdocs.go new file mode 100644 index 0000000000..f96e983b0c --- /dev/null +++ b/modulegen/mkdocs.go @@ -0,0 +1,12 @@ +package main + +import ( + "github.com/testcontainers/testcontainers-go/modulegen/internal/mkdocs" +) + +// update examples in mkdocs +func generateMkdocs(ctx *Context, example Example) error { + exampleMd := example.ParentDir() + "/" + example.Lower() + ".md" + indexMd := example.ParentDir() + "/index.md" + return mkdocs.UpdateConfig(ctx.MkdocsConfigFile(), example.IsModule, exampleMd, indexMd) +} diff --git a/modulegen/types.go b/modulegen/types.go new file mode 100644 index 0000000000..d2665c7b5f --- /dev/null +++ b/modulegen/types.go @@ -0,0 +1,86 @@ +package main + +import ( + "fmt" + "regexp" + "strings" + "unicode" + "unicode/utf8" + + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +type Example struct { + Image string // fully qualified name of the Docker image + IsModule bool // if true, the example will be generated as a Go module + Name string + TitleName string // title of the name: e.g. "mongodb" -> "MongoDB" + TCVersion string // Testcontainers for Go version +} + +// ContainerName returns the name of the container, which is the lower-cased title of the example +// If the title is set, it will be used instead of the name +func (e *Example) ContainerName() string { + name := e.Lower() + + if e.IsModule { + name = e.Title() + } else { + if e.TitleName != "" { + r, n := utf8.DecodeRuneInString(e.TitleName) + name = string(unicode.ToLower(r)) + e.TitleName[n:] + } + } + + return name + "Container" +} + +// Entrypoint returns the name of the entrypoint function, which is the lower-cased title of the example +// If the example is a module, the entrypoint will be "RunContainer" +func (e *Example) Entrypoint() string { + if e.IsModule { + return "RunContainer" + } + + return "runContainer" +} + +func (e *Example) Lower() string { + return strings.ToLower(e.Name) +} + +func (e *Example) ParentDir() string { + if e.IsModule { + return "modules" + } + + return "examples" +} + +func (e *Example) Title() string { + if e.TitleName != "" { + return e.TitleName + } + + return cases.Title(language.Und, cases.NoLower).String(e.Lower()) +} + +func (e *Example) Type() string { + if e.IsModule { + return "module" + } + return "example" +} + +func (e *Example) Validate() error { + if !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]*$`).MatchString(e.Name) { + return fmt.Errorf("invalid name: %s. Only alphanumerical characters are allowed (leading character must be a letter)", e.Name) + } + + if !regexp.MustCompile(`^[A-Za-z][A-Za-z0-9]*$`).MatchString(e.TitleName) { + return fmt.Errorf("invalid title: %s. Only alphanumerical characters are allowed (leading character must be a letter)", e.TitleName) + } + + return nil +} diff --git a/modulegen/workflow.go b/modulegen/workflow.go new file mode 100644 index 0000000000..a0d4f0264e --- /dev/null +++ b/modulegen/workflow.go @@ -0,0 +1,22 @@ +package main + +import ( + "github.com/testcontainers/testcontainers-go/modulegen/internal/workflow" +) + +// update github ci workflow +func generateWorkFlow(ctx *Context) error { + rootCtx, err := getRootContext() + if err != nil { + return err + } + examples, err := rootCtx.GetExamples() + if err != nil { + return err + } + modules, err := rootCtx.GetModules() + if err != nil { + return err + } + return workflow.Generate(ctx.GithubWorkflowsDir(), examples, modules) +}