Merge pull request #19549 from LazarusX/fix_dockerode_type

Update Dockerode options types
This commit is contained in:
Nathan Shively-Sanders
2017-09-10 17:27:55 -07:00
committed by GitHub
2 changed files with 30 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import * as Docker from 'dockerode';
import * as fs from 'fs';
// Code samples from Dockerode 'Getting started'
const docker = new Docker();
@@ -25,6 +26,24 @@ const docker6 = new Docker({
});
const docker7 = new Docker({
host: '192.168.1.10',
port: process.env.DOCKER_PORT || 2375,
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('key.pem'),
version: 'v1.25' // required when Docker >= v1.13, https://docs.docker.com/engine/api/version-history/
});
const docker8 = new Docker({
protocol: 'https', // you can enforce a protocol
host: '192.168.1.10',
port: process.env.DOCKER_PORT || 2375,
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('key.pem')
});
const docker9 = new Docker({
Promise
});

View File

@@ -1,8 +1,9 @@
// Type definitions for dockerode 2.4
// Type definitions for dockerode 2.5
// Project: https://github.com/apocas/dockerode
// Definitions by: Carl Winkler <https://github.com/seikho>
// Nicolas Laplante <https://github.com/nlaplante>
// ByeongHun Yoo <https://github.com/isac322>
// Ray Fang <https://github.com/lazarusx>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -655,15 +656,21 @@ declare namespace Dockerode {
};
}
interface KeyObject {
pem: string | Buffer;
passphrase?: string;
}
interface DockerOptions {
socketPath?: string;
host?: string;
port?: number | string;
ca?: string;
cert?: string;
key?: string;
ca?: string | string[] | Buffer | Buffer[];
cert?: string | string[] | Buffer | Buffer[];
key?: string | string[] | Buffer | Buffer[] | KeyObject[];
protocol?: "https" | "http";
timeout?: number;
version?: string;
Promise?: typeof Promise;
}