Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: building blocks for Go modules #1016

Merged
merged 43 commits into from Apr 4, 2023

Conversation

mdelapenya
Copy link
Collaborator

@mdelapenya mdelapenya commented Mar 29, 2023

What does this PR do?

This PR adds certain building blocks that will support the creation of new modules, and the migration of old examples to modules. For that:

  • it is adding a CustomizeRequestOption type which will be used in modules as a functional opt to customize the initial container request.
  • it is adding a func that modifies a container request, in order to provide our users with a way to customize the predefined container request for a given module. This function is able to merge the original request with the one provided by the users, appending maps and slices when needed.
  • because we are using a library for the merge (https://github.com/imdario/mergo), we are updating the Go dependencies to all modules.
  • it is also adding helper functional options for updating the Image, the WaitStrategy and the Docker types modifiers (for advanced configurations). This "sugar" represents what we consider the most used customizations from users.
  • it is enriching the log output when starting a container, using emojis. We consider that this log is important to understand what image is run, and when the container is created and started.
=== RUN   TestContainerCreationWithName
Testcontainers properties file has been found: /Users/mdelapenya/.testcontainers.properties
2023/03/28 18:08:40 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 20.10.23
  API Version: 1.41
  Operating System: Docker Desktop
  Total Memory: 7851 MB
2023/03/28 18:08:40 🐳 Starting container id: 365d35ee2b6a image: docker.io/testcontainers/ryuk:0.4.0
2023/03/28 18:08:40 🚧 Waiting for container id 365d35ee2b6a image: docker.io/testcontainers/ryuk:0.4.0
2023/03/28 18:08:40 ✅ Container is ready id: 365d35ee2b6a image: docker.io/testcontainers/ryuk:0.4.0
2023/03/28 18:08:40 🐳 Starting container id: c06ec5047fb8 image: docker.io/nginx:alpine
2023/03/28 18:08:40 🚧 Waiting for container id c06ec5047fb8 image: docker.io/nginx:alpine
2023/03/28 18:08:40 ✅ Container is ready id: c06ec5047fb8 image: docker.io/nginx:alpine
    docker_test.go:2211: terminating container
--- PASS: TestContainerCreationWithName (1.13s)
PASS
ok      github.com/testcontainers/testcontainers-go     1.349s

Why is it important?

Simplify the experience writing modules, preparing for the new Go design.

@mdelapenya mdelapenya requested a review from a team as a code owner March 29, 2023 14:51
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Mar 29, 2023
@mdelapenya mdelapenya self-assigned this Mar 29, 2023
@netlify
Copy link

netlify bot commented Mar 29, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 9e0dab2
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/642bf21c71c8a70008c68b2a
😎 Deploy Preview https://deploy-preview-1016--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 settings.

@sonarcloud
Copy link

sonarcloud bot commented Apr 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.5% 0.5% Duplication

@@ -3,19 +3,10 @@ package neo4j
import (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fbiville please take a look at these changes, as the NeoJ module will be refactored after this PR

@@ -3,9 +3,10 @@ package vault
import (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@alihanyalcin please take a look at these changes, as the Vault module will be refactored after this PR

Copy link
Collaborator Author

@mdelapenya mdelapenya Apr 4, 2023

Choose a reason for hiding this comment

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

BTW, couchbase won't be modified, as it comes with some postStart "hooks" (initCluster and create buckets), and the container request is not providing those capabilities yet. Possibly in upcoming releases

@mdelapenya mdelapenya merged commit 09208cd into testcontainers:main Apr 4, 2023
53 checks passed
@mdelapenya mdelapenya deleted the modules-infra branch April 4, 2023 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or new behaviors on the existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant