Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DockerClient {

options = options || {};

return self._validate(options, schemas.auth.options).then((params) => {
return self._validate(options, schemas.auth).then((params) => {
return self.modem.post({
url: '/auth',
body: params,
Expand Down
15 changes: 1 addition & 14 deletions lib/endpoints/containers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const schemas = require('../schemas/containers');
const auth = require('../helpers/auth');

class ContainersClient {

Expand Down Expand Up @@ -29,7 +28,7 @@ class ContainersClient {
});
}

create(model, options, auth) {
create(model, options) {
const self = this;

options = options || {};
Expand All @@ -52,12 +51,6 @@ class ContainersClient {
}
};

if(auth) {
requestOptions.headers = {
'X-Registry-Auth': auth.generate(auth)
};
}

return this.docker.modem.post(requestOptions);
});
}
Expand Down Expand Up @@ -320,12 +313,6 @@ class ContainersClient {
}
};

if(auth) {
requestOptions.headers = {
'X-Registry-Auth': auth.generate(auth)
};
}

return self.docker.modem.post(requestOptions);
});
}
Expand Down
7 changes: 4 additions & 3 deletions lib/endpoints/images.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const schemas = require('../schemas/images');
const auth = require('../helpers/auth');

class ImagesClient {

Expand Down Expand Up @@ -41,7 +42,7 @@ class ImagesClient {
qs: params,
headers: {
'Content-type': 'application/tar',
'X-Registry-Auth': JSON.stringify(registryAuth)
'X-Registry-Auth': auth.generate(registryAuth)
},
successCodes: {
200: 'No Error'
Expand All @@ -65,7 +66,7 @@ class ImagesClient {
url: '/images/create',
qs: params,
headers: {
'X-Registry-Auth': JSON.stringify(registryAuth)
'X-Registry-Auth': auth.generate(registryAuth)
},
successCodes: {
200: 'No Error'
Expand Down Expand Up @@ -129,7 +130,7 @@ class ImagesClient {
url: `/images/${name}/push`,
qs: params,
headers: {
'X-Registry-Auth': JSON.stringify(registryAuth)
'X-Registry-Auth': auth.generate(registryAuth)
},
successCodes: {
200: 'No Error'
Expand Down
16 changes: 7 additions & 9 deletions lib/schemas/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

const Joi = require('joi');

module.exports.auth = {
options: Joi.object().keys({
username: Joi.string().optional(),
password: Joi.string().optional(),
email: Joi.string().email().optional(),
serveraddress: Joi.string().uri().optional(),
identitytoken: Joi.string().optional()
})
};
module.exports.auth = Joi.object().keys({
username: Joi.string().optional(),
password: Joi.string().optional(),
email: Joi.string().email().optional(),
serveraddress: Joi.string().uri({ allowRelative: true }).optional(),
identitytoken: Joi.string().optional()
});

module.exports.events = {
options: Joi.object().keys({
Expand Down
12 changes: 9 additions & 3 deletions test/images/inspect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const Code = require('code');
const Lab = require('lab');
const harness = require('../harness');

Expand All @@ -13,9 +14,14 @@ lab.experiment('images - inspect', () => {
.get('/images/hello-world/json')
.reply(200, {});

const req = harness.client.images().inspect('hello-world');

harness.handleSuccess(scope, 200, req, done);
harness.client.images().inspect('hello-world').then(() => {
Code.expect(scope.isDone()).to.equal(true);
}, () => {
Code.fail('should be a 200 response');
}).finally(() => {
harness.clean();
done();
});

});

Expand Down
13 changes: 10 additions & 3 deletions test/images/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const Code = require('code');
const Lab = require('lab');
const harness = require('../harness');

Expand All @@ -11,11 +12,17 @@ lab.experiment('images - list', () => {

const scope = harness.mock()
.get('/images/json')
.query({all: false, digest: false})
.reply(200, {});

const req = harness.client.images().list();

harness.handleSuccess(scope, 200, req, done);
harness.client.images().list().then(() => {
Code.expect(scope.isDone()).to.equal(true);
}, () => {
Code.fail('should be a 200 response');
}).finally(() => {
harness.clean();
done();
});

});

Expand Down
14 changes: 9 additions & 5 deletions test/images/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const Code = require('code');
const Lab = require('lab');
const harness = require('../harness');

Expand All @@ -11,15 +12,18 @@ lab.experiment('images - search', () => {

const scope = harness.mock()
.get('/images/search')
.query({ term: 'hello-world' })
.query({term: 'hello-world'})
.reply(200, {});

const req = harness.client.images().search({
term: 'hello-world'
harness.client.images().search({term: 'hello-world'}).then(() => {
Code.expect(scope.isDone()).to.equal(true);
}, () => {
Code.fail('should be a 200 response');
}).finally(() => {
harness.clean();
done();
});

harness.handleSuccess(scope, 200, req, done);

});

});