Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: always generate the examples including a explicit image #1611

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

mdelapenya
Copy link
Collaborator

What does this PR do?

This PR updates the module templates to always include the default image for the new module. It applies to:

  • examples_test.go
  • module_test.go

Therefore, the all RunContainer calls in the examples will include the testcontainers.WithImage("foo:bar") functional option.

Why is it important?

Users copy&pasting our code examples will receive a code snippet including the image, which is important for awareness of what version of the technology they are using.

@mdelapenya mdelapenya requested a review from a team as a code owner September 12, 2023 02:47
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Sep 12, 2023
@mdelapenya mdelapenya self-assigned this Sep 12, 2023
@netlify
Copy link

netlify bot commented Sep 12, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 7b4fc17
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/64ffd14fa9e3d80008e8a7cd
😎 Deploy Preview https://deploy-preview-1611--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdelapenya
Copy link
Collaborator Author

Specially for the interest of @eddumelendez 😉

@mdelapenya mdelapenya merged commit b25ee5a into testcontainers:main Sep 12, 2023
99 checks passed
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 12, 2023
* main:
  chore: always generate the examples including a explicit image (testcontainers#1611)
  chore: support linting all modules locally (testcontainers#1609)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 12, 2023
* main:
  chore: always generate the examples including a explicit image (testcontainers#1611)
mdelapenya added a commit that referenced this pull request Sep 12, 2023
…containerd-1.7.5

* main:
  chore: always generate the examples including a explicit image (#1611)
  chore: support linting all modules locally (#1609)
  ci(sonarcloud): run only when not root-less (#1608)
  remove extra equal in sonar.organization (#1607)
  chore(ci): enable code coverage on Sonarcloud (#1518)
  docs: use Go testable examples in modules (#1603)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 12, 2023
* main:
  chore: always generate the examples including a explicit image (testcontainers#1611)
  chore: support linting all modules locally (testcontainers#1609)
  ci(sonarcloud): run only when not root-less (testcontainers#1608)
  remove extra equal in sonar.organization (testcontainers#1607)
  chore(ci): enable code coverage on Sonarcloud (testcontainers#1518)
  docs: use Go testable examples in modules (testcontainers#1603)
  ci(lint): enable errorlint linter (testcontainers#1604)
  ci(lint): enable gocritic linter (testcontainers#1605)
  chore(deps): bump github.com/hashicorp/vault-client-go in /modules/vault (testcontainers#1566)
  ci(security): setup codeql scan  (testcontainers#1606)
  chore(deps): bump github.com/cyphar/filepath-securejoin (testcontainers#1601)
  chore: generate Go examples for new modules (testcontainers#1600)
  chore: generate Go examples for new modules (testcontainers#1600)

import (
"context"
"fmt"

"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/{{ $lower }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mdelapenya,
This is breaking go mod tidy when applied on an example.

go run . new example --name questdb --image "questdb/questdb:latest" --title QuestDB
Error: >> error synchronizing the dependencies: exit status 1

When you then try in examples/questdb

go mod tidy
go: finding module for package github.com/testcontainers/testcontainers-go/modules/questdb
github.com/testcontainers/testcontainers-go/examples/questdb tested by
        github.com/testcontainers/testcontainers-go/examples/questdb.test imports
        github.com/testcontainers/testcontainers-go/modules/questdb: module github.com/testcontainers/testcontainers-go@latest found (v0.23.0, replaced by ../..), but does not contain package github.com/testcon
tainers/testcontainers-go/modules/questdb

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right, the modules keyword must be taken from the struct's parentDir 🤦

Will submit a fix ASAP, thanks for reporting it

@mdelapenya mdelapenya deleted the refine-examples branch November 6, 2023 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that do not impact the existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants