testcontainers-dotnet icon indicating copy to clipboard operation
testcontainers-dotnet copied to clipboard

Support for credentials from environment variables

Open vova-lantsov-dev opened this issue 2 years ago • 2 comments

Describe the solution you'd like For CI/CD purposes, it'd be really useful to be able to auth via environment variables that contains the Docker config data. Here is an example: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#determine-your-docker_auth_config-data

Something like that: image

vova-lantsov-dev avatar Aug 01 '22 11:08 vova-lantsov-dev

The env variable DOCKER_AUTH_CONFIG is not yet supported. Base64 just works with ~/.docker/config.json. Anyway, it is not difficult to implement. We just need another provider. Something like: https://github.com/testcontainers/testcontainers-dotnet/blob/0f4d0ff3ab79567bda94b8d3d41e0a9987665497/src/Testcontainers/Builders/Base64Provider.cs#L12

To read the value from the env variable or ~/.testcontainers.properties file, we need another getter in: https://github.com/testcontainers/testcontainers-dotnet/blob/0f4d0ff3ab79567bda94b8d3d41e0a9987665497/src/Testcontainers/Configurations/PropertiesFileConfiguration.cs#L11

Probably we can use the same test cases, like we are using for ~/.docker/config.json: https://github.com/testcontainers/testcontainers-dotnet/blob/0f4d0ff3ab79567bda94b8d3d41e0a9987665497/tests/Testcontainers.Tests/Unit/Configurations/DockerRegistryAuthenticationProviderTest.cs#L62

Would you like to create a pull request?

HofmeisterAn avatar Aug 01 '22 14:08 HofmeisterAn

Sure, I would try

vova-lantsov-dev avatar Aug 01 '22 23:08 vova-lantsov-dev