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

Also looks for registry credential files in XDG folders #3532

Merged

Conversation

sv3ndk
Copy link
Contributor

@sv3ndk sv3ndk commented Dec 18, 2021

This PR is my proposition for addressing #3524 . This is my first contribution to this project, don't hesitate to let me know if I failed to follow any convention.

This PR adds 2 locations, based on the XDG base directory specification, to the list of places where Jib looks for a credential file for registry authentication.

The main motivation for this change is enabling to use Jib together with Podman.

The 2 added locations are also mentioned in man containers-auth.json:

A credentials file in JSON format used to authenticate against container image registries. 
The primary (read/write) file is stored at ${XDG_RUNTIME_DIR}/containers/auth.json on Linux; 
on Windows and macOS, at $HOME/.config/containers/auth.json.

When searching for the credential for a registry, the following files will be read in sequence 
until the valid credential is found: first reading the primary (read/write) file, or the explicit override 
using an option of the calling application.  If credentials are not present, search in 
${XDG_CONFIG_HOME}/containers/auth.json, $HOME/.docker/config.json, $HOME/.dockercfg.
...

This logic seems aligned with the philosophy of Jib, which already iterates through various locations.

Jib also already follows XDG specification, for example for storing its own config.

The resulting flow should hopefully be natural to most users: both Docker and Podman users would have their credential file picked up automatically in the default location of their tool.

I updated documentation to mention the new configuration feature.

@sv3ndk sv3ndk changed the title Also looks or registry credential files in XDG folders Also looks for registry credential files in XDG folders Dec 18, 2021
@ddixit14
Copy link

@sv3ndk Thank you for your contribution, really appreciate it. The team will review this after the holidays.
Happy Coding 👯

@sv3ndk
Copy link
Contributor Author

sv3ndk commented Dec 21, 2021

Thanks for the kind feed-back. Enjoy the holidays :)

@ddixit14
Copy link

You too. Happy Holidays!

@sv3ndk
Copy link
Contributor Author

sv3ndk commented Jan 14, 2022

Hi @ddixit14 , I pushed a commit to fix the formatting issues, could you please re-trigger the CI workflow?

@sv3ndk
Copy link
Contributor Author

sv3ndk commented Jan 14, 2022

Sorry, I'm realizing there was one remaining formatting issue that ./gradlew clean goJF had not fixed (I probably forgot the to "clean" first).
Now hopefully it should be correct. At least ./gradlew clean jib-plugins-common:verifyGoogleJavaFormat does not report anything on my host atm.

@chanseokoh chanseokoh force-pushed the xdg_registry_authentication branch from df403f0 to 49b585c Compare January 14, 2022 19:33
@chanseokoh
Copy link
Member

Thanks for your contribution. I'm going to merge this once the tests pass, unless I hear back any concerns from you.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants