-
Notifications
You must be signed in to change notification settings - Fork 298
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(core): tolerate DOCKER_AUTH_CONFIG
with schemas that are not implemented in tc-python
#646
fix(core): tolerate DOCKER_AUTH_CONFIG
with schemas that are not implemented in tc-python
#646
Conversation
I've been hitting my head on this for the past few days. This would be a super welcome fix |
from what i can tell this PR only lets the library tolerate this env var - not actually use it correctly. do you guys have this env var set in your environment by default like for other programs? |
lets say you are looking at this readme: https://github.com/awslabs/amazon-ecr-credential-helper?tab=readme-ov-file#configuration
ok so how you use this is echo $(aws sts get-caller-identity | jq -r .Account).dkr.ecr.us-east-1.amazonaws.com \
| docker-credential-ecr-login get \
| jq .Secret -r \
| docker login -u AWS --password-stdin "https://$(aws sts get-caller-identity | jq -r .Account).dkr.ecr.us-east-1.amazonaws.com" so basically now you see how to get the username and password out of an ecr helper - presumably other helpers have other conventions so if you wanted to you could write a simple bash script that formats the data back into a JSON with a username/password and feed that into the library. |
This is the problem I am running into
Ultimately our DOCKER_AUTH_CONFIG is set globally to use the credsStore as specified above, however in the unittests I am using this is there isn't really a need for custom auth to a private registry.
This makes an assumption that if there is an docker_auth_config it will have an at least one auths entry. In this case the docker_auth_config is present but without an explicit auths section cause this to throw an AttributeError. It should either respect and use the credsStore present or handle the case of no auths keys resulting in potentially an auth error rather than throwing an AttributeError exception. The PR fixes the flaw with the .get("auths"). In our case this is returning None where an empty dict should result in more desired behavior. |
DOCKER_AUTH_CONFIG
with schemas that are not implemented in tc-python
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #646 +/- ##
=======================================
Coverage ? 76.55%
=======================================
Files ? 11
Lines ? 580
Branches ? 84
=======================================
Hits ? 444
Misses ? 110
Partials ? 26 ☔ View full report in Codecov by Sentry. |
@alexanderankin Thank you for the comment! I undestand that your bash script could be able to transform the credentials to the format that is accepted by the library with some more commands but I think that the main purpose of the credential helper is to avoid an explicit login into a private registry because it uses a preconfigured and logged AWS account and if I had to make a previous script with multiple commands, I think I would prefer to use the AWS CLI with the following command:
As well as @gifflen, I use a global DOCKER_AUTH_CONFIG env var in my pipeline, but I do not need it to login in a private registry for my tests job. I use it to build the production image of my service in another job. I think that the PR #647 would be a better solution to solve this problem and will allow the use of credentials helpers within the library. Should we close this PR and pay attention to that one? Or do you prefer to merge this temporary fix and implement the full solution in the other PR? |
I am reading the implementation of the credentials helper in the testcontainers-java library and it is so much similar to the bash command you wrote @alexanderankin. Here are some references: Function to get the username and password from credentials helper But... The credentials helpers are called automatically when you try to pull an image from a registry. It is not necessary to do docker login explicity as is doing the testcontainers-java library, is it? |
@alvaromerinog we try and take aspiration from |
seems like superceded by #647 - closing for now - but looking forward to more PRs to implement the actual missing functionality |
since this env var might be set in the env targetting software other than this library, this library should silently ignore what it considers to be invalid input