Skip to content

Commit 20a3e34

Browse files
committed
Check 'auth' field when displaying .dockercfg config
1 parent 14188ec commit 20a3e34

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

app/scripts/services/secrets.js

+18-12
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,29 @@ angular.module("openshiftConsole")
2828
return secretsByType;
2929
};
3030

31+
var setDataParams = function(decodedSecretData, serverName, data) {
32+
var usernamePassword = [];
33+
if (data.auth) {
34+
usernamePassword = window.atob(data.auth).split(":");
35+
} else if (data.username && data.password) {
36+
usernamePassword = [data.username, data.password];
37+
}
38+
39+
decodedSecretData.auths[serverName] = {
40+
username: usernamePassword[0],
41+
password: usernamePassword[1],
42+
email: data.email
43+
};
44+
return decodedSecretData;
45+
};
46+
3147
var decodeDockercfg = function(encodedData) {
3248
var decodedSecretData = {
3349
auths: {}
3450
};
3551
var decodedData = JSON.parse(window.atob(encodedData));
3652
_.each(decodedData, function(data, serverName) {
37-
decodedSecretData.auths[serverName] = {
38-
username: data.username,
39-
password: data.password,
40-
email: data.email
41-
};
53+
decodedSecretData = setDataParams(decodedSecretData, serverName, data);
4254
});
4355
return decodedSecretData;
4456
};
@@ -53,13 +65,7 @@ angular.module("openshiftConsole")
5365
decodedSecretData.auths[serverName] = data;
5466
return;
5567
}
56-
57-
var usernamePassword = window.atob(data.auth).split(":");
58-
decodedSecretData.auths[serverName] = {
59-
username: usernamePassword[0],
60-
password: usernamePassword[1],
61-
email: data.email
62-
};
68+
decodedSecretData = setDataParams(decodedSecretData, serverName, data);
6369
});
6470

6571
if (decodedData.credsStore) {

0 commit comments

Comments
 (0)