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

fix: docker config error handling when config file does not exist #2772

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

stevenh
Copy link
Collaborator

@stevenh stevenh commented Sep 7, 2024

Handle file not exist error in getDockerAuthConfigs, treating it as if no authentication was provided.

Use config directly for cache instead of loading the file a second time which may be the wrong file if loaded from the environment.

Correctly handle json decode errors in getDockerConfig instead of falling back to the default config, which would result in unexpected behaviour.

Tests refactored to ensure all edge cases for getDockerConfig and getDockerAuthConfigs are handled.

Fixes #2767
Closes #2771

@stevenh stevenh requested a review from a team as a code owner September 7, 2024 16:57
Copy link

netlify bot commented Sep 7, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 7931b93
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66dca80ac7b2730008fd20ac
😎 Deploy Preview https://deploy-preview-2772--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.

@stevenh stevenh changed the title fix: auth with no docker config fix: docker config error handling Sep 7, 2024
@stevenh stevenh force-pushed the fix/auth-no-config branch 2 times, most recently from 8f66bf1 to 84fd80a Compare September 7, 2024 18:36
@stevenh stevenh marked this pull request as draft September 7, 2024 18:36
Handle file not exist error in getDockerAuthConfigs, treating it as if
no authentication was provided.

Use config directly for cache instead of loading the file a second time
which may be the wrong file if loaded from the environment.

Correctly handle json decode errors in getDockerConfig instead of
falling back to the default config, which would result in unexpected
behaviour.

Tests refactored to ensure all edge cases for getDockerConfig and
getDockerAuthConfigs are handled.

Fixes testcontainers#2767
Copy link

@daniel-meyer-dme daniel-meyer-dme left a comment

Choose a reason for hiding this comment

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

nice test extension

@mdelapenya mdelapenya self-assigned this Sep 9, 2024
@mdelapenya mdelapenya added the bug An issue with the library label Sep 9, 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!

@mdelapenya mdelapenya changed the title fix: docker config error handling fix: docker config error handling when config file does not exist Sep 9, 2024
@mdelapenya mdelapenya merged commit 6a947dc into testcontainers:main Sep 9, 2024
112 checks passed
@stevenh stevenh deleted the fix/auth-no-config branch September 9, 2024 15:38
mdelapenya added a commit that referenced this pull request Sep 10, 2024
* main:
  ci: add generate for mocks (#2774)
  fix: docker config error handling when config file does not exist (#2772)
  docs: refine heading badges in README (#2770)
mdelapenya added a commit to stevenh/testcontainers-go that referenced this pull request Sep 10, 2024
* main:
  ci: add generate for mocks (testcontainers#2774)
  fix: docker config error handling when config file does not exist (testcontainers#2772)
  docs: refine heading badges in README (testcontainers#2770)
  feat(wait): for file (testcontainers#2731)
  feat(compose): select services via profiles (testcontainers#2758)
  chore(deps): bump mkdocs-markdownextradata-plugin from 0.2.5 to 0.2.6 (testcontainers#2761)
  fix: update template too (testcontainers#2763)
  chore(deps): bump actions/checkout from 4.1.1 to 4.1.7 (testcontainers#2762)
  chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.2.2 (testcontainers#2760)
  fix: check if the discovered docker socket responds (testcontainers#2741)
  Upgrade milvus-io/milvus-sdk-go to avoid checksum mismatch. (testcontainers#2753)
  Fix trailing slash on Image Prefix (testcontainers#2747)
  chore: use new testcontainers/ryuk:0.9.0 image (testcontainers#2750)
  chore(deps): bump minimal Go version from 1.21 to 1.22 (testcontainers#2743)
  chore(deps): bump github/codeql-action from 3.24.9 to 3.25.15 (testcontainers#2677)
  fix: use of log.Fatal in main (testcontainers#2739)
  chore: prepare for next minor development cycle (0.34.0)
  chore: use new version (v0.33.0) in modules and examples
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 11, 2024
* main:
  ci: add generate for mocks (testcontainers#2774)
  fix: docker config error handling when config file does not exist (testcontainers#2772)
  docs: refine heading badges in README (testcontainers#2770)
  feat(wait): for file (testcontainers#2731)
  feat(compose): select services via profiles (testcontainers#2758)
  chore(deps): bump mkdocs-markdownextradata-plugin from 0.2.5 to 0.2.6 (testcontainers#2761)
  fix: update template too (testcontainers#2763)
  chore(deps): bump actions/checkout from 4.1.1 to 4.1.7 (testcontainers#2762)
  chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.2.2 (testcontainers#2760)
  fix: check if the discovered docker socket responds (testcontainers#2741)
  Upgrade milvus-io/milvus-sdk-go to avoid checksum mismatch. (testcontainers#2753)
  Fix trailing slash on Image Prefix (testcontainers#2747)
  chore: use new testcontainers/ryuk:0.9.0 image (testcontainers#2750)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 18, 2024
* main:
  fix: resource clean up for tests and examples (testcontainers#2738)
  ci: add generate for mocks (testcontainers#2774)
  fix: docker config error handling when config file does not exist (testcontainers#2772)
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 23, 2024
* main:
  chore: use a much smaller image for testing (testcontainers#2795)
  fix: parallel containers clean race (testcontainers#2790)
  fix(registry): wait for (testcontainers#2793)
  fix: container timeout test (testcontainers#2792)
  docs: document redpanda options (testcontainers#2789)
  feat: support databend module (testcontainers#2779)
  chore: golangci-lint 1.61.0 (testcontainers#2787)
  fix(mssql): bump Docker image version (testcontainers#2786)
  fix: handle 127 error code for podman compatibility (testcontainers#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (testcontainers#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (testcontainers#2777)
  fix(postgres): Apply default snapshot name if no name specified (testcontainers#2783)
  fix: resource clean up for tests and examples (testcontainers#2738)
  ci: add generate for mocks (testcontainers#2774)
  fix: docker config error handling when config file does not exist (testcontainers#2772)
mdelapenya added a commit that referenced this pull request Sep 26, 2024
* main: (29 commits)
  fix: template for code generation (#2800)
  fix: update module path (#2797)
  fix: container logging deadlocks (#2791)
  chore: use a much smaller image for testing (#2795)
  fix: parallel containers clean race (#2790)
  fix(registry): wait for (#2793)
  fix: container timeout test (#2792)
  docs: document redpanda options (#2789)
  feat: support databend module (#2779)
  chore: golangci-lint 1.61.0 (#2787)
  fix(mssql): bump Docker image version (#2786)
  fix: handle 127 error code for podman compatibility (#2778)
  fix: do not override ImageBuildOptions.Labels when building from a Dockerfile (#2775)
  feat(mongodb): Wait for mongodb module with a replicaset to finish (#2777)
  fix(postgres): Apply default snapshot name if no name specified (#2783)
  fix: resource clean up for tests and examples (#2738)
  ci: add generate for mocks (#2774)
  fix: docker config error handling when config file does not exist (#2772)
  docs: refine heading badges in README (#2770)
  feat(wait): for file (#2731)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Consider handling non-existent ~/.docker/config.json
3 participants