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: add functional option for startup commands #1647

Merged
merged 4 commits into from
Sep 20, 2023

Conversation

mdelapenya
Copy link
Member

@mdelapenya mdelapenya commented Sep 20, 2023

  • feat: add a generic option to add startup commands
  • docs: include startup commands in all modules

What does this PR do?

This PR adds a functional option to run arbitrary commands in the container that uses them.

The startup commands will be treated as an slice of strings that will be executed in the container right after it's started. For that, it will leverage the lifecycle hooks of the container, more specifically the PostStarts hooks. A new lifecycle hook will be created, which will be appended to the existing lifecycle hooks.

Finally, the new functional option has been documented in all existing modules, including the template for new ones.

Why is it important?

Containers, and more importantly modules, many time needs to run commands right after they are started to define a desired state. With this approach, we will simplify the way they users add those startup commands when defining a request for a container or a module.

@mdelapenya mdelapenya requested a review from a team as a code owner September 20, 2023 12:31
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Sep 20, 2023
@mdelapenya mdelapenya self-assigned this Sep 20, 2023
@netlify
Copy link

netlify bot commented Sep 20, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 1f74955
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/650ae8f43873100008eef2c5
😎 Deploy Preview https://deploy-preview-1647--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 mdelapenya merged commit 76dcf05 into testcontainers:main Sep 20, 2023
102 checks passed
@mdelapenya mdelapenya deleted the with-startup-commands branch September 20, 2023 15:21
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 20, 2023
* main:
  docs: have common options in a common markdown file (testcontainers#1648)
  feat: add functional option for startup commands (testcontainers#1647)
  fix: support running the semver Docker image interactively (testcontainers#1646)
  fix: proper next version
  chore: prepare for next minor development cycle ()
  chore: use new version (v0.24.1) in modules and examples
  fix: avoid deadlocks when Docker is not available (testcontainers#1645)
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.

1 participant