Compare commits
91 Commits
Author | SHA1 | Date | |
---|---|---|---|
a965647c1f | |||
db88c7f86c | |||
3f18cb68bf | |||
dae3b59e3b | |||
53062e70d4 | |||
3e70dc465b | |||
49445d93c6 | |||
4f838837f8 | |||
c76968bbe8 | |||
6c5e5644b1 | |||
5cf80944fe | |||
cdb69c5f17 | |||
178c1d2df1 | |||
43d9da808b | |||
15f5c38eb0 | |||
225c1be14c | |||
44f2aab2f6 | |||
b69315f1d3 | |||
7d20804986 | |||
0aab639fbd | |||
794bb60dfc | |||
b182a379af | |||
5c6c06dee6 | |||
a48e1e035e | |||
8836c06b56 | |||
7af8e0739b | |||
684185e951 | |||
21e6fff3fb | |||
83c49a6234 | |||
ad67849d45 | |||
0e4e07a912 | |||
1fbc09f557 | |||
d6201b864c | |||
ea5e552192 | |||
1afe5c6e16 | |||
eb0dc96dbd | |||
55f45b1c3a | |||
87ff0f01bb | |||
dd1939d7b2 | |||
5a2a5f1248 | |||
9767b8767a | |||
546e139b46 | |||
28d70bb49f | |||
b71f134abd | |||
968b3c7449 | |||
d9558f7843 | |||
19e67ffdcc | |||
e983b66c28 | |||
c79f6a698f | |||
0ef098e9c8 | |||
d56350ff28 | |||
a4dc4e7950 | |||
424e911804 | |||
b5c4727bae | |||
b6f3fbf8a9 | |||
7241e7a8fd | |||
ae37148ece | |||
65c37bdd6f | |||
6acbe30e2e | |||
eb6f7889d0 | |||
e39da5fee9 | |||
b07628bb0b | |||
5815f9b202 | |||
846ea9997e | |||
de54db33ad | |||
314cb692ac | |||
73f8ded3fe | |||
a28b10ac51 | |||
927e2e0acc | |||
c496405818 | |||
020737e21b | |||
fe3560caac | |||
b2a7e67868 | |||
f772ca15ef | |||
71cfad146f | |||
43b1c13256 | |||
2c8b17f029 | |||
c6521d9160 | |||
72c74e44b5 | |||
2fb628213d | |||
373a4e2eac | |||
a202d05e9c | |||
6e97a7d83c | |||
04bb3b9ed0 | |||
29e502a32e | |||
75a118183e | |||
aa1fe594e8 | |||
cf761e19bf | |||
af7590c8de | |||
ee2e4fb856 | |||
ff5cecb07e |
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
|
@ -1,5 +1,5 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -34,39 +34,11 @@ snyk:
|
|||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
sast:
|
|
||||||
stage: security
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
|
||||||
variables:
|
|
||||||
DOCKER_DRIVER: overlay2
|
|
||||||
allow_failure: true
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- docker run
|
|
||||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
|
||||||
--volume "$PWD:/code"
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
|
||||||
artifacts:
|
|
||||||
reports:
|
|
||||||
sast: gl-sast-report.json
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testSTABLE:
|
testStable:
|
||||||
image: hosttoday/ht-docker-dbase:npmci
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
@ -78,6 +50,18 @@ testSTABLE:
|
|||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
@ -94,19 +78,11 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm install
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume "$PWD":/code
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@ -122,13 +98,15 @@ trigger:
|
|||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
60
README.md
60
README.md
@ -1,52 +1,38 @@
|
|||||||
# @mojoio/dockersock
|
# @mojoio/docker
|
||||||
|
unofficial docker engine api abstraction package written in TypeScript
|
||||||
|
|
||||||
easy communication with docker remote api from node, TypeScript ready
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/docker)
|
||||||
## Availabililty
|
* [gitlab.com (source)](https://gitlab.com/mojoio/docker)
|
||||||
|
* [github.com (source mirror)](https://github.com/mojoio/docker)
|
||||||
[](https://www.npmjs.com/package/dockersock)
|
* [docs (typedoc)](https://mojoio.gitlab.io/docker/)
|
||||||
[](https://GitLab.com/mojoio/dockersock)
|
|
||||||
[](https://github.com/mojoio/dockersock)
|
|
||||||
[](https://mojoio.gitlab.io/dockersock/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
[](https://gitlab.com/mojoio/docker/commits/master)
|
||||||
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
[](https://gitlab.com/mojoio/docker/commits/master)
|
||||||
[](https://GitLab.com/mojoio/dockersock/commits/master)
|
[](https://www.npmjs.com/package/@mojoio/docker)
|
||||||
[](https://www.npmjs.com/package/dockersock)
|
[](https://snyk.io/test/npm/@mojoio/docker)
|
||||||
[](https://david-dm.org/mojoio/dockersock)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](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://prettier.io/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](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,13 +1,22 @@
|
|||||||
{
|
{
|
||||||
"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": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public",
|
"npmAccessLevel": "public",
|
||||||
"npmRegistryUrl": "registry.npmjs.org"
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
762
package-lock.json
generated
762
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/docker",
|
"name": "@mojoio/docker",
|
||||||
"version": "1.0.32",
|
"version": "1.0.78",
|
||||||
"description": "easy communication with docker remote api from node, TypeScript ready",
|
"description": "easy communication with docker remote api from node, TypeScript ready",
|
||||||
"private": false,
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -27,19 +27,36 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.10",
|
"@pushrocks/lik": "^3.0.11",
|
||||||
|
"@pushrocks/smartfile": "^7.0.4",
|
||||||
|
"@pushrocks/smartjson": "^3.0.8",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
|
"@pushrocks/smartnetwork": "^1.1.14",
|
||||||
|
"@pushrocks/smartpath": "^4.0.1",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@pushrocks/smartrequest": "^1.1.16",
|
"@pushrocks/smartrequest": "^1.1.26",
|
||||||
"rxjs": "^6.5.2"
|
"@pushrocks/smartstring": "^3.0.10",
|
||||||
|
"@pushrocks/smartversion": "^2.0.4",
|
||||||
|
"rxjs": "^6.5.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"@pushrocks/tapbundle": "^3.0.11",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^12.7.1",
|
"@types/node": "^12.7.4",
|
||||||
"tslint": "^5.18.0",
|
"tslint": "^5.19.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
11
scripts/testauth.ts
Normal file
11
scripts/testauth.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import * as docker from '../ts';
|
||||||
|
import * as smartstring from '@pushrocks/smartstring';
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
const dockerHost = new docker.DockerHost();
|
||||||
|
await docker.DockerImage.createFromRegistry(dockerHost, {
|
||||||
|
imageUrl: 'registry.gitlab.com/servezone/private/cloudly:latest'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
run();
|
98
test/test.ts
98
test/test.ts
@ -1,23 +1,53 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import { DockerHost } from '../ts/index';
|
import * as docker from '../ts/index';
|
||||||
|
|
||||||
let testDockerHost: DockerHost;
|
let testDockerHost: docker.DockerHost;
|
||||||
|
|
||||||
tap.test('should create a new Dockersock instance', async () => {
|
tap.test('should create a new Dockersock instance', async () => {
|
||||||
testDockerHost = new DockerHost();
|
testDockerHost = new docker.DockerHost('http://unix:/var/run/docker.sock:');
|
||||||
return expect(testDockerHost).to.be.instanceof(DockerHost);
|
return expect(testDockerHost).to.be.instanceof(docker.DockerHost);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should create a docker swarm', async () => {
|
||||||
|
await testDockerHost.activateSwarm();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Containers
|
||||||
tap.test('should list containers', async () => {
|
tap.test('should list containers', async () => {
|
||||||
const containers = await testDockerHost.getContainers();
|
const containers = await testDockerHost.getContainers();
|
||||||
console.log(containers);
|
console.log(containers);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.skip.test('should pull an image from imagetag', async () => {
|
// Networks
|
||||||
// await testDockerHost.pullImage('hosttoday/ht-docker-node:npmci');
|
tap.test('should list networks', async () => {
|
||||||
|
const networks = await testDockerHost.getNetworks();
|
||||||
|
console.log(networks);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should return a change Objservable', async tools => {
|
tap.test('should create a network', async () => {
|
||||||
|
const newNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
|
||||||
|
Name: 'webgateway'
|
||||||
|
});
|
||||||
|
expect(newNetwork).to.be.instanceOf(docker.DockerNetwork);
|
||||||
|
expect(newNetwork.Name).to.equal('webgateway');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should remove a network', async () => {
|
||||||
|
const webgateway = await docker.DockerNetwork.getNetworkByName(testDockerHost, 'webgateway');
|
||||||
|
await webgateway.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Images
|
||||||
|
tap.test('should pull an image from imagetag', async () => {
|
||||||
|
const image = await docker.DockerImage.createFromRegistry(testDockerHost, {
|
||||||
|
imageUrl: 'hosttoday/ht-docker-node',
|
||||||
|
imageTag: 'alpine'
|
||||||
|
});
|
||||||
|
expect(image).to.be.instanceOf(docker.DockerImage);
|
||||||
|
console.log(image);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should return a change Observable', async tools => {
|
||||||
const testObservable = await testDockerHost.getEventObservable();
|
const testObservable = await testDockerHost.getEventObservable();
|
||||||
const subscription = testObservable.subscribe(changeObject => {
|
const subscription = testObservable.subscribe(changeObject => {
|
||||||
console.log(changeObject);
|
console.log(changeObject);
|
||||||
@ -26,4 +56,58 @@ tap.test('should return a change Objservable', async tools => {
|
|||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// SECRETS
|
||||||
|
tap.test('should create a secret', async () => {
|
||||||
|
const mySecret = await docker.DockerSecret.createSecret(testDockerHost, {
|
||||||
|
name: 'testSecret',
|
||||||
|
version: '1.0.3',
|
||||||
|
contentArg: `{ "hi": "wow"}`,
|
||||||
|
labels: {}
|
||||||
|
});
|
||||||
|
console.log(mySecret);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should remove a secret by name', async () => {
|
||||||
|
const mySecret = await docker.DockerSecret.getSecretByName(testDockerHost, 'testSecret');
|
||||||
|
await mySecret.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
// SERVICES
|
||||||
|
tap.test('should activate swarm mode', async () => {
|
||||||
|
await testDockerHost.activateSwarm();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should list all services', async tools => {
|
||||||
|
const services = await testDockerHost.getServices();
|
||||||
|
console.log(services);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should create a service', async () => {
|
||||||
|
const testNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
|
||||||
|
Name: 'testNetwork'
|
||||||
|
});
|
||||||
|
const testSecret = await docker.DockerSecret.createSecret(testDockerHost, {
|
||||||
|
name: 'testSecret',
|
||||||
|
version: '0.0.1',
|
||||||
|
labels: {},
|
||||||
|
contentArg: '{"hi": "wow"}'
|
||||||
|
});
|
||||||
|
const testImage = await docker.DockerImage.createFromRegistry(testDockerHost, {
|
||||||
|
imageUrl: 'registry.gitlab.com/hosttoday/ht-docker-static'
|
||||||
|
});
|
||||||
|
const testService = await docker.DockerService.createService(testDockerHost, {
|
||||||
|
image: testImage,
|
||||||
|
labels: {},
|
||||||
|
name: 'testService',
|
||||||
|
networks: [testNetwork],
|
||||||
|
networkAlias: 'testService',
|
||||||
|
secrets: [testSecret],
|
||||||
|
ports: ['3000:80']
|
||||||
|
});
|
||||||
|
|
||||||
|
await testService.remove();
|
||||||
|
await testNetwork.remove();
|
||||||
|
await testSecret.remove();
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1 +0,0 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
|
@ -1,12 +1,10 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './docker.plugins';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
import { DockerHost } from './docker.classes.host';
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
export class DockerContainer {
|
export class DockerContainer {
|
||||||
// ======
|
|
||||||
// STATIC
|
// STATIC
|
||||||
// ======
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all containers
|
* get all containers
|
||||||
@ -17,7 +15,7 @@ export class DockerContainer {
|
|||||||
|
|
||||||
// TODO: Think about getting the config by inpsecting the container
|
// TODO: Think about getting the config by inpsecting the container
|
||||||
for (const containerResult of response.body) {
|
for (const containerResult of response.body) {
|
||||||
result.push(new DockerContainer(containerResult));
|
result.push(new DockerContainer(dockerHostArg, containerResult));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -26,37 +24,55 @@ export class DockerContainer {
|
|||||||
* gets an container by Id
|
* gets an container by Id
|
||||||
* @param containerId
|
* @param containerId
|
||||||
*/
|
*/
|
||||||
public static async getContainerById(containerId: string) {}
|
public static async getContainerById(containerId: string) {
|
||||||
|
// TODO: implement get container by id
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a container
|
* create a container
|
||||||
*/
|
*/
|
||||||
public static async create(creationSpecifier: interfaces.IContainerCreationSpecifier) {
|
public static async create(
|
||||||
|
dockerHost: DockerHost,
|
||||||
}
|
containerCreationDescriptor: interfaces.IContainerCreationDescriptor
|
||||||
|
) {
|
||||||
// ========
|
// check for unique hostname
|
||||||
// INSTANCE
|
const existingContainers = await DockerContainer.getContainers(dockerHost);
|
||||||
// ========
|
const sameHostNameContainer = existingContainers.find(container => {
|
||||||
|
// TODO implement HostName Detection;
|
||||||
constructor(dockerContainerObjectArg: any) {
|
return false;
|
||||||
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
|
|
||||||
this[keyArg] = dockerContainerObjectArg[keyArg];
|
|
||||||
});
|
});
|
||||||
|
const response = await dockerHost.request('POST', '/containers/create', {
|
||||||
|
Hostname: containerCreationDescriptor.Hostname,
|
||||||
|
Domainname: containerCreationDescriptor.Domainname,
|
||||||
|
User: 'root'
|
||||||
|
});
|
||||||
|
if (response.statusCode < 300) {
|
||||||
|
plugins.smartlog.defaultLogger.log('info', 'Container created successfully');
|
||||||
|
} else {
|
||||||
|
plugins.smartlog.defaultLogger.log(
|
||||||
|
'error',
|
||||||
|
'There has been a problem when creating the container'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Id: string;
|
// INSTANCE
|
||||||
Names: string[];
|
// references
|
||||||
Image: string;
|
public dockerHost: DockerHost;
|
||||||
ImageID: string;
|
|
||||||
Command: string;
|
// properties
|
||||||
Created: number;
|
public Id: string;
|
||||||
Ports: interfaces.TPorts;
|
public Names: string[];
|
||||||
Labels: interfaces.TLabels;
|
public Image: string;
|
||||||
State: string;
|
public ImageID: string;
|
||||||
Status: string;
|
public Command: string;
|
||||||
HostConfig: any;
|
public Created: number;
|
||||||
NetworkSettings: {
|
public Ports: interfaces.TPorts;
|
||||||
|
public Labels: interfaces.TLabels;
|
||||||
|
public State: string;
|
||||||
|
public Status: string;
|
||||||
|
public HostConfig: any;
|
||||||
|
public NetworkSettings: {
|
||||||
Networks: {
|
Networks: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
IPAMConfig: any;
|
IPAMConfig: any;
|
||||||
@ -75,5 +91,11 @@ export class DockerContainer {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Mounts: any;
|
public Mounts: any;
|
||||||
|
constructor(dockerHostArg: DockerHost, dockerContainerObjectArg: any) {
|
||||||
|
this.dockerHost = dockerHostArg;
|
||||||
|
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
|
||||||
|
this[keyArg] = dockerContainerObjectArg[keyArg];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,35 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './docker.plugins';
|
||||||
import { DockerContainer } from './docker.classes.container';
|
import { DockerContainer } from './docker.classes.container';
|
||||||
|
import { DockerNetwork } from './docker.classes.network';
|
||||||
|
import { DockerService } from './docker.classes.service';
|
||||||
|
|
||||||
|
export interface IAuthData {
|
||||||
|
serveraddress: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class DockerHost {
|
export class DockerHost {
|
||||||
/**
|
/**
|
||||||
* the path where the docker sock can be found
|
* the path where the docker sock can be found
|
||||||
*/
|
*/
|
||||||
sockPath: string;
|
public socketPath: string;
|
||||||
|
private registryToken: string = '';
|
||||||
/**
|
|
||||||
* keeping track of currently active requests to safely end this module at any time
|
|
||||||
*/
|
|
||||||
requestObjectmap = new plugins.lik.Objectmap<any>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
||||||
this.sockPath = pathArg;
|
let pathToUse: string;
|
||||||
|
if (pathArg) {
|
||||||
|
pathToUse = pathArg;
|
||||||
|
} else if (process.env.CI) {
|
||||||
|
pathToUse = 'http://docker:2375/';
|
||||||
|
} else {
|
||||||
|
pathToUse = 'http://unix:/var/run/docker.sock:';
|
||||||
|
}
|
||||||
|
this.socketPath = pathToUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,21 +37,65 @@ export class DockerHost {
|
|||||||
* @param userArg
|
* @param userArg
|
||||||
* @param passArg
|
* @param passArg
|
||||||
*/
|
*/
|
||||||
auth(registryArg: string, userArg: string, passArg: string) {
|
public async auth(authData: IAuthData) {
|
||||||
let done = plugins.smartpromise.defer();
|
const response = await this.request('POST', '/auth', authData);
|
||||||
this.request('POST', '');
|
if (response.body.Status !== 'Login Succeeded') {
|
||||||
return done.promise;
|
console.log(`Login failed with ${response.body.Status}`);
|
||||||
|
throw new Error(response.body.Status);
|
||||||
|
}
|
||||||
|
console.log(response.body.Status);
|
||||||
|
this.registryToken = plugins.smartstring.base64.encode(
|
||||||
|
plugins.smartjson.Smartjson.stringify(authData, {})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the token from the .docker/config.json file for GitLab registry
|
||||||
|
*/
|
||||||
|
public async getGitlabComTokenFromDockerConfig() {
|
||||||
|
const dockerConfigPath = plugins.smartpath.get.home('~/.docker/config.json');
|
||||||
|
const configObject = plugins.smartfile.fs.toObjectSync(dockerConfigPath);
|
||||||
|
const gitlabAuthBase64 = configObject.auths['registry.gitlab.com'].auth;
|
||||||
|
const gitlabAuth: string = plugins.smartstring.base64.decode(gitlabAuthBase64);
|
||||||
|
const gitlabAuthArray = gitlabAuth.split(':');
|
||||||
|
await this.auth({
|
||||||
|
username: gitlabAuthArray[0],
|
||||||
|
password: gitlabAuthArray[1],
|
||||||
|
serveraddress: 'registry.gitlab.com'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets all networks
|
||||||
|
*/
|
||||||
|
public async getNetworks() {
|
||||||
|
return await DockerNetwork.getNetworks(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async getContainers() {
|
|
||||||
|
/**
|
||||||
|
* gets all containers
|
||||||
|
*/
|
||||||
|
public async getContainers() {
|
||||||
const containerArray = await DockerContainer.getContainers(this);
|
const containerArray = await DockerContainer.getContainers(this);
|
||||||
return containerArray;
|
return containerArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
|
/**
|
||||||
|
* gets all services
|
||||||
|
*/
|
||||||
|
public async getServices() {
|
||||||
|
const serviceArray = await DockerService.getServices(this);
|
||||||
|
return serviceArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
|
||||||
const response = await this.requestStreaming('GET', '/events');
|
const response = await this.requestStreaming('GET', '/events');
|
||||||
return plugins.rxjs.Observable.create(observer => {
|
return plugins.rxjs.Observable.create(observer => {
|
||||||
response.on('data', data => {
|
response.on('data', data => {
|
||||||
@ -57,33 +113,71 @@ export class DockerHost {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* activates docker swarm
|
||||||
|
*/
|
||||||
|
public async activateSwarm(addvertisementIpArg?: string) {
|
||||||
|
// determine advertisement address
|
||||||
|
let addvertisementIp: string;
|
||||||
|
if (addvertisementIpArg) {
|
||||||
|
addvertisementIp = addvertisementIpArg;
|
||||||
|
} else {
|
||||||
|
const smartnetworkInstance = new plugins.smartnetwork.SmartNetwork();
|
||||||
|
const defaultGateway = await smartnetworkInstance.getDefaultGateway();
|
||||||
|
if (defaultGateway) {
|
||||||
|
addvertisementIp = defaultGateway.ipv4.address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await this.request('POST', '/swarm/init', {
|
||||||
|
ListenAddr: '0.0.0.0:2377',
|
||||||
|
AdvertiseAddr: addvertisementIp,
|
||||||
|
DataPathPort: 4789,
|
||||||
|
DefaultAddrPool: ['10.10.0.0/8', '20.20.0.0/8'],
|
||||||
|
SubnetSize: 24,
|
||||||
|
ForceNewCluster: false
|
||||||
|
});
|
||||||
|
if (response.statusCode === 200) {
|
||||||
|
plugins.smartlog.defaultLogger.log('info', 'created Swam succesfully');
|
||||||
|
} else {
|
||||||
|
plugins.smartlog.defaultLogger.log('error', 'could not initiate swarm');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fire a request
|
* fire a request
|
||||||
*/
|
*/
|
||||||
async request(methodArg: string, routeArg: string, dataArg = {}) {
|
public async request(methodArg: string, routeArg: string, dataArg = {}) {
|
||||||
const requestUrl = `${this.sockPath}${routeArg}`;
|
const requestUrl = `${this.socketPath}${routeArg}`;
|
||||||
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',
|
||||||
|
'X-Registry-Auth': this.registryToken,
|
||||||
Host: 'docker.sock'
|
Host: 'docker.sock'
|
||||||
},
|
},
|
||||||
requestBody: dataArg
|
requestBody: dataArg,
|
||||||
|
keepAlive: false
|
||||||
});
|
});
|
||||||
|
if (response.statusCode !== 200) {
|
||||||
|
console.log(response.body);
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) {
|
public async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) {
|
||||||
const requestUrl = `${this.sockPath}${routeArg}`;
|
const requestUrl = `${this.socketPath}${routeArg}`;
|
||||||
const response = await plugins.smartrequest.request(
|
const response = await plugins.smartrequest.request(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
{
|
{
|
||||||
method: methodArg,
|
method: methodArg,
|
||||||
headers: {
|
headers: {
|
||||||
// 'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'X-Registry-Auth': this.registryToken,
|
||||||
Host: 'docker.sock'
|
Host: 'docker.sock'
|
||||||
},
|
},
|
||||||
requestBody: null
|
requestBody: null,
|
||||||
|
keepAlive: false
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -1,37 +1,146 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './docker.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
import { DockerHost } from './docker.classes.host';
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
export class DockerImage {
|
export class DockerImage {
|
||||||
// STATIC
|
// STATIC
|
||||||
public static async createFromRegistry(dockerHostArg: DockerHost, dockerImageTag): Promise<DockerImage> {
|
public static async getImages(dockerHost: DockerHost) {
|
||||||
const resultingImage = new DockerImage();
|
const images: DockerImage[] = [];
|
||||||
|
const response = await dockerHost.request('GET', '/images/json');
|
||||||
return resultingImage;
|
for (const imageObject of response.body) {
|
||||||
|
images.push(new DockerImage(dockerHost, imageObject));
|
||||||
|
}
|
||||||
|
return images;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async createFromExistingImage(dockerHostArg: DockerHost, dockerImageTag) {}
|
public static async findImageByName(dockerHost: DockerHost, imageNameArg: string) {
|
||||||
|
const images = await this.getImages(dockerHost);
|
||||||
|
const result = images.find(image => {
|
||||||
|
if (image.RepoTags) {
|
||||||
|
return image.RepoTags.includes(imageNameArg);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async createFromRegistry(
|
||||||
|
dockerHostArg: DockerHost,
|
||||||
|
creationObject: interfaces.IImageCreationDescriptor
|
||||||
|
): Promise<DockerImage> {
|
||||||
|
// lets create a sanatized imageUrlObject
|
||||||
|
const imageUrlObject: {
|
||||||
|
imageUrl: string;
|
||||||
|
imageTag: string;
|
||||||
|
imageOriginTag: string;
|
||||||
|
} = {
|
||||||
|
imageUrl: creationObject.imageUrl,
|
||||||
|
imageTag: creationObject.imageTag,
|
||||||
|
imageOriginTag: null
|
||||||
|
};
|
||||||
|
if (imageUrlObject.imageUrl.includes(':')) {
|
||||||
|
const imageUrl = imageUrlObject.imageUrl.split(':')[0];
|
||||||
|
const imageTag = imageUrlObject.imageUrl.split(':')[1];
|
||||||
|
if (imageUrlObject.imageTag) {
|
||||||
|
throw new Error(
|
||||||
|
`imageUrl ${imageUrlObject.imageUrl} can't be tagged with ${imageUrlObject.imageTag} because it is already tagged with ${imageTag}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
imageUrlObject.imageUrl = imageUrl;
|
||||||
|
imageUrlObject.imageTag = imageTag;
|
||||||
|
}
|
||||||
|
} else if (!imageUrlObject.imageTag) {
|
||||||
|
imageUrlObject.imageTag = 'latest';
|
||||||
|
}
|
||||||
|
imageUrlObject.imageOriginTag = `${imageUrlObject.imageUrl}:${imageUrlObject.imageTag}`;
|
||||||
|
|
||||||
|
// lets actually create the image
|
||||||
|
const response = await dockerHostArg.request(
|
||||||
|
'POST',
|
||||||
|
`/images/create?fromImage=${encodeURIComponent(
|
||||||
|
imageUrlObject.imageUrl
|
||||||
|
)}&tag=${encodeURIComponent(imageUrlObject.imageTag)}`
|
||||||
|
);
|
||||||
|
if (response.statusCode < 300) {
|
||||||
|
plugins.smartlog.defaultLogger.log(
|
||||||
|
'info',
|
||||||
|
`Successfully pulled image ${imageUrlObject.imageUrl} from the registry`
|
||||||
|
);
|
||||||
|
const image = await DockerImage.findImageByName(dockerHostArg, imageUrlObject.imageOriginTag);
|
||||||
|
return image;
|
||||||
|
} else {
|
||||||
|
plugins.smartlog.defaultLogger.log('error', `Failed at the attempt of creating a new image`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async tagImageByIdOrName(
|
||||||
|
dockerHost: DockerHost,
|
||||||
|
idOrNameArg: string,
|
||||||
|
newTagArg: string
|
||||||
|
) {
|
||||||
|
const response = await dockerHost.request(
|
||||||
|
'POST',
|
||||||
|
`/images/${encodeURIComponent(idOrNameArg)}/${encodeURIComponent(newTagArg)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async buildImage(dockerHostArg: DockerHost, dockerImageTag) {
|
||||||
|
// TODO: implement building an image
|
||||||
|
}
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
|
// references
|
||||||
|
public dockerHost: DockerHost;
|
||||||
|
|
||||||
|
// properties
|
||||||
/**
|
/**
|
||||||
* the tags for an image
|
* the tags for an image
|
||||||
*/
|
*/
|
||||||
public tags: string[] = [];
|
public Containers: number;
|
||||||
|
public Created: number;
|
||||||
|
public Id: string;
|
||||||
|
public Labels: interfaces.TLabels;
|
||||||
|
public ParentId: string;
|
||||||
|
public RepoDigests: string[];
|
||||||
|
public RepoTags: string[];
|
||||||
|
public SharedSize: number;
|
||||||
|
public Size: number;
|
||||||
|
public VirtualSize: number;
|
||||||
|
|
||||||
|
constructor(dockerHostArg, dockerImageObjectArg: any) {
|
||||||
|
this.dockerHost = dockerHostArg;
|
||||||
|
Object.keys(dockerImageObjectArg).forEach(keyArg => {
|
||||||
|
this[keyArg] = dockerImageObjectArg[keyArg];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a boolean wether the image has a upstream image
|
* tag an image
|
||||||
|
* @param newTag
|
||||||
*/
|
*/
|
||||||
public isUpstreamImage (): boolean {
|
public async tagImage(newTag) {
|
||||||
// TODO: implement isUpastreamImage
|
throw new Error('.tagImage is not yet implemented');
|
||||||
return true;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* pulls the latest version from the registry
|
||||||
*/
|
*/
|
||||||
public async pullLatestImageFromRegistry() : Promise<boolean> {
|
public async pullLatestImageFromRegistry(): Promise<boolean> {
|
||||||
// TODO: implement pullLatestImageFromRegistry
|
const updatedImage = await DockerImage.createFromRegistry(this.dockerHost, {
|
||||||
|
imageUrl: this.RepoTags[0]
|
||||||
|
});
|
||||||
|
Object.assign(this, updatedImage);
|
||||||
|
// TODO: Compare image digists before and after
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get stuff
|
||||||
|
public async getVersion() {
|
||||||
|
if (this.Labels && this.Labels.version) {
|
||||||
|
return this.Labels.version;
|
||||||
|
} else {
|
||||||
|
return 'x.x.x';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,119 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './docker.plugins';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
import { DockerHost } from './docker.classes.host';
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
import { DockerService } from './docker.classes.service';
|
||||||
|
|
||||||
export class DockerNetwork {
|
export class DockerNetwork {
|
||||||
|
public static async getNetworks(dockerHost: DockerHost): Promise<DockerNetwork[]> {
|
||||||
|
const dockerNetworks: DockerNetwork[] = [];
|
||||||
|
const response = await dockerHost.request('GET', '/networks');
|
||||||
|
for (const networkObject of response.body) {
|
||||||
|
const dockerNetwork = new DockerNetwork(dockerHost);
|
||||||
|
Object.assign(dockerNetwork, networkObject);
|
||||||
|
dockerNetworks.push(dockerNetwork);
|
||||||
|
}
|
||||||
|
return dockerNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getNetworkByName(dockerHost: DockerHost, dockerNetworkNameArg: string) {
|
||||||
|
const networks = await DockerNetwork.getNetworks(dockerHost);
|
||||||
|
return networks.find(dockerNetwork => dockerNetwork.Name === dockerNetworkNameArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async createNetwork(
|
||||||
|
dockerHost: DockerHost,
|
||||||
|
networkCreationDescriptor: interfaces.INetworkCreationDescriptor
|
||||||
|
): Promise<DockerNetwork> {
|
||||||
|
const response = await dockerHost.request('POST', '/networks/create', {
|
||||||
|
Name: networkCreationDescriptor.Name,
|
||||||
|
CheckDuplicate: true,
|
||||||
|
Driver: 'overlay',
|
||||||
|
EnableIPv6: false,
|
||||||
|
IPAM: {
|
||||||
|
Driver: 'default',
|
||||||
|
Config: [
|
||||||
|
{
|
||||||
|
Subnet: '172.20.10.0/16',
|
||||||
|
IPRange: '172.20.10.0/24',
|
||||||
|
Gateway: '172.20.10.11'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
Internal: true,
|
||||||
|
Attachable: true,
|
||||||
|
Ingress: false
|
||||||
|
});
|
||||||
|
if (response.statusCode < 300) {
|
||||||
|
plugins.smartlog.defaultLogger.log('info', 'Created network successfully');
|
||||||
|
return await DockerNetwork.getNetworkByName(dockerHost, networkCreationDescriptor.Name);
|
||||||
|
} else {
|
||||||
|
plugins.smartlog.defaultLogger.log(
|
||||||
|
'error',
|
||||||
|
'There has been an error creating the wanted network'
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
// references
|
||||||
|
public dockerHost: DockerHost;
|
||||||
|
|
||||||
|
// properties
|
||||||
|
public Name: string;
|
||||||
|
public Id: string;
|
||||||
|
public Created: string;
|
||||||
|
public Scope: string;
|
||||||
|
public Driver: string;
|
||||||
|
public EnableIPv6: boolean;
|
||||||
|
public Internal: boolean;
|
||||||
|
public Attachable: boolean;
|
||||||
|
public Ingress: false;
|
||||||
|
public IPAM: {
|
||||||
|
Driver: 'default' | 'bridge' | 'overlay';
|
||||||
|
Config: [
|
||||||
|
{
|
||||||
|
Subnet: string;
|
||||||
|
IPRange: string;
|
||||||
|
Gateway: string;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(dockerHostArg: DockerHost) {
|
||||||
|
this.dockerHost = dockerHostArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes the network
|
||||||
|
*/
|
||||||
|
public async remove() {
|
||||||
|
const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getContainersOnNetwork(): Promise<Array<{
|
||||||
|
Name: string;
|
||||||
|
EndpointID: string;
|
||||||
|
MacAddress: string;
|
||||||
|
IPv4Address: string;
|
||||||
|
IPv6Address: string;
|
||||||
|
}>> {
|
||||||
|
const returnArray = [];
|
||||||
|
const response = await this.dockerHost.request('GET', `/networks/${this.Id}`);
|
||||||
|
for (const key of Object.keys(response.body.Containers)) {
|
||||||
|
returnArray.push(response.body.Containers[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnArray;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getContainersOnNetworkForService(serviceArg: DockerService) {
|
||||||
|
const containersOnNetwork = await this.getContainersOnNetwork();
|
||||||
|
const containersOfService = containersOnNetwork.filter(container => {
|
||||||
|
return container.Name.startsWith(serviceArg.Spec.Name);
|
||||||
|
});
|
||||||
|
return containersOfService;
|
||||||
|
}
|
||||||
}
|
}
|
92
ts/docker.classes.secret.ts
Normal file
92
ts/docker.classes.secret.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import * as plugins from './docker.plugins';
|
||||||
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
|
||||||
|
// interfaces
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
export class DockerSecret {
|
||||||
|
// STATIC
|
||||||
|
public static async getSecrets(dockerHostArg: DockerHost) {
|
||||||
|
const response = await dockerHostArg.request('GET', '/secrets');
|
||||||
|
const secrets: DockerSecret[] = [];
|
||||||
|
for (const secret of response.body) {
|
||||||
|
const dockerSecretInstance = new DockerSecret(dockerHostArg);
|
||||||
|
Object.assign(dockerSecretInstance, secret);
|
||||||
|
secrets.push(dockerSecretInstance);
|
||||||
|
}
|
||||||
|
return secrets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getSecretByID(dockerHostArg: DockerHost, idArg: string) {
|
||||||
|
const secrets = await this.getSecrets(dockerHostArg);
|
||||||
|
return secrets.find(secret => secret.ID === idArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getSecretByName(dockerHostArg: DockerHost, nameArg: string) {
|
||||||
|
const secrets = await this.getSecrets(dockerHostArg);
|
||||||
|
return secrets.find(secret => secret.Spec.Name === nameArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async createSecret(
|
||||||
|
dockerHostArg: DockerHost,
|
||||||
|
secretDescriptor: interfaces.ISecretCreationDescriptor
|
||||||
|
) {
|
||||||
|
const labels: interfaces.TLabels = {
|
||||||
|
...secretDescriptor.labels,
|
||||||
|
version: secretDescriptor.version
|
||||||
|
};
|
||||||
|
const response = await dockerHostArg.request('POST', '/secrets/create', {
|
||||||
|
Name: secretDescriptor.name,
|
||||||
|
Labels: labels,
|
||||||
|
Data: plugins.smartstring.base64.encode(secretDescriptor.contentArg)
|
||||||
|
});
|
||||||
|
|
||||||
|
const newSecretInstance = new DockerSecret(dockerHostArg);
|
||||||
|
Object.assign(newSecretInstance, response.body);
|
||||||
|
Object.assign(
|
||||||
|
newSecretInstance,
|
||||||
|
await DockerSecret.getSecretByID(dockerHostArg, newSecretInstance.ID)
|
||||||
|
);
|
||||||
|
return newSecretInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public ID: string;
|
||||||
|
public Spec: {
|
||||||
|
Name: string;
|
||||||
|
Labels: interfaces.TLabels;
|
||||||
|
};
|
||||||
|
public Version: {
|
||||||
|
Index: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
public dockerHost: DockerHost;
|
||||||
|
constructor(dockerHostArg: DockerHost) {
|
||||||
|
this.dockerHost = dockerHostArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates a secret
|
||||||
|
*/
|
||||||
|
public async update(contentArg: string) {
|
||||||
|
const route = `/secrets/${this.ID}/update?=version=${this.Version.Index}`;
|
||||||
|
const response = await this.dockerHost.request(
|
||||||
|
'POST',
|
||||||
|
`/secrets/${this.ID}/update?version=${this.Version.Index}`,
|
||||||
|
{
|
||||||
|
Name: this.Spec.Name,
|
||||||
|
Labels: this.Spec.Labels,
|
||||||
|
Data: plugins.smartstring.base64.encode(contentArg)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async remove() {
|
||||||
|
await this.dockerHost.request('DELETE', `/secrets/${this.ID}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get things
|
||||||
|
public async getVersion() {
|
||||||
|
return this.Spec.Labels.version;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,221 @@
|
|||||||
import * as plugins from './dockersock.plugins';
|
import * as plugins from './docker.plugins';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
import { DockerHost } from './docker.classes.host';
|
import { DockerHost } from './docker.classes.host';
|
||||||
|
import { DockerImage } from './docker.classes.image';
|
||||||
|
import { DockerSecret } from './docker.classes.secret';
|
||||||
|
|
||||||
export class DockerService {
|
export class DockerService {
|
||||||
|
// STATIC
|
||||||
|
public static async getServices(dockerHost: DockerHost) {
|
||||||
|
const services: DockerService[] = [];
|
||||||
|
const response = await dockerHost.request('GET', '/services');
|
||||||
|
for (const serviceObject of response.body) {
|
||||||
|
const dockerService = new DockerService(dockerHost);
|
||||||
|
Object.assign(dockerService, serviceObject);
|
||||||
|
services.push(dockerService);
|
||||||
|
}
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async getServiceByName(
|
||||||
|
dockerHost: DockerHost,
|
||||||
|
networkName: string
|
||||||
|
): Promise<DockerService> {
|
||||||
|
const allServices = await DockerService.getServices(dockerHost);
|
||||||
|
const wantedService = allServices.find(service => {
|
||||||
|
return service.Spec.Name === networkName;
|
||||||
|
});
|
||||||
|
return wantedService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a service
|
||||||
|
*/
|
||||||
|
public static async createService(
|
||||||
|
dockerHost: DockerHost,
|
||||||
|
serviceCreationDescriptor: interfaces.IServiceCreationDescriptor
|
||||||
|
): Promise<DockerService> {
|
||||||
|
// lets get the image
|
||||||
|
plugins.smartlog.defaultLogger.log(
|
||||||
|
'info',
|
||||||
|
`now creating service ${serviceCreationDescriptor.name}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// await serviceCreationDescriptor.image.pullLatestImageFromRegistry();
|
||||||
|
const serviceVersion = await serviceCreationDescriptor.image.getVersion();
|
||||||
|
|
||||||
|
const labels: interfaces.TLabels = {
|
||||||
|
...serviceCreationDescriptor.labels,
|
||||||
|
version: serviceVersion
|
||||||
|
};
|
||||||
|
|
||||||
|
const mounts: Array<{
|
||||||
|
/**
|
||||||
|
* the target inside the container
|
||||||
|
*/
|
||||||
|
Target: string;
|
||||||
|
/**
|
||||||
|
* The Source from which to mount the data (Volume or host path)
|
||||||
|
*/
|
||||||
|
Source: string;
|
||||||
|
Type: 'bind' | 'volume' | 'tmpfs' | 'npipe';
|
||||||
|
ReadOnly: boolean;
|
||||||
|
Consistency: 'default' | 'consistent' | 'cached' | 'delegated';
|
||||||
|
}> = [];
|
||||||
|
if (serviceCreationDescriptor.accessHostDockerSock) {
|
||||||
|
mounts.push({
|
||||||
|
Target: '/var/run/docker.sock',
|
||||||
|
Source: '/var/run/docker.sock',
|
||||||
|
Consistency: 'default',
|
||||||
|
ReadOnly: false,
|
||||||
|
Type: 'bind'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const networkArray: Array<{
|
||||||
|
Target: string;
|
||||||
|
Aliases: string[];
|
||||||
|
}> = [];
|
||||||
|
|
||||||
|
for (const network of serviceCreationDescriptor.networks) {
|
||||||
|
networkArray.push({
|
||||||
|
Target: network.Name,
|
||||||
|
Aliases: [serviceCreationDescriptor.networkAlias]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const ports = [];
|
||||||
|
for (const port of serviceCreationDescriptor.ports) {
|
||||||
|
const portArray = port.split(':');
|
||||||
|
const hostPort = portArray[0];
|
||||||
|
const containerPort = portArray[1];
|
||||||
|
ports.push({
|
||||||
|
Protocol: 'tcp',
|
||||||
|
PublishedPort: parseInt(hostPort, 10),
|
||||||
|
TargetPort: parseInt(containerPort, 10)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// lets configure secrets
|
||||||
|
const secretArray: any[] = [];
|
||||||
|
for (const secret of serviceCreationDescriptor.secrets) {
|
||||||
|
secretArray.push({
|
||||||
|
File: {
|
||||||
|
Name: 'secret.json', // TODO: make sure that works with multiple secrets
|
||||||
|
UID: '33',
|
||||||
|
GID: '33',
|
||||||
|
Mode: 384
|
||||||
|
},
|
||||||
|
SecretID: secret.ID,
|
||||||
|
SecretName: secret.Spec.Name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// lets configure limits
|
||||||
|
const limits = {
|
||||||
|
MemoryBytes: 1000 * 1000000
|
||||||
|
};
|
||||||
|
|
||||||
|
if (serviceCreationDescriptor.resources) {
|
||||||
|
limits.MemoryBytes = serviceCreationDescriptor.resources.memorySizeMB * 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await dockerHost.request('POST', '/services/create', {
|
||||||
|
Name: serviceCreationDescriptor.name,
|
||||||
|
TaskTemplate: {
|
||||||
|
ContainerSpec: {
|
||||||
|
Image: serviceCreationDescriptor.image.RepoTags[0],
|
||||||
|
Labels: labels,
|
||||||
|
Secrets: secretArray,
|
||||||
|
Mounts: mounts
|
||||||
|
},
|
||||||
|
UpdateConfig: {
|
||||||
|
Parallelism: 0,
|
||||||
|
Delay: 0,
|
||||||
|
FailureAction: 'pause',
|
||||||
|
Monitor: 15000000000,
|
||||||
|
MaxFailureRatio: 0.15
|
||||||
|
},
|
||||||
|
ForceUpdate: 1,
|
||||||
|
Resources: {
|
||||||
|
Limits: limits
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Labels: labels,
|
||||||
|
Networks: networkArray,
|
||||||
|
EndpointSpec: {
|
||||||
|
Ports: ports
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const createdService = await DockerService.getServiceByName(
|
||||||
|
dockerHost,
|
||||||
|
serviceCreationDescriptor.name
|
||||||
|
);
|
||||||
|
return createdService;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
public dockerHostRef: DockerHost;
|
||||||
|
|
||||||
|
public ID: string;
|
||||||
|
public Version: { Index: number };
|
||||||
|
public CreatedAt: string;
|
||||||
|
public UpdatedAt: string;
|
||||||
|
public Spec: {
|
||||||
|
Name: string;
|
||||||
|
Labels: interfaces.TLabels;
|
||||||
|
TaskTemplate: {
|
||||||
|
ContainerSpec: {
|
||||||
|
Image: string;
|
||||||
|
Isolation: string;
|
||||||
|
Secrets: Array<{
|
||||||
|
File: {
|
||||||
|
Name: string;
|
||||||
|
UID: string;
|
||||||
|
GID: string;
|
||||||
|
Mode: number;
|
||||||
|
};
|
||||||
|
SecretID: string;
|
||||||
|
SecretName: string;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
ForceUpdate: 0;
|
||||||
|
};
|
||||||
|
Mode: {};
|
||||||
|
Networks: [any[]];
|
||||||
|
};
|
||||||
|
public Endpoint: { Spec: {}; VirtualIPs: [any[]] };
|
||||||
|
|
||||||
|
constructor(dockerHostArg: DockerHost) {
|
||||||
|
this.dockerHostRef = dockerHostArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async remove() {
|
||||||
|
await this.dockerHostRef.request('DELETE', `/services/${this.ID}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async reReadFromDockerEngine() {
|
||||||
|
const dockerData = await this.dockerHostRef.request('GET', `/services/${this.ID}`);
|
||||||
|
// TODO: Better assign: Object.assign(this, dockerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async needsUpdate(): Promise<boolean> {
|
||||||
|
// TODO: implement digest based update recognition
|
||||||
|
|
||||||
|
await this.reReadFromDockerEngine();
|
||||||
|
const dockerImage = await DockerImage.createFromRegistry(this.dockerHostRef, {
|
||||||
|
imageUrl: this.Spec.TaskTemplate.ContainerSpec.Image
|
||||||
|
});
|
||||||
|
|
||||||
|
const imageVersion = new plugins.smartversion.SmartVersion(dockerImage.Labels.version);
|
||||||
|
const serviceVersion = new plugins.smartversion.SmartVersion(this.Spec.Labels.version);
|
||||||
|
if (imageVersion.greaterThan(serviceVersion)) {
|
||||||
|
console.log(`service ${this.Spec.Name} needs to be updated`);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
console.log(`service ${this.Spec.Name} is up to date.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
36
ts/docker.plugins.ts
Normal file
36
ts/docker.plugins.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// node native path
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export { path };
|
||||||
|
|
||||||
|
// @pushrocks scope
|
||||||
|
import * as lik from '@pushrocks/lik';
|
||||||
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
import * as smartjson from '@pushrocks/smartjson';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
import * as smartnetwork from '@pushrocks/smartnetwork';
|
||||||
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
import * as smartstring from '@pushrocks/smartstring';
|
||||||
|
import * as smartversion from '@pushrocks/smartversion';
|
||||||
|
|
||||||
|
smartlog.defaultLogger.enableConsole();
|
||||||
|
|
||||||
|
export {
|
||||||
|
lik,
|
||||||
|
smartfile,
|
||||||
|
smartjson,
|
||||||
|
smartlog,
|
||||||
|
smartnetwork,
|
||||||
|
smartpath,
|
||||||
|
smartpromise,
|
||||||
|
smartrequest,
|
||||||
|
smartstring,
|
||||||
|
smartversion
|
||||||
|
};
|
||||||
|
|
||||||
|
// third party
|
||||||
|
import * as rxjs from 'rxjs';
|
||||||
|
|
||||||
|
export { rxjs };
|
@ -1,12 +0,0 @@
|
|||||||
// @pushrocks scope
|
|
||||||
import * as lik from '@pushrocks/lik';
|
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
|
||||||
|
|
||||||
export { lik, smartlog, smartpromise, smartrequest };
|
|
||||||
|
|
||||||
// third party
|
|
||||||
import * as rxjs from 'rxjs';
|
|
||||||
|
|
||||||
export { rxjs };
|
|
@ -2,4 +2,5 @@ export * from './docker.classes.host';
|
|||||||
export * from './docker.classes.container';
|
export * from './docker.classes.container';
|
||||||
export * from './docker.classes.image';
|
export * from './docker.classes.image';
|
||||||
export * from './docker.classes.network';
|
export * from './docker.classes.network';
|
||||||
|
export * from './docker.classes.secret';
|
||||||
export * from './docker.classes.service';
|
export * from './docker.classes.service';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { DockerNetwork } from '../docker.classes.network';
|
import { DockerNetwork } from '../docker.classes.network';
|
||||||
|
|
||||||
export interface IContainerCreationSpecifier {
|
export interface IContainerCreationDescriptor {
|
||||||
hostname: string;
|
Hostname: string;
|
||||||
domainName: string;
|
Domainname: string;
|
||||||
networks?: DockerNetwork[];
|
networks?: DockerNetwork[];
|
||||||
}
|
}
|
||||||
|
4
ts/interfaces/image.ts
Normal file
4
ts/interfaces/image.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface IImageCreationDescriptor {
|
||||||
|
imageUrl: string;
|
||||||
|
imageTag?: string;
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
export * from './container';
|
export * from './container';
|
||||||
|
export * from './image';
|
||||||
export * from './label';
|
export * from './label';
|
||||||
|
export * from './network';
|
||||||
export * from './port';
|
export * from './port';
|
||||||
|
export * from './secret';
|
||||||
|
export * from './service';
|
||||||
|
6
ts/interfaces/network.ts
Normal file
6
ts/interfaces/network.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* creates a new Network
|
||||||
|
*/
|
||||||
|
export interface INetworkCreationDescriptor {
|
||||||
|
Name: string;
|
||||||
|
}
|
8
ts/interfaces/secret.ts
Normal file
8
ts/interfaces/secret.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import * as interfaces from './';
|
||||||
|
|
||||||
|
export interface ISecretCreationDescriptor {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
contentArg: any;
|
||||||
|
labels: interfaces.TLabels;
|
||||||
|
}
|
18
ts/interfaces/service.ts
Normal file
18
ts/interfaces/service.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import * as interfaces from './';
|
||||||
|
import { DockerNetwork } from '../docker.classes.network';
|
||||||
|
import { DockerSecret } from '../docker.classes.secret';
|
||||||
|
import { DockerImage } from '../docker.classes.image';
|
||||||
|
|
||||||
|
export interface IServiceCreationDescriptor {
|
||||||
|
name: string;
|
||||||
|
image: DockerImage;
|
||||||
|
labels: interfaces.TLabels;
|
||||||
|
networks: DockerNetwork[];
|
||||||
|
networkAlias: string;
|
||||||
|
secrets: DockerSecret[];
|
||||||
|
ports: string[];
|
||||||
|
accessHostDockerSock?: boolean;
|
||||||
|
resources?: {
|
||||||
|
memorySizeMB: number
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user