Skip to content

feat: create an internal sdk for docker contexts and docker configs #3091

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

mdelapenya
Copy link
Member

  • feat: create a seed for an sdk in the internal package
  • chore: wrap errors
  • chore: use new dockerconfig package instead of cpuguy83's
  • chore: run mod tidy

What does this PR do?

This PR adds two packages into a new internal docker package:

  • context: locates and loads docker contexts from the docker config path.
  • config: locates and reads docker config from the docker config path.

The config package embedes the cpuyguy83's dockercfg package, to have control on the config and auth types.

Why is it important?

Both new packages could represent the seed for an eventual docker-sdk-go package, that would naturally emerge from this internal set of packages.

They are internal in order to iterate faster, and not break clients of testcontainers-go.

Related issues

@mdelapenya mdelapenya requested a review from a team as a code owner April 8, 2025 12:03
@mdelapenya mdelapenya added the feature New functionality or new behaviors on the existing one label Apr 8, 2025
@mdelapenya mdelapenya self-assigned this Apr 8, 2025
@mdelapenya mdelapenya requested a review from stevenh April 8, 2025 12:03
Copy link

netlify bot commented Apr 8, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit fab6f05
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/6808e05496061a0008482370
😎 Deploy Preview https://deploy-preview-3091--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
Member Author

@stevenh I think this PR would be the foundation for the internal SDK in which the work for the new docker client could land.

Can we prioritise this PR if possible?


// getContextFromEnv returns the context name from the environment variables.
func getContextFromEnv() string {
if os.Getenv(EnvOverrideHost) != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

bug: this looks like it should be an == ""?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting as that specifically breaks context if you specify a host. This is documented in the comment for CurrentContext. We should replicate that so folks know the history if we want to keep that behaviour as it's quite unexpected.

Comment on lines +50 to +54
if ctxName := os.Getenv(EnvOverrideContext); ctxName != "" {
return ctxName
}

return ""
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: simplify to only one read so it also closes the race condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

we are reading two different variables, is that what you meant?

@mdelapenya mdelapenya requested a review from stevenh April 23, 2025 12:03
* main:
  feat: add toxiproxy module (testcontainers#3092)
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.

2 participants