1+ var _ = require ( 'underscore' ) ;
2+
13var Container = function ( modem , id ) {
24 this . modem = modem ;
35 this . id = id ;
6+
7+ this . defaultOptions = {
8+ top : { } ,
9+ start : { } ,
10+ commit : { } ,
11+ stop : { } ,
12+ restart : { } ,
13+ resize : { } ,
14+ attach : { } ,
15+ remove : { } ,
16+ copy : { }
17+ } ;
18+
419} ;
520
621Container . prototype . inspect = function ( callback ) {
@@ -37,7 +52,7 @@ Container.prototype.top = function(opts, callback) {
3752 404 : "no such container" ,
3853 500 : "server error"
3954 } ,
40- options : opts
55+ options : _ . extend ( { } , this . defaultOptions . top , opts )
4156 } ;
4257
4358 this . modem . dial ( optsf , function ( err , data ) {
@@ -92,7 +107,7 @@ Container.prototype.start = function(opts, callback) {
92107 404 : "no such container" ,
93108 500 : "server error"
94109 } ,
95- options : opts
110+ options : _ . extend ( { } , this . defaultOptions . start , opts )
96111 } ;
97112
98113 this . modem . dial ( optsf , function ( err , data ) {
@@ -116,7 +131,7 @@ Container.prototype.commit = function(opts, callback) {
116131 404 : "no such container" ,
117132 500 : "server error"
118133 } ,
119- options : opts
134+ options : _ . extend ( { } , this . defaultOptions . commit , opts )
120135 } ;
121136
122137 this . modem . dial ( optsf , function ( err , data ) {
@@ -138,7 +153,7 @@ Container.prototype.stop = function(opts, callback) {
138153 404 : "no such container" ,
139154 500 : "server error"
140155 } ,
141- options : opts
156+ options : _ . extend ( { } , this . defaultOptions . stop , opts )
142157 } ;
143158
144159 this . modem . dial ( optsf , function ( err , data ) {
@@ -160,7 +175,7 @@ Container.prototype.restart = function(opts, callback) {
160175 404 : "no such container" ,
161176 500 : "server error"
162177 } ,
163- options : opts
178+ options : _ . extend ( { } , this . defaultOptions . restart , opts )
164179 } ;
165180
166181 this . modem . dial ( optsf , function ( err , data ) {
@@ -188,7 +203,7 @@ Container.prototype.resize = function(opts, callback) {
188203 var optsf = {
189204 path : '/containers/' + this . id + '/resize?' ,
190205 method : 'POST' ,
191- options : opts ,
206+ options : _ . extend ( { } , this . defaultOptions . resize , opts ) ,
192207 statusCodes : {
193208 200 : true ,
194209 400 : 'bad parameter' ,
@@ -206,7 +221,7 @@ Container.prototype.attach = function(opts, callback) {
206221 var optsf = {
207222 path : '/containers/' + this . id + '/attach?' ,
208223 method : 'POST' ,
209- options : opts ,
224+ options : _ . extend ( { } , this . defaultOptions . attach , opts ) ,
210225 isStream : true ,
211226 openStdin : opts . stdin ,
212227 statusCodes : {
@@ -253,7 +268,7 @@ Container.prototype.remove = function(opts, callback) {
253268 404 : "no such container" ,
254269 500 : "server error"
255270 } ,
256- options : opts
271+ options : _ . extend ( { } , this . defaultOptions . remove , opts )
257272 } ;
258273
259274 this . modem . dial ( optsf , function ( err , data ) {
@@ -271,7 +286,7 @@ Container.prototype.copy = function(opts, callback) {
271286 404 : "no such container" ,
272287 500 : "server error"
273288 } ,
274- options : opts
289+ options : _ . extend ( { } , this . defaultOptions . copy , opts )
275290 } ;
276291
277292 this . modem . dial ( optsf , function ( err , data ) {
0 commit comments