Merge pull request #960 from balena-io/update-dockerode-types

types: Upgrade dockerode types, and remove fixes which are superceded
This commit is contained in:
CameronDiver 2019-04-08 12:15:03 +01:00 committed by GitHub
commit fe32d76f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 37 deletions

6
package-lock.json generated
View File

@ -102,9 +102,9 @@
"dev": true "dev": true
}, },
"@types/dockerode": { "@types/dockerode": {
"version": "2.5.10", "version": "2.5.13",
"resolved": "https://registry.npmjs.org/@types/dockerode/-/dockerode-2.5.10.tgz", "resolved": "https://registry.npmjs.org/@types/dockerode/-/dockerode-2.5.13.tgz",
"integrity": "sha512-Aiy0iYuWudPOHNc69LYHCfvjzvJ0KaRIkM9o6unMQSOh7rp7/KydUVb5KRGRSoRk9V7uWv9IssEi/ahF4yaOkA==", "integrity": "sha512-TgSP2nhCZgKOYcuMyuUs1SvLWZCd20z6SczPadLL11iCEEMDiblE23cwIyc1BR7FPpntwT9Z+IcdFNAXUAKmKQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "*" "@types/node": "*"

View File

@ -31,7 +31,7 @@
"devDependencies": { "devDependencies": {
"@types/bluebird": "^3.5.25", "@types/bluebird": "^3.5.25",
"@types/common-tags": "^1.8.0", "@types/common-tags": "^1.8.0",
"@types/dockerode": "^2.5.10", "@types/dockerode": "^2.5.13",
"@types/event-stream": "^3.3.34", "@types/event-stream": "^3.3.34",
"@types/express": "^4.11.1", "@types/express": "^4.11.1",
"@types/knex": "^0.14.14", "@types/knex": "^0.14.14",

View File

@ -203,20 +203,13 @@ export class Volumes {
} }
private async listWithBothLabels(): Promise<Dockerode.VolumeInspectInfo[]> { private async listWithBothLabels(): Promise<Dockerode.VolumeInspectInfo[]> {
// We have to cast the listVolumes call from any[] to any below, until the const [legacyResponse, currentResponse] = await Promise.all([
// relevant PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/32383
// is merged and released - we can also replace Dockerode here with the Docker
// DockerUtils class imported above
const [legacyResponse, currentResponse]: [
Dockerode.VolumeInfoList,
Dockerode.VolumeInfoList
] = await Promise.all([
this.docker.listVolumes({ this.docker.listVolumes({
filters: { label: ['io.resin.supervised'] }, filters: { label: ['io.resin.supervised'] },
}) as Promise<any>, }),
this.docker.listVolumes({ this.docker.listVolumes({
filters: { label: ['io.balena.supervised'] }, filters: { label: ['io.balena.supervised'] },
}) as Promise<any>, }),
]); ]);
const legacyVolumes = _.get(legacyResponse, 'Volumes', []); const legacyVolumes = _.get(legacyResponse, 'Volumes', []);

View File

@ -21,27 +21,4 @@ declare module 'dockerode' {
Healthcheck?: DockerHealthcheck; Healthcheck?: DockerHealthcheck;
StopTimeout?: number; StopTimeout?: number;
} }
// TODO: Once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/32383
// is merged and released, remove this and VolumeInfoList
export interface VolumeInspectInfo {
Name: string;
Driver: string;
Mountpoint: string;
Status?: { [key: string]: string };
Labels: { [key: string]: string };
Scope: 'local' | 'global';
// Field is always present, but sometimes is null
Options: { [key: string]: string } | null;
// Field is sometimes present, and sometimes null
UsageData?: {
Size: number;
RefCount: number;
} | null;
}
export interface VolumeInfoList {
Volumes: Dockerode.VolumeInspectInfo[];
Warnings: string[];
}
} }