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(nats): WithConfigFile - pass a configuration file to nats server #2905

Merged
merged 13 commits into from
Dec 5, 2024

Conversation

vyskocilm
Copy link
Contributor

What does this PR do?

Nats server can be started with a custom configuration file.

Why is it important?

While a lot of options can be passed as a command line parameters, having an
ability to pass a custom configuration file helps a testing of more advanced
real world setups, like authn/authz.

Method WithConfigFile is provided by other modules like postgresql. The
difference is this version accepts io.Reader, so configuration file does not
need to be a real file stored on a host. This simplifies a testing setup.

Related issues

N/A

How to test this PR

This PR adds a simple test starting the server with a custom authorization
token and shows a client without a correct one can't connect to the server,
while the one with a right one can.

As a final validation the logs of the container are checked for Using configuration file: /etc/nats.conf text.

@vyskocilm vyskocilm requested a review from a team as a code owner December 1, 2024 21:01
Copy link

netlify bot commented Dec 1, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 89b884b
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/674f0c010030e0000879b544
😎 Deploy Preview https://deploy-preview-2905--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.

Copy link
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, adding a config option is a good addition.

We're looking to use ContainerCustomizers where possible moving forward, looks like this would work for this case, so if we could make that switch it should simplify.

modules/nats/options.go Outdated Show resolved Hide resolved
modules/nats/nats.go Outdated Show resolved Hide resolved
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Dec 2, 2024
modules/nats/options.go Outdated Show resolved Hide resolved
mdelapenya
mdelapenya previously approved these changes Dec 2, 2024
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

LGTM, although I added two wording suggestions in the docs

modules/nats/options.go Outdated Show resolved Hide resolved
docs/modules/nats.md Outdated Show resolved Hide resolved
@mdelapenya mdelapenya changed the title feat: WithConfigFile - pass a configuration file to nats server feat(nats): WithConfigFile - pass a configuration file to nats server Dec 2, 2024
@mdelapenya mdelapenya self-assigned this Dec 2, 2024
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
Co-authored-by: Manuel de la Peña <social.mdelapenya@gmail.com>
@vyskocilm vyskocilm requested a review from stevenh December 2, 2024 10:21
mdelapenya
mdelapenya previously approved these changes Dec 3, 2024
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

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

Just a few tweaks to the language and test

docs/modules/nats.md Outdated Show resolved Hide resolved
modules/nats/nats_test.go Outdated Show resolved Hide resolved
modules/nats/nats_test.go Show resolved Hide resolved
modules/nats/options.go Outdated Show resolved Hide resolved
Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdelapenya mdelapenya merged commit 0bbab5e into testcontainers:main Dec 5, 2024
122 checks passed
@mdelapenya
Copy link
Member

Merged, thanks for your work here 🙇

mdelapenya added a commit to mtellis2/testcontainers-go that referenced this pull request Dec 11, 2024
* main: (234 commits)
  chore(ci): add Github labels based on PR title (testcontainers#2914)
  chore(gha): Use official setup-docker-action (testcontainers#2913)
  chore(ci): enforce conventional commits syntax in PR titles (testcontainers#2911)
  feat(nats): WithConfigFile - pass a configuration file to nats server (testcontainers#2905)
  chore: enable implicit default logger only in testing with -v (testcontainers#2877)
  fix: container binds syntax (testcontainers#2899)
  refactor(cockroachdb): to use request driven options (testcontainers#2883)
  chore(deps): bump actions/setup-go from 5.0.0 to 5.1.0 (testcontainers#2904)
  chore(deps): bump ossf/scorecard-action from 2.3.1 to 2.4.0 (testcontainers#2903)
  chore(deps): bump test-summary/action from 2.3 to 2.4 (testcontainers#2902)
  feat(wait): strategy walk (testcontainers#2895)
  feat(wait): tls strategy (testcontainers#2896)
  docs: better contribution guidelines (testcontainers#2893)
  fix(influxdb): Respect custom waitStrategy (testcontainers#2845)
  fix: only upload to sonar on ubuntu-latest (testcontainers#2891)
  fix: build artifact name properly (testcontainers#2890)
  fix: do not run sonar upload when ryuk is disabled (testcontainers#2889)
  fix: update GH actions for uploading/downloading artifacts (testcontainers#2888)
  feat(ci): Enable master moby with rootless (testcontainers#2880)
  fix(redpanda): temporary file use
  ...
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Dec 13, 2024
* main:
  feat(gcloud)!: add support to seed data when using RunBigQueryContainer (testcontainers#2523)
  security(deps): bump golang.org/x/crypto from 0.28.0 to 0.31.0 (testcontainers#2916)
  chore(ci): add Github labels based on PR title (testcontainers#2914)
  chore(gha): Use official setup-docker-action (testcontainers#2913)
  chore(ci): enforce conventional commits syntax in PR titles (testcontainers#2911)
  feat(nats): WithConfigFile - pass a configuration file to nats server (testcontainers#2905)
  chore: enable implicit default logger only in testing with -v (testcontainers#2877)
  fix: container binds syntax (testcontainers#2899)
  refactor(cockroachdb): to use request driven options (testcontainers#2883)
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.

3 participants