Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public KeyMaterialFactory newKeyMaterialFactory(final URL endpoint, @Nonnull Vir
* Makes the credentials available locally and returns {@link KeyMaterialFactory} that gives you the parameters
* needed to access it.
*
* This is done by inserting the token into {@code ~/.dockercfg}
* This is done by inserting the token into {@code ~/.dockercfg} or {@code ~/.docker/config.json}
*/
public KeyMaterialFactory newKeyMaterialFactory(final @Nonnull URL endpoint, @Nonnull VirtualChannel target, @CheckForNull Launcher launcher, final @Nonnull TaskListener listener) throws InterruptedException, IOException {
target.call(new MasterToSlaveCallable<Void, IOException>() {
/**
* Insert the token into {@code ~/.dockercfg}
* Insert the token into {@code ~/.dockercfg} or {@code ~/.docker/config.json}
*/
@Override
public Void call() throws IOException {
Expand All @@ -96,6 +96,11 @@ public Void call() throws IOException {
if (config.exists()) {
json = JSONObject.fromObject(FileUtils.readFileToString(config, "UTF-8"));
auths = json.getJSONObject("auths");
if (auths.isNullObject()) {
auths = new JSONObject();
json.put("auths", auths);
FileUtils.writeStringToFile(config, json.toString(2), "UTF-8");
Copy link
Member

Choose a reason for hiding this comment

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

I would add some logic on the FINE/CONFIG level here. It is just a data migration logic IIUC

}
} else {
config = new File(System.getProperty("user.home"), ".dockercfg");
if (config.exists()) {
Expand Down