Closed walac closed 8 years ago
@walac Thanks much! I took your changes, and also exposed .login(...)
on the client so one doesn't have to hack in client._authInfo
. Example code:
var drc = require('docker-registry-client');
var bunyan = require('bunyan');
var log = bunyan.createLogger({name: 'pingplay', level: 'trace'});
var client = drc.createClientV2({
name: 'docker.io',
log: log,
username: 'MY-USERNAME',
password: 'MY-PASSWORD'
});
client.ping(function(err, body, res) {
if (!err) {
console.log('Success on first try');
} else if (err.statusCode === 401) {
client.login({
pingErr: err,
pingRes: res
}, function(err, result) {
client.ping(function(err, body, res) {
if (!err) {
console.log('Success');
} else {
console.log('Fail:', err);
}
});
});
} else {
console.log('Huh?', err);
}
});
This is published in docker-registry-client@3.1.0.
Great, thank you very much.
V2 ping function doesn't provide a way for bearer token authentication. With this commit, we pass the this._authInfo to ping function, and it is valid, we use it.
Sample code: