fix(core): update

This commit is contained in:
2018-07-17 08:39:37 +02:00
parent 1d0c4c3cf9
commit 7a80718d27
6 changed files with 472 additions and 16 deletions

View File

@ -1,2 +1 @@
import * as plugins from './dockersock.plugins';

View File

@ -3,8 +3,11 @@ import { DockerHost } from './docker.classes.host';
export class DockerContainer {
static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
const result = [];
await dockerHostArg.request('GET', '/containers/json')
const result: DockerContainer[] = [];
const response = await dockerHostArg.request('GET', '/containers/json');
for(const containerResult in response.body) {
result.push(new DockerContainer());
}
return result;
}
}

View File

@ -1,5 +1,5 @@
import * as plugins from "./dockersock.plugins";
import { DockerContainer } from "./docker.classes.container";
import * as plugins from './dockersock.plugins';
import { DockerContainer } from './docker.classes.container';
export class DockerHost {
/**
@ -16,7 +16,7 @@ export class DockerHost {
* the constructor to instantiate a new docker sock instance
* @param pathArg
*/
constructor(pathArg: string = "http://unix:/var/run/docker.sock:") {
constructor(pathArg: string = 'http://unix:/var/run/docker.sock:') {
this.sockPath = pathArg;
}
@ -27,7 +27,7 @@ export class DockerHost {
*/
auth(registryArg: string, userArg: string, passArg: string) {
let done = plugins.smartpromise.defer();
this.request("POST", "");
this.request('POST', '');
return done.promise;
}
@ -43,16 +43,16 @@ export class DockerHost {
* fire a request
*/
async request(methodArg: string, routeArg: string, dataArg = {}) {
const requestUrl = `${this.sockPath}${routeArg}`
const requestUrl = `${this.sockPath}${routeArg}`;
console.log(requestUrl);
const response = await plugins.smartrequest.request(requestUrl, {
method: methodArg,
headers: {
"Content-Type": "application/json",
"Host": "docker.sock"
'Content-Type': 'application/json',
Host: 'docker.sock'
},
requestBody: dataArg
});
return response
return response;
}
}

View File

@ -11,4 +11,4 @@ export class DockerImage {
const resultingImage = new DockerImage();
return resultingImage;
}
}
}