Skip to content

Commit 75c11ac

Browse files
add arg check and pass old image
1 parent e61302a commit 75c11ac

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

lib/models/apis/mavis.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var ApiClient = require('simple-api-client');
66
var util = require('util');
77
var Boom = require('dat-middleware').Boom;
88
var debug = require('debug')('runnable-api:mavis:model');
9+
var isObject = require('101/is-object');
10+
var isFunction = require('101/is-function');
911

1012
module.exports = Mavis;
1113

@@ -26,15 +28,28 @@ Mavis.prototype.findDockForNetwork = function (cb) {
2628
this.findDockForContainer({}, cb);
2729
};
2830

29-
Mavis.prototype.findDockForBuild = function (build, cb) {
31+
Mavis.prototype.findDockForBuild = function (contextVersion, cb) {
32+
debug('findDockForBuild', formatArgs(arguments));
33+
34+
if (!isObject(contextVersion)) {
35+
return cb(new Error('missing contextVersion'));
36+
}
37+
3038
var opts = {
3139
type: 'container_build'
3240
};
33-
opts.prevDuration = build.duration || 0;
41+
opts.prevDuration = contextVersion.duration || 0;
42+
opts.prevImage = contextVersion.dockerTag || null;
3443
this.findDock(opts, cb);
3544
};
3645

3746
Mavis.prototype.findDockForContainer = function (contextVersion, cb) {
47+
debug('findDockForContainer', formatArgs(arguments));
48+
49+
if (!isObject(contextVersion)) {
50+
return cb(new Error('missing contextVersion'));
51+
}
52+
3853
var opts = {
3954
type: 'container_run'
4055
};
@@ -104,10 +119,6 @@ function responseErr (res) {
104119
});
105120
}
106121

107-
// TODO: add all the findDock types
108-
// Mavis.prototype.findDockForContainerCreate
109-
110-
var isFunction = require('101/is-function');
111122
function formatArgs (args) {
112123
return Array.prototype.slice.call(args)
113124
.map(function (arg) {

0 commit comments

Comments
 (0)