Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit b851c8d

Browse files
committed
Merge branch 'develop', prepare 1.1.0
2 parents 0438fe6 + 775e489 commit b851c8d

File tree

6 files changed

+134
-48
lines changed

6 files changed

+134
-48
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
"devDependencies": {
3939
"coveralls": "^3.0.0",
4040
"pkg": "^4.1.4",
41-
"tap": "^10.7.1"
41+
"tap": "^11.0.0"
4242
}
4343
}

src/docker/start.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ module.exports = async ({image, username, resultStream}) => {
3838
RestartPolicy.Name = 'on-failure';
3939
RestartPolicy.MaximumRetryCount = restartCount;
4040
}
41+
const additionalLabels = config.labels || {};
4142

4243
// create config
4344
const containerConfig = {
4445
Image: image,
4546
name,
4647
Env,
4748
Labels: {
49+
...additionalLabels,
4850
'exoframe.deployment': name,
4951
'exoframe.user': username,
5052
'exoframe.project': project,

test/deploy.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = (server, token) =>
1717
const streamComposeUpdate = tar.pack(path.join(__dirname, 'fixtures', 'compose-project'));
1818
const streamBrokenDocker = tar.pack(path.join(__dirname, 'fixtures', 'broken-docker-project'));
1919
const streamBrokenNode = tar.pack(path.join(__dirname, 'fixtures', 'broken-node-project'));
20+
const streamAdditionalLabels = tar.pack(path.join(__dirname, 'fixtures', 'additional-labels'));
2021

2122
// options base
2223
const optionsBase = {
@@ -484,6 +485,39 @@ module.exports = (server, token) =>
484485
});
485486
});
486487

488+
tap.test('Should have additional labels', t => {
489+
const options = Object.assign(optionsBase, {
490+
payload: streamAdditionalLabels,
491+
});
492+
493+
server.inject(options, async response => {
494+
// parse result into lines
495+
const result = response.result
496+
.split('\n')
497+
.filter(l => l && l.length)
498+
.map(line => JSON.parse(line));
499+
500+
// find deployments
501+
const deployments = result.find(it => it.deployments && it.deployments.length).deployments;
502+
503+
// check response
504+
t.equal(response.statusCode, 200, 'Correct status code');
505+
506+
// check docker services
507+
const allContainers = await docker.listContainers();
508+
const containerInfo = allContainers.find(c => c.Names.includes(deployments[0].Name));
509+
t.ok(containerInfo, 'Docker has container');
510+
t.equal(containerInfo.Labels['custom.label'], "additional-label", 'Should have label `custom.label=additional-label`');
511+
512+
// cleanup
513+
const instance = docker.getContainer(containerInfo.Id);
514+
await instance.stop();
515+
await instance.remove();
516+
517+
t.end();
518+
});
519+
});
520+
487521
tap.test('End', t => {
488522
resolve();
489523
t.end();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "test-additional-labels",
3+
"domain": false,
4+
"project": "simple-html",
5+
"restart": "no",
6+
"labels": {
7+
"custom.label" : "additional-label"
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html lang="en">
2+
<head>
3+
<title>hello world.</title>
4+
</head>
5+
<body>
6+
<h1>Testing additional labels</h1>
7+
</body>
8+
</html>

0 commit comments

Comments
 (0)