Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
04bb3b9ed0 | |||
29e502a32e | |||
75a118183e | |||
aa1fe594e8 | |||
cf761e19bf | |||
af7590c8de | |||
ee2e4fb856 | |||
ff5cecb07e | |||
e50b028c00 | |||
867dda8e7c | |||
d12d595f21 | |||
6117228ea4 | |||
b6b584f808 | |||
48fe6ce0a8 | |||
55acb39071 | |||
f7b17a4684 | |||
d95f6c8e7f | |||
001cdadb6b | |||
82655623d1 | |||
ea117bc391 | |||
57594728df | |||
8430a4d6e0 | |||
7f38868510 | |||
7a80718d27 |
22
.gitignore
vendored
22
.gitignore
vendored
@ -1,4 +1,22 @@
|
|||||||
.yarn/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
117
.gitlab-ci.yml
117
.gitlab-ci.yml
@ -1,62 +1,119 @@
|
|||||||
image: hosttoday/ht-docker-dbase:npmci
|
# gitzone ci_default
|
||||||
services:
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
- docker:dind
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .yarn/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
- trigger
|
- release
|
||||||
- pages
|
- metadata
|
||||||
|
|
||||||
before_script:
|
# ====================
|
||||||
- npmci prepare docker-gitlab
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
test:
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- priv
|
- notpriv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish npm
|
- npmci node install lts
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- priv
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
stage: metadata
|
||||||
stage: trigger
|
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- docker
|
||||||
- priv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
stage: pages
|
services:
|
||||||
|
- docker:18-dind
|
||||||
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add npmpage
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci command npmpage --publish gitlab
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
57
README.md
57
README.md
@ -1,52 +1,41 @@
|
|||||||
# @mojoio/dockersock
|
# @mojoio/docker
|
||||||
|
|
||||||
easy communication with docker remote api from node, TypeScript ready
|
unofficial docker engine api abstraction package written in TypeScript
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/dockersock)
|
- [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/docker)
|
||||||
[](https://GitLab.com/mojoio/dockersock)
|
- [gitlab.com (source)](https://gitlab.com/mojoio/docker)
|
||||||
[](https://github.com/mojoio/dockersock)
|
- [github.com (source mirror)](https://github.com/mojoio/docker)
|
||||||
[](https://mojoio.gitlab.io/dockersock/)
|
- [docs (typedoc)](https://mojoio.gitlab.io/docker/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
[](https://gitlab.com/mojoio/docker/commits/master)
|
||||||
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
[](https://gitlab.com/mojoio/docker/commits/master)
|
||||||
[](https://www.npmjs.com/package/dockersock)
|
[](https://www.npmjs.com/package/@mojoio/docker)
|
||||||
[](https://david-dm.org/mojoio/dockersock)
|
[](https://snyk.io/test/npm/@mojoio/docker)
|
||||||
[](https://www.bithound.io/github/mojoio/dockersock/master/dependencies/npm)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/mojoio/dockersock)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://prettier.io/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```TypeScript
|
```typescript
|
||||||
import {Dockersock} from "dockersock"; // require Dockersock class
|
import { DockerHost } from '@mojoio/docker'; // require Dockersock class
|
||||||
|
|
||||||
let myDockersock = new Dockersock(); // optional: you can pass a domain to the contructor, defaults to /var/run/docker.sock
|
const run = async () => {
|
||||||
|
const myDockerHost = new DockerHost(); // optional: you can pass a domain to the contructor, defaults to /var/run/docker.sock
|
||||||
|
|
||||||
myDockersock.listContainers() // promise, resolve gets container data
|
const containers = await myDockerHost.getContainers(); // promise, resolve with an array of DockerContainers
|
||||||
myDockersock.listContainersDetailed() // promise, resolve gets more detailed container data (by combining several requests internally)
|
};
|
||||||
myDockersock.listContainersRunning() // promise, resolve gets container data for currently running containers
|
|
||||||
myDockersock.listContainersStopped() // promise, resolve gets container data for stopped containers
|
|
||||||
|
|
||||||
myDockersock.startContainer({ // starts a already present container
|
|
||||||
name: "somecontainername"
|
|
||||||
})
|
|
||||||
|
|
||||||
myDockersock.newContainer({ // start new Container, equals "docker run" shell command
|
|
||||||
image: "someimagetag"
|
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://mojo.io)
|
[](https://maintainedby.lossless.com)
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
{
|
{
|
||||||
"npmts": {
|
|
||||||
"mode": "default",
|
|
||||||
"coverageTreshold": 10
|
|
||||||
},
|
|
||||||
"npmdocker": {
|
"npmdocker": {
|
||||||
"baseImage": "hosttoday/ht-docker-node:npmci",
|
"baseImage": "hosttoday/ht-docker-node:npmci",
|
||||||
"command":
|
"command": "(ls -a && rm -r node_modules && yarn global add npmts && yarn install && npmts)",
|
||||||
"(ls -a && rm -r node_modules && yarn global add npmts && yarn install && npmts)",
|
|
||||||
"dockerSock": true
|
"dockerSock": true
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": ["npmts", "npmdocker"]
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public",
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "mojoio",
|
||||||
|
"gitrepo": "docker",
|
||||||
|
"shortDescription": "unofficial docker engine api abstraction package written in TypeScript",
|
||||||
|
"npmPackagename": "@mojoio/docker",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1687
package-lock.json
generated
1687
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/docker",
|
"name": "@mojoio/docker",
|
||||||
"version": "1.0.24",
|
"version": "1.0.36",
|
||||||
"description": "easy communication with docker remote api from node, TypeScript ready",
|
"description": "easy communication with docker remote api from node, TypeScript ready",
|
||||||
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tsrun test/test.ts",
|
"test": "tstest test/",
|
||||||
"build": "(npmts --notest && npmdocker)"
|
"build": "tsbuild"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -26,14 +27,30 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.1",
|
"@pushrocks/lik": "^3.0.10",
|
||||||
"@pushrocks/smartlog": "^2.0.1",
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@pushrocks/smartrequest": "^1.0.17",
|
"@pushrocks/smartrequest": "^1.1.16",
|
||||||
"rxjs": "^6.2.2"
|
"rxjs": "^6.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@pushrocks/tapbundle": "^3.0.1"
|
"@gitzone/tsbuild": "^2.1.11",
|
||||||
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
|
"@gitzone/tstest": "^1.0.24",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.11",
|
||||||
|
"@types/node": "^12.7.1",
|
||||||
|
"tslint": "^5.18.0",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"private": false
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
19
test/test.ts
19
test/test.ts
@ -13,16 +13,17 @@ tap.test('should list containers', async () => {
|
|||||||
console.log(containers);
|
console.log(containers);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
tap.skip.test('should pull an image from imagetag', async () => {
|
||||||
tap.test('should pull an image from imagetag', async () => {
|
// await testDockerHost.pullImage('hosttoday/ht-docker-node:npmci');
|
||||||
await testDockerHost.pullImage('hosttoday/ht-docker-node:npmci');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.skip.test('should return a change Objservable', async () => {
|
tap.test('should return a change Objservable', async tools => {
|
||||||
let myObservable = testDockerHost.getChangeObservable();
|
const testObservable = await testDockerHost.getEventObservable();
|
||||||
testDockerHost.endRequests();
|
const subscription = testObservable.subscribe(changeObject => {
|
||||||
let testPromise = observableToPromise(myObservable);
|
console.log(changeObject);
|
||||||
return await expect(testPromise).to.eventually.be.fulfilled;
|
});
|
||||||
}); */
|
await tools.delayFor(2000);
|
||||||
|
subscription.unsubscribe();
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1,2 +1 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './dockersock.plugins';
|
||||||
|
|
||||||
|
@ -1,10 +1,77 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './dockersock.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
import { DockerHost } from './docker.classes.host';
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
export class DockerContainer {
|
export class DockerContainer {
|
||||||
static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
|
// ======
|
||||||
const result = [];
|
// STATIC
|
||||||
await dockerHostArg.request('GET', '/containers/json')
|
// ======
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get all containers
|
||||||
|
*/
|
||||||
|
public static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
|
||||||
|
const result: DockerContainer[] = [];
|
||||||
|
const response = await dockerHostArg.request('GET', '/containers/json');
|
||||||
|
|
||||||
|
// TODO: Think about getting the config by inpsecting the container
|
||||||
|
for (const containerResult of response.body) {
|
||||||
|
result.push(new DockerContainer(containerResult));
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets an container by Id
|
||||||
|
* @param containerId
|
||||||
|
*/
|
||||||
|
public static async getContainerById(containerId: string) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a container
|
||||||
|
*/
|
||||||
|
public static async create(creationSpecifier: interfaces.IContainerCreationSpecifier) {}
|
||||||
|
|
||||||
|
// ========
|
||||||
|
// INSTANCE
|
||||||
|
// ========
|
||||||
|
|
||||||
|
constructor(dockerContainerObjectArg: any) {
|
||||||
|
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
|
||||||
|
this[keyArg] = dockerContainerObjectArg[keyArg];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Id: string;
|
||||||
|
Names: string[];
|
||||||
|
Image: string;
|
||||||
|
ImageID: string;
|
||||||
|
Command: string;
|
||||||
|
Created: number;
|
||||||
|
Ports: interfaces.TPorts;
|
||||||
|
Labels: interfaces.TLabels;
|
||||||
|
State: string;
|
||||||
|
Status: string;
|
||||||
|
HostConfig: any;
|
||||||
|
NetworkSettings: {
|
||||||
|
Networks: {
|
||||||
|
[key: string]: {
|
||||||
|
IPAMConfig: any;
|
||||||
|
Links: any;
|
||||||
|
Aliases: any;
|
||||||
|
NetworkID: string;
|
||||||
|
EndpointID: string;
|
||||||
|
Gateway: string;
|
||||||
|
IPAddress: string;
|
||||||
|
IPPrefixLen: number;
|
||||||
|
IPv6Gateway: string;
|
||||||
|
GlobalIPv6Address: string;
|
||||||
|
GlobalIPv6PrefixLen: number;
|
||||||
|
MacAddress: string;
|
||||||
|
DriverOpts: any;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Mounts: any;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from "./dockersock.plugins";
|
import * as plugins from './dockersock.plugins';
|
||||||
import { DockerContainer } from "./docker.classes.container";
|
import { DockerContainer } from './docker.classes.container';
|
||||||
|
|
||||||
export class DockerHost {
|
export class DockerHost {
|
||||||
/**
|
/**
|
||||||
@ -16,7 +16,7 @@ export class DockerHost {
|
|||||||
* the constructor to instantiate a new docker sock instance
|
* the constructor to instantiate a new docker sock instance
|
||||||
* @param pathArg
|
* @param pathArg
|
||||||
*/
|
*/
|
||||||
constructor(pathArg: string = "http://unix:/var/run/docker.sock:") {
|
constructor(pathArg: string = 'http://unix:/var/run/docker.sock:') {
|
||||||
this.sockPath = pathArg;
|
this.sockPath = pathArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ export class DockerHost {
|
|||||||
*/
|
*/
|
||||||
auth(registryArg: string, userArg: string, passArg: string) {
|
auth(registryArg: string, userArg: string, passArg: string) {
|
||||||
let done = plugins.smartpromise.defer();
|
let done = plugins.smartpromise.defer();
|
||||||
this.request("POST", "");
|
this.request('POST', '');
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,20 +39,56 @@ export class DockerHost {
|
|||||||
return containerArray;
|
return containerArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
|
||||||
|
const response = await this.requestStreaming('GET', '/events');
|
||||||
|
return plugins.rxjs.Observable.create(observer => {
|
||||||
|
response.on('data', data => {
|
||||||
|
const eventString = data.toString();
|
||||||
|
try {
|
||||||
|
const eventObject = JSON.parse(eventString);
|
||||||
|
observer.next(eventObject);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
response.emit('end');
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fire a request
|
* fire a request
|
||||||
*/
|
*/
|
||||||
async request(methodArg: string, routeArg: string, dataArg = {}) {
|
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, {
|
const response = await plugins.smartrequest.request(requestUrl, {
|
||||||
method: methodArg,
|
method: methodArg,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
'Content-Type': 'application/json',
|
||||||
"Host": "docker.sock"
|
Host: 'docker.sock'
|
||||||
},
|
},
|
||||||
requestBody: dataArg
|
requestBody: dataArg
|
||||||
});
|
});
|
||||||
return response
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) {
|
||||||
|
const requestUrl = `${this.sockPath}${routeArg}`;
|
||||||
|
const response = await plugins.smartrequest.request(
|
||||||
|
requestUrl,
|
||||||
|
{
|
||||||
|
method: methodArg,
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'application/json',
|
||||||
|
Host: 'docker.sock'
|
||||||
|
},
|
||||||
|
requestBody: null
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
console.log(response.statusCode);
|
||||||
|
console.log(response.body);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,37 @@ import * as plugins from './dockersock.plugins';
|
|||||||
import { DockerHost } from './docker.classes.host';
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
export class DockerImage {
|
export class DockerImage {
|
||||||
|
// STATIC
|
||||||
|
public static async createFromRegistry(
|
||||||
|
dockerHostArg: DockerHost,
|
||||||
|
dockerImageTag
|
||||||
|
): Promise<DockerImage> {
|
||||||
|
const resultingImage = new DockerImage();
|
||||||
|
|
||||||
|
return resultingImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async createFromExistingImage(dockerHostArg: DockerHost, dockerImageTag) {}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
/**
|
/**
|
||||||
* the tags for an image
|
* the tags for an image
|
||||||
*/
|
*/
|
||||||
tags: string[] = [];
|
public tags: string[] = [];
|
||||||
|
|
||||||
static async createFromRegsitry(dockerHostArg: DockerHost): Promise<DockerImage> {
|
/**
|
||||||
const resultingImage = new DockerImage();
|
* returns a boolean wether the image has a upstream image
|
||||||
return resultingImage;
|
*/
|
||||||
|
public isUpstreamImage(): boolean {
|
||||||
|
// TODO: implement isUpastreamImage
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public async pullLatestImageFromRegistry(): Promise<boolean> {
|
||||||
|
// TODO: implement pullLatestImageFromRegistry
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from './dockersock.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
|
export class DockerNetwork {}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from './dockersock.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
|
export class DockerService {}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
import 'typings-global';
|
// @pushrocks scope
|
||||||
export import smartlog = require('@pushrocks/smartlog');
|
import * as lik from '@pushrocks/lik';
|
||||||
export import lik = require('@pushrocks/lik');
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
export import smartpromise = require('@pushrocks/smartpromise');
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
export import smartrequest = require('@pushrocks/smartrequest');
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
export import rxjs = require('rxjs');
|
|
||||||
|
export { lik, smartlog, smartpromise, smartrequest };
|
||||||
|
|
||||||
|
// third party
|
||||||
|
import * as rxjs from 'rxjs';
|
||||||
|
|
||||||
|
export { rxjs };
|
||||||
|
@ -1 +1,5 @@
|
|||||||
export { DockerHost } from './docker.classes.host';
|
export * from './docker.classes.host';
|
||||||
|
export * from './docker.classes.container';
|
||||||
|
export * from './docker.classes.image';
|
||||||
|
export * from './docker.classes.network';
|
||||||
|
export * from './docker.classes.service';
|
||||||
|
7
ts/interfaces/container.ts
Normal file
7
ts/interfaces/container.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { DockerNetwork } from '../docker.classes.network';
|
||||||
|
|
||||||
|
export interface IContainerCreationSpecifier {
|
||||||
|
hostname: string;
|
||||||
|
domainName: string;
|
||||||
|
networks?: DockerNetwork[];
|
||||||
|
}
|
3
ts/interfaces/index.ts
Normal file
3
ts/interfaces/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from './container';
|
||||||
|
export * from './label';
|
||||||
|
export * from './port';
|
2
ts/interfaces/label.ts
Normal file
2
ts/interfaces/label.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// tslint:disable-next-line: interface-over-type-literal
|
||||||
|
export type TLabels = { [key: string]: string };
|
6
ts/interfaces/port.ts
Normal file
6
ts/interfaces/port.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export interface IPort {
|
||||||
|
PrivatePort: 80;
|
||||||
|
Type: 'tcp';
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TPorts = IPort[];
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
|
}
|
Reference in New Issue
Block a user