Compare commits

...

32 Commits

Author SHA1 Message Date
b5c4727bae 1.0.51 2019-08-16 21:45:22 +02:00
b6f3fbf8a9 fix(core): update 2019-08-16 21:45:21 +02:00
7241e7a8fd 1.0.50 2019-08-16 21:34:36 +02:00
ae37148ece fix(core): update 2019-08-16 21:34:35 +02:00
65c37bdd6f 1.0.49 2019-08-16 21:21:31 +02:00
6acbe30e2e fix(core): update 2019-08-16 21:21:30 +02:00
eb6f7889d0 1.0.48 2019-08-16 21:10:03 +02:00
e39da5fee9 fix(core): update 2019-08-16 21:10:03 +02:00
b07628bb0b 1.0.47 2019-08-16 21:07:59 +02:00
5815f9b202 fix(core): update 2019-08-16 21:07:59 +02:00
846ea9997e 1.0.46 2019-08-16 18:32:42 +02:00
de54db33ad fix(core): update 2019-08-16 18:32:41 +02:00
314cb692ac 1.0.45 2019-08-16 18:21:55 +02:00
73f8ded3fe fix(core): update 2019-08-16 18:21:55 +02:00
a28b10ac51 1.0.44 2019-08-16 14:46:48 +02:00
927e2e0acc fix(core): update 2019-08-16 14:46:48 +02:00
c496405818 1.0.43 2019-08-16 12:48:57 +02:00
020737e21b fix(core): update 2019-08-16 12:48:56 +02:00
fe3560caac 1.0.42 2019-08-16 12:48:40 +02:00
b2a7e67868 fix(core): update 2019-08-16 12:48:40 +02:00
f772ca15ef 1.0.41 2019-08-15 19:04:10 +02:00
71cfad146f fix(core): update 2019-08-15 19:04:09 +02:00
43b1c13256 1.0.40 2019-08-15 19:02:44 +02:00
2c8b17f029 fix(core): update 2019-08-15 19:02:43 +02:00
c6521d9160 1.0.39 2019-08-15 19:00:17 +02:00
72c74e44b5 fix(core): update 2019-08-15 19:00:17 +02:00
2fb628213d 1.0.38 2019-08-15 18:50:13 +02:00
373a4e2eac fix(core): update 2019-08-15 18:50:13 +02:00
a202d05e9c 1.0.37 2019-08-14 23:21:54 +02:00
6e97a7d83c fix(core): update 2019-08-14 23:21:54 +02:00
04bb3b9ed0 1.0.36 2019-08-14 21:02:06 +02:00
29e502a32e fix(core): update 2019-08-14 21:02:06 +02:00
18 changed files with 492 additions and 100 deletions

View File

@ -39,6 +39,8 @@ snyk:
# ==================== # ====================
testLTS: testLTS:
services:
- docker:18-dind
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@ -48,7 +50,7 @@ testLTS:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv - priv
testBuild: testBuild:
stage: test stage: test

29
.vscode/launch.json vendored Normal file
View 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"
}
]
}

View File

@ -21,22 +21,13 @@ unofficial docker engine api abstraction package written in TypeScript
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.

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/docker", "name": "@mojoio/docker",
"version": "1.0.35", "version": "1.0.51",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/docker", "name": "@mojoio/docker",
"version": "1.0.35", "version": "1.0.51",
"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",

View File

@ -1,23 +1,50 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import { DockerHost } from '../ts/index'; import * as docker from '../ts/index';
import { DockerService } 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();
return expect(testDockerHost).to.be.instanceof(DockerHost); return expect(testDockerHost).to.be.instanceof(docker.DockerHost);
}); });
// 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 +53,29 @@ tap.test('should return a change Objservable', async tools => {
subscription.unsubscribe(); subscription.unsubscribe();
}); });
// SERVICES
tap.test('should activate swarm mode', async () => {
await testDockerHost.activateSwarm();
});
tap.test('should list all services', async tools => {
const services = await docker.DockerService.getServices(testDockerHost);
console.log(services);
});
tap.test('should create a service', async () => {
const testNetwork = await docker.DockerNetwork.createNetwork(testDockerHost, {
Name: 'testNetwork'
});
await DockerService.createService(testDockerHost, {
Image: 'nginx:latest',
Labels: {
'testlabel': 'hi'
},
Name: 'testService',
networks: [testNetwork],
networkAlias: 'testService'
});
});
tap.start(); tap.start();

View File

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

View File

@ -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,35 +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
// INSTANCE ) {
// ======== // check for unique hostname
const existingContainers = await DockerContainer.getContainers(dockerHost);
constructor(dockerContainerObjectArg: any) { const sameHostNameContainer = existingContainers.find(container => {
Object.keys(dockerContainerObjectArg).forEach(keyArg => { // TODO implement HostName Detection;
this[keyArg] = dockerContainerObjectArg[keyArg]; return false;
}); });
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;
@ -73,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];
});
}
} }

View File

@ -1,23 +1,27 @@
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';
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;
/**
* 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 +29,30 @@ export class DockerHost {
* @param userArg * @param userArg
* @param passArg * @param passArg
*/ */
auth(registryArg: string, userArg: string, passArg: string) { public async auth(registryArg: string, userArg: string, passArg: string) {
let done = plugins.smartpromise.defer(); // TODO: implement Docker Registry authentication
this.request('POST', ''); await this.request('POST', '');
return done.promise; }
/**
* gets all networks
*/
public async getNetworks() {
return await DockerNetwork.getNetworks(this);
}
/**
* gets all containers
*/
public async getContainers() {
const containerArray = await DockerContainer.getContainers(this);
return containerArray;
} }
/** /**
* *
*/ */
async getContainers() { public async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
const containerArray = await DockerContainer.getContainers(this);
return containerArray;
}
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,11 +70,30 @@ export class DockerHost {
}); });
} }
/**
* activates docker swarm
*/
public async activateSwarm(addvertisementIpArg?: string) {
const response = await this.request('POST', '/swarm/init', {
ListenAddr: '0.0.0.0:2377',
AdvertiseAddr: addvertisementIpArg ? `${addvertisementIpArg}:2377` : undefined,
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: {
@ -70,11 +102,14 @@ export class DockerHost {
}, },
requestBody: dataArg requestBody: dataArg
}); });
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,
{ {

View File

@ -1,38 +1,128 @@
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( public static async getImages(dockerHost: DockerHost) {
dockerHostArg: DockerHost, const images: DockerImage[] = [];
dockerImageTag const response = await dockerHost.request('GET', '/images/json');
): Promise<DockerImage> { for (const imageObject of response.body) {
const resultingImage = new DockerImage(); images.push(new DockerImage(dockerHost, imageObject));
}
return resultingImage; return images;
} }
public static async createFromExistingImage(dockerHostArg: DockerHost, dockerImageTag) {} public static async findImageByName(dockerHost: DockerHost, imageNameArg: string) {
const images = await this.getImages(dockerHost);
return images.find(image => {
return image.RepoTags.includes(imageNameArg);
});
}
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.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) {
* returns a boolean wether the image has a upstream image this.dockerHost = dockerHostArg;
*/ Object.keys(dockerImageObjectArg).forEach(keyArg => {
public isUpstreamImage(): boolean { this[keyArg] = dockerImageObjectArg[keyArg];
// TODO: implement isUpastreamImage });
return true;
} }
public tagImage(newTag) {}
/** /**
* * 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;
} }
} }

View File

@ -1,6 +1,94 @@
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 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) {
dockerNetworks.push(new DockerNetwork(dockerHost, networkObject));
}
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, dockerNetworkObjectArg: any) {
this.dockerHost = dockerHostArg;
Object.keys(dockerNetworkObjectArg).forEach(keyArg => {
this[keyArg] = dockerNetworkObjectArg[keyArg];
});
}
/**
* removes the network
*/
public async remove() {
const response = await this.dockerHost.request('DELETE', `/networks/${this.Id}`);
}
}

View File

@ -1,6 +1,63 @@
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';
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) {
services.push(new DockerService(dockerHost, serviceObject));
}
return services;
}
/**
* creates a service
*/
public static async createService(
dockerHost: DockerHost,
serviceCreationDescriptor: interfaces.IServiceCreationDescriptor
) {
// lets get the image
plugins.smartlog.defaultLogger.log('info', `downloading image for service ${serviceCreationDescriptor.Name}`);
const serviceImage = await DockerImage.createFromRegistry(dockerHost, {
imageUrl: serviceCreationDescriptor.Image
});
const networkArray: any[] = [];
for (const network of serviceCreationDescriptor.networks) {
networkArray.push({
Target: network.Name,
Aliases: [serviceCreationDescriptor.networkAlias]
});
}
dockerHost.request('POST', '/services/create', {
Name: serviceCreationDescriptor.Name,
TaskTemplate: {
ContainerSpec: {
Image: serviceCreationDescriptor.Image,
Labels: serviceCreationDescriptor.Labels
}
},
Labels: serviceCreationDescriptor.Labels,
Networks: networkArray
});
}
// INSTANCE
public dockerHost: DockerHost;
constructor(dockerHostArg: DockerHost, serviceObject) {
this.dockerHost = dockerHostArg;
Object.assign(this, serviceObject);
}
update() {
// TODO: implemnt updating service
}
}

View File

@ -4,6 +4,8 @@ import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
smartlog.defaultLogger.enableConsole();
export { lik, smartlog, smartpromise, smartrequest }; export { lik, smartlog, smartpromise, smartrequest };
// third party // third party

View File

@ -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
View File

@ -0,0 +1,4 @@
export interface IImageCreationDescriptor {
imageUrl: string;
imageTag?: string;
}

View File

@ -1,3 +1,6 @@
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 './service';

6
ts/interfaces/network.ts Normal file
View File

@ -0,0 +1,6 @@
/**
* creates a new Network
*/
export interface INetworkCreationDescriptor {
Name: string;
}

10
ts/interfaces/service.ts Normal file
View File

@ -0,0 +1,10 @@
import * as interfaces from './';
import { DockerNetwork } from '../docker.classes.network';
export interface IServiceCreationDescriptor {
Name: string;
Image: string;
Labels: interfaces.TLabels;
networks: DockerNetwork[];
networkAlias: string;
}