swarmerode
Advanced tools
Comparing version 2.2.3 to 2.2.4-0
18
index.js
@@ -6,3 +6,2 @@ 'use strict' | ||
var exists = require('101/exists') | ||
var cache = require('./cache') | ||
var Consul = require('./consul') | ||
@@ -32,11 +31,8 @@ | ||
Swarmerode.prototype.swarmInfo = function (cb) { | ||
var self = this | ||
cache.handleCache('info', function (evalCb) { | ||
self.info(function (err, info) { | ||
if (err) { return evalCb(err) } | ||
info.parsedSystemStatus = Swarmerode._parseSwarmSystemStatus(info.SystemStatus) | ||
debug('swarm info %j', info) | ||
evalCb(null, info) | ||
}) | ||
}, cb) | ||
this.info(function (err, info) { | ||
if (err) { return cb(err) } | ||
info.parsedSystemStatus = Swarmerode._parseSwarmSystemStatus(info.SystemStatus) | ||
debug('swarm info %j', info) | ||
cb(null, info) | ||
}) | ||
} | ||
@@ -98,2 +94,3 @@ | ||
Host: systemStatus.shift()[1], | ||
ID: systemStatus.shift()[1], | ||
Status: systemStatus.shift()[1], | ||
@@ -104,3 +101,2 @@ Containers: parseInt(systemStatus.shift()[1], 10), | ||
Labels: parseLabels(systemStatus.shift()[1]), | ||
Error: systemStatus.shift()[1], | ||
UpdatedAt: systemStatus.shift()[1], | ||
@@ -107,0 +103,0 @@ ServerVersion: systemStatus.shift()[1] |
{ | ||
"name": "swarmerode", | ||
"version": "2.2.3", | ||
"version": "2.2.4-0", | ||
"description": "Swarm Client Extension for Dockerode", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,6 +11,2 @@ # swarmerode | ||
## Configuration | ||
The environment variable `SWARMERODE_CACHE_LENGTH` can be set to the number of milliseconds you'd like the docker info calls to be cached for. | ||
## Example | ||
@@ -17,0 +13,0 @@ |
@@ -18,3 +18,3 @@ 'use strict' | ||
} | ||
var nodeName = hostInfo.nodeName || (' swarm-agent-0' + hostIndex) | ||
var nodeName = hostInfo.nodeName || (' ip-swarm-agent-0' + hostIndex) | ||
var host = hostInfo.host || ('10.0.0.' + hostIndex + ':4242') | ||
@@ -25,2 +25,3 @@ var numContainers = hostInfo.Containers || '1' | ||
[ nodeName, host ], | ||
[ ' └ ID', '' + Math.random() ], | ||
[ ' └ Status', 'Healthy' ], | ||
@@ -31,3 +32,2 @@ [ ' └ Containers', numContainers ], | ||
[ ' └ Labels', labelString ], | ||
[ ' └ Error', '(none)' ], | ||
[ ' └ UpdatedAt', '2016-03-08T19:02:41Z' ], | ||
@@ -53,9 +53,8 @@ [ ' └ ServerVersion', '1.10.2' ] | ||
return { | ||
ServerVersion: 'swarm/1.1.2', | ||
ID: '', | ||
Containers: 25, | ||
ContainersRunning: 5, | ||
ID: 'needed', | ||
Containers: 630, | ||
ContainersRunning: 159, | ||
ContainersPaused: 0, | ||
ContainersStopped: 20, | ||
Images: 46, | ||
ContainersStopped: 471, | ||
Images: 409, | ||
Driver: '', | ||
@@ -66,2 +65,3 @@ DriverStatus: null, | ||
SwapLimit: true, | ||
KernelMemory: false, | ||
CpuCfsPeriod: true, | ||
@@ -78,7 +78,8 @@ CpuCfsQuota: true, | ||
NGoroutines: 0, | ||
SystemTime: '2016-03-08T19:02:46.450133201Z', | ||
SystemTime: '2016-07-21T22:32:59.381546165Z', | ||
ExecutionDriver: '', | ||
LoggingDriver: '', | ||
CgroupDriver: '', | ||
NEventsListener: 1, | ||
KernelVersion: '3.13.0-77-generic', | ||
KernelVersion: '3.13.0-79-generic', | ||
OperatingSystem: 'linux', | ||
@@ -89,4 +90,4 @@ OSType: '', | ||
RegistryConfig: null, | ||
NCPU: 4, | ||
MemTotal: 17580879052, | ||
NCPU: 62, | ||
MemTotal: 179278903900, | ||
DockerRootDir: '', | ||
@@ -96,9 +97,11 @@ HttpProxy: '', | ||
NoProxy: '', | ||
Name: '005f6adac88b', | ||
Name: '4e86b7819c69', | ||
Labels: null, | ||
ExperimentalBuild: false, | ||
ServerVersion: 'swarm/1.2.3', | ||
ClusterStore: '', | ||
ClusterAdvertise: '', | ||
SecurityOptions: null, | ||
SystemStatus: SystemStatus | ||
} | ||
} |
@@ -6,3 +6,2 @@ 'use strict' | ||
var sinon = require('sinon') | ||
var cache = require('../cache') | ||
@@ -115,11 +114,2 @@ var exampleHosts = [ '10.0.0.1:4242', '10.0.0.2:4242', '10.0.0.3:4242' ] | ||
describe('swarmInfo', function () { | ||
beforeEach(function () { | ||
sinon.stub(cache, 'handleCache', function (key, check, cb) { | ||
check(cb) | ||
}) | ||
}) | ||
afterEach(function () { | ||
cache.handleCache.restore() | ||
}) | ||
it('should call the class info function', function (done) { | ||
@@ -142,9 +132,2 @@ sinon.spy(MockClass.prototype, 'info') | ||
}) | ||
it('should call cache with cb', function () { | ||
var handleCb = sinon.stub() | ||
instance.swarmInfo(handleCb) | ||
sinon.assert.calledOnce(cache.handleCache) | ||
sinon.assert.calledWith(cache.handleCache, 'info', sinon.match.func, handleCb) | ||
}) | ||
}) | ||
@@ -204,2 +187,3 @@ | ||
assert.isNumber(out.ParsedNodes['cool.node'].Containers) | ||
assert.isString(out.ParsedNodes['cool.node'].ID) | ||
assert.equal(out.ParsedNodes['cool.node'].Containers, 100) | ||
@@ -209,3 +193,2 @@ assert.equal(out.ParsedNodes['cool.node'].Status, 'Healthy') | ||
assert.equal(out.ParsedNodes['cool.node'].ReservedMem, '10 GiB / 1.021 GiB') | ||
assert.equal(out.ParsedNodes['cool.node'].Error, '(none)') | ||
assert.equal(out.ParsedNodes['cool.node'].UpdatedAt, '2016-03-08T19:02:41Z') | ||
@@ -217,2 +200,3 @@ assert.equal(out.ParsedNodes['cool.node'].Labels.env, 'test') | ||
assert.isNumber(out.ParsedNodes['un.cool.node'].Containers) | ||
assert.isString(out.ParsedNodes['un.cool.node'].ID) | ||
assert.equal(out.ParsedNodes['un.cool.node'].Status, 'Healthy') | ||
@@ -222,3 +206,2 @@ assert.equal(out.ParsedNodes['un.cool.node'].Containers, 4) | ||
assert.equal(out.ParsedNodes['un.cool.node'].ReservedMem, '10 GiB / 1.021 GiB') | ||
assert.equal(out.ParsedNodes['un.cool.node'].Error, '(none)') | ||
assert.equal(out.ParsedNodes['un.cool.node'].UpdatedAt, '2016-03-08T19:02:41Z') | ||
@@ -253,2 +236,3 @@ assert.equal(out.ParsedNodes['un.cool.node'].Labels.env, 'prod') | ||
assert.isNumber(out.ParsedNodes['cool.node'].Containers) | ||
assert.isString(out.ParsedNodes['cool.node'].ID) | ||
assert.equal(out.ParsedNodes['cool.node'].Containers, 100) | ||
@@ -258,3 +242,2 @@ assert.equal(out.ParsedNodes['cool.node'].Status, 'Healthy') | ||
assert.equal(out.ParsedNodes['cool.node'].ReservedMem, '10 GiB / 1.021 GiB') | ||
assert.equal(out.ParsedNodes['cool.node'].Error, '(none)') | ||
assert.equal(out.ParsedNodes['cool.node'].UpdatedAt, '2016-03-08T19:02:41Z') | ||
@@ -261,0 +244,0 @@ assert.equal(out.ParsedNodes['cool.node'].Labels.env, 'test') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
8
24199
10
602
1
30