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: support for titles in examples #775

Merged
merged 2 commits into from
Jan 25, 2023

Conversation

mdelapenya
Copy link
Collaborator

What does this PR do?

This PR is adding a flag to the examples generator so that it's possible to define a camelcase version of the name to be used when initials are present.

It will allow creating an example but overriding the default name with a custom title that follows the same rules that a name, i.e. alphabetical
characters, only. The only difference is that it allows uppercase chars that will be used when certain initials are needed in uppercase: i.e.
mongodb and MongoDB (before this changes it was Mongodb).

This title will be used here:

  • the CI descriptor, as its name
  • the H1 heading in the docs page for the example
  • the struct for the example, which is now exampleDBContainer
  • the setupExample function name, which is now setupExampleDB

Why is it important?

As detected here a technology with initials generated examples not 100% accurate,
forcing users of the generator to add a second commit polishing certain names.

This PR simplifies the creation of those examples including initials (MongoDB, QuestDB...).

Related issues

How to test this PR

go run . --name questdb --image "questdb/questdb:latest" --title QuestDB

It will allow creating an example but overriding the default name with a
custom title that follows the same rules that a name, i.e. alphabetical
characters, only. The only difference is that it allows uppercase chars
that will be used when certain initials are needed in uppercase: i.e.
mongodb and MongoDB (before this changes it was Mongodb).

This title will be used here:
- the CI descriptor, as its name
- the H1 heading in the docs page for the example
- the struct for the example, which is now exampleDBContainer
- the setupExample function name, which is now setupExampleDB
@mdelapenya mdelapenya requested a review from a team as a code owner January 24, 2023 16:45
@mdelapenya mdelapenya added the enhancement New feature or request label Jan 24, 2023
@mdelapenya mdelapenya self-assigned this Jan 24, 2023
@netlify
Copy link

netlify bot commented Jan 24, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 4ba42d0
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/63d10a00ece75b0008727493
😎 Deploy Preview https://deploy-preview-775--testcontainers-go.netlify.app/examples
📱 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.

@mdelapenya mdelapenya requested a review from a team January 24, 2023 16:45

### What is this tool not doing?

- If the example name does not contain alphabeticall characters, it will exit the generation.
- If the example name does not contain alphabetical characters, it will exit the generation.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Found a typo here

Comment on lines +125 to +127
"ToLower": func() string { return example.Lower() },
"Title": func() string { return example.Title() },
"ToLowerTitle": func() string { return example.LowerTitle() },
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The functions do not receive a parameter, instead reading the example value

kiview
kiview previously approved these changes Jan 25, 2023
docs/examples/index.md Outdated Show resolved Hide resolved
examples/main.go Outdated Show resolved Hide resolved
examples/main.go Outdated Show resolved Hide resolved
Co-authored-by: Kevin Wittek <kiview@users.noreply.github.com>
@mdelapenya mdelapenya merged commit 255d260 into testcontainers:main Jan 25, 2023
@mdelapenya mdelapenya changed the title chore: support for titles in examples feat: support for titles in examples Jan 25, 2023
@mdelapenya mdelapenya deleted the generator-variants branch January 30, 2023 12:37
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Feb 10, 2023
* main:
  chore: update Docker labels for containers (testcontainers#813)
  fix: nil pointer dereference in HealthStrategy (testcontainers#802)
  fix: Synchronise writes to containers map (testcontainers#812)
  chore(deps): bump google.golang.org/api from 0.108.0 to 0.109.0 in /examples (testcontainers#810)
  chore(deps): bump cloud.google.com/go/spanner in /examples/spanner (testcontainers#806)
  chore: restructure Docker helper methods (testcontainers#799)
  Verify Reaper state to create new or return existing instance (testcontainers#782)
  docs: add intel as user (testcontainers#798)
  chore: bump containerd in examples (testcontainers#797)
  chore(deps): bump github.com/containerd/containerd from 1.6.15 to 1.6.16 (testcontainers#793)
  chore: extract docker host calculation to an internal package (testcontainers#796)
  chore: run "go mod tidy" automatically when creating examples (testcontainers#794)
  chore: build images with backoff retries (testcontainers#792)
  fix: use right import package for compose in docs (testcontainers#791)
  chore(deps): bump google.golang.org/grpc from 1.52.1 to 1.52.3 in /examples (testcontainers#790)
  Add devcontainer file (testcontainers#765)
  chore: check dependabot dependencies weekly (testcontainers#789)
  chore(deps): bump google.golang.org/grpc from 1.52.0 to 1.52.1 in /examples (testcontainers#783)
  chore: support for titles in examples (testcontainers#775)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants