New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-docker-api

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-docker-api - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

.travis.yml

181

lib/volume.js

@@ -7,10 +7,183 @@ 'use strict';

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Volume = function Volume(modem) {
_classCallCheck(this, Volume);
var Volume = function () {
function Volume(modem, id) {
_classCallCheck(this, Volume);
this.modem = modem;
};
this.modem = modem;
this.id = id;
}
/*
* Get the list of volumes
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/list-volumes
*
* @param {Object} opts Query params in the request (optional)
* @return {Promise} Promise returning the result as a list of volumes
*/
_createClass(Volume, [{
key: 'list',
value: function list(opts) {
var _this = this;
var call = {
path: '/volumes',
method: 'GET',
options: opts,
statusCodes: {
200: true,
500: 'server error'
}
};
return new Promise(function (resolve, reject) {
_this.modem.dial(call, function (err, result) {
if (err) return reject(err);
resolve(result.Volumes.map(function (conf) {
var volume = new Volume(_this.modem, conf.Name);
return Object.assign(volume, conf);
}));
});
});
}
/*
* Create an volume
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/create-a-volume
*
* @param {Object} opts Query params in the request (optional)
* @return {Promise} Promise return the new volume
*/
}, {
key: 'create',
value: function create(opts) {
var _this2 = this;
var call = {
path: '/volumes/create?',
method: 'POST',
options: opts,
statusCodes: {
201: true,
500: 'server error'
}
};
return new Promise(function (resolve, reject) {
_this2.modem.dial(call, function (err, conf) {
if (err) return reject(err);
var volume = new Volume(_this2.modem, conf.Name);
resolve(Object.assign(volume, conf));
});
});
}
/*
* Get low-level information on a volume
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/inspect-a-volume
* The reason why this module isn't called inspect is because that interferes with the inspect utility of node.
*
* @param {Object} opts Query params in the request (optional)
* @param {String} id ID of the volume to inspect, if it's not set, use the id of the object (optional)
* @return {Promise} Promise return the new volume
*/
}, {
key: 'status',
value: function status(opts, id) {
var _this3 = this;
var _processArguments = this.__processArguments(opts, id);
var _processArguments2 = _slicedToArray(_processArguments, 2);
opts = _processArguments2[0];
id = _processArguments2[1];
var call = {
path: '/volumes/' + id + '?',
method: 'GET',
options: opts,
statusCodes: {
200: true,
404: 'no such volume',
500: 'server error'
}
};
return new Promise(function (resolve, reject) {
_this3.modem.dial(call, function (err, conf) {
if (err) return reject(err);
var volume = new Volume(_this3.modem, id);
resolve(Object.assign(volume, conf));
});
});
}
/*
* Remove an volume from the filesystem
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/remove-a-volume
*
* @param {Object} opts Query params in the request (optional)
* @param {String} id ID of the volume to inspect, if it's not set, use the id of the object (optional)
* @return {Promise} Promise return the new volume
*/
}, {
key: 'remove',
value: function remove(opts, id) {
var _this4 = this;
var _processArguments3 = this.__processArguments(opts, id);
var _processArguments4 = _slicedToArray(_processArguments3, 2);
opts = _processArguments4[0];
id = _processArguments4[1];
var call = {
path: '/volumes/' + id + '?',
method: 'DELETE',
options: opts,
statusCodes: {
204: true,
404: 'no such volume',
409: 'conflict',
500: 'server error'
}
};
return new Promise(function (resolve, reject) {
_this4.modem.dial(call, function (err, res) {
if (err) return reject(err);
resolve(res);
});
});
}
}, {
key: '__processArguments',
value: function __processArguments(opts, id) {
if (typeof opts === "string" && !id) {
id = opts;
}
if (!id && this.id) {
id = this.id;
}
if (!opts) opts = {};
return [opts, id];
}
}]);
return Volume;
}();
exports.default = Volume;

8

package.json
{
"name": "node-docker-api",
"version": "1.0.5",
"version": "1.0.6",
"description": "Docker Remote API driver for node",
"main": "./lib/docker",
"scripts": {
"test": "./node_modules/standard/bin/cmd.js src && ./node_modules/mocha/bin/mocha --require babel-core/register -R spec",
"build": "babel src --presets babel-preset-es2015 --out-dir lib"
"test": "chmod +x test.sh; ./test.sh",
"build": "./node_modules/babel-cli/bin/babel.js src --presets babel-preset-es2015 --out-dir lib"
},

@@ -26,2 +26,4 @@ "repository": {

"devDependencies": {
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-preset-es2015": "^6.9.0",

@@ -28,0 +30,0 @@ "chai": "^3.5.0",

# docker-api
[![travis-ci](https://travis-ci.org/AgustinCB/docker-api.png?branch=master)](https://travis-ci.org/AgustinCB/docker-api)

@@ -14,3 +15,3 @@ Docker Remote API driver for node.js. It uses the same modem than [dockerode](https://github.com/apocas/docker), but the interface is promisified and with a different syntax.

The current status of the package is in development. From the [API reference](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24), there's full support and test for sections 3.1, 3.2 and 3.3.
The current status of the package is in development. From the [API reference](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24), there's full support and test for sections 3.1, 3.2 and 3.3 and experimental support for section 3.4.

@@ -17,0 +18,0 @@ ## Installation

'use strict'
export default class Volume {
constructor (modem) {
constructor (modem, id) {
this.modem = modem
this.id = id
}
/*
* Get the list of volumes
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/list-volumes
*
* @param {Object} opts Query params in the request (optional)
* @return {Promise} Promise returning the result as a list of volumes
*/
list (opts) {
const call = {
path: '/volumes',
method: 'GET',
options: opts,
statusCodes: {
200: true,
500: 'server error'
}
}
return new Promise((resolve, reject) => {
this.modem.dial(call, (err, result) => {
if (err) return reject(err)
resolve(result.Volumes.map((conf) => {
let volume = new Volume(this.modem, conf.Name)
return Object.assign(volume, conf)
}))
})
})
}
/*
* Create an volume
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/create-a-volume
*
* @param {Object} opts Query params in the request (optional)
* @return {Promise} Promise return the new volume
*/
create (opts) {
const call = {
path: '/volumes/create?',
method: 'POST',
options: opts,
statusCodes: {
201: true,
500: 'server error'
}
}
return new Promise((resolve, reject) => {
this.modem.dial(call, (err, conf) => {
if (err) return reject(err)
let volume = new Volume(this.modem, conf.Name)
resolve(Object.assign(volume, conf))
})
})
}
/*
* Get low-level information on a volume
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/inspect-a-volume
* The reason why this module isn't called inspect is because that interferes with the inspect utility of node.
*
* @param {Object} opts Query params in the request (optional)
* @param {String} id ID of the volume to inspect, if it's not set, use the id of the object (optional)
* @return {Promise} Promise return the new volume
*/
status (opts, id) {
[ opts, id ] = this.__processArguments(opts, id)
const call = {
path: `/volumes/${id}?`,
method: 'GET',
options: opts,
statusCodes: {
200: true,
404: 'no such volume',
500: 'server error'
}
}
return new Promise((resolve, reject) => {
this.modem.dial(call, (err, conf) => {
if (err) return reject(err)
let volume = new Volume(this.modem, id)
resolve(Object.assign(volume, conf))
})
})
}
/*
* Remove an volume from the filesystem
* https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/remove-a-volume
*
* @param {Object} opts Query params in the request (optional)
* @param {String} id ID of the volume to inspect, if it's not set, use the id of the object (optional)
* @return {Promise} Promise return the new volume
*/
remove (opts, id) {
[ opts, id ] = this.__processArguments(opts, id)
const call = {
path: `/volumes/${id}?`,
method: 'DELETE',
options: opts,
statusCodes: {
204: true,
404: 'no such volume',
409: 'conflict',
500: 'server error'
}
}
return new Promise((resolve, reject) => {
this.modem.dial(call, (err, res) => {
if (err) return reject(err)
resolve(res)
})
})
}
__processArguments (opts, id) {
if (typeof opts === "string" && !id) {
id = opts
}
if (!id && this.id) {
id = this.id
}
if (!opts) opts = {};
return [ opts, id ]
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc