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

Commit

Permalink
Merge branch 'develop', prepare 6.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yamalight committed Jun 15, 2020
2 parents 618dde8 + 6d27ef1 commit ad2e52f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "exoframe-server",
"version": "6.2.2",
"version": "6.2.3-dev.2",
"description": "Exoframe is a self-hosted tool that allows simple one-command deployments using Docker",
"main": "bin/server-core.js",
"bin": "bin/exoframe-server.js",
Expand Down
14 changes: 13 additions & 1 deletion src/docker/templates/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ const {getHost, getEnv} = require('../../util');
const generateBaseName = ({username, config}) =>
`exo-${_.kebabCase(username)}-${_.kebabCase(config.name.split(':').shift())}`;

// maps array labels to objects, if necessary
const asObjectLabels = labels =>
!Array.isArray(labels)
? labels
: labels.reduce((acc, label) => {
// Split at =, but only retain first value
const [name, ...values] = label.split('=');
const value = values.join('=');

return {...acc, [name]: value};
}, {});

// function to update compose file with required vars
const updateCompose = ({username, baseName, serverConfig, composePath}) => {
const uid = uuidv1();
Expand Down Expand Up @@ -51,7 +63,7 @@ const updateCompose = ({username, baseName, serverConfig, composePath}) => {
'traefik.enable': 'true',
};

compose.services[svcKey].labels = Object.assign({}, extLabels, compose.services[svcKey].labels);
compose.services[svcKey].labels = Object.assign({}, extLabels, asObjectLabels(compose.services[svcKey].labels));
});

// write new compose back to file
Expand Down
4 changes: 4 additions & 0 deletions test/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ test('Should deploy simple compose project', async done => {
expect(containerOne.Labels[`traefik.http.routers.web.rule`]).toEqual('Host(`test.dev`)');
expect(containerOne.Labels['custom.envvar']).toEqual('custom-value');
expect(containerOne.Labels['custom.secret']).toEqual('custom-secret-value');
expect(containerTwo.Labels.username).toEqual('user1234');
expect(containerTwo.Labels.password).toEqual('abcde=cddfd=gdfg');
expect(containerOne.NetworkSettings.Networks.exoframe).toBeDefined();
expect(containerTwo.NetworkSettings.Networks.exoframe).toBeDefined();

Expand Down Expand Up @@ -496,6 +498,8 @@ test('Should update simple compose project', async done => {
expect(containerOne.Labels[`traefik.http.routers.web.rule`]).toEqual('Host(`test.dev`)');
expect(containerOne.Labels['custom.envvar']).toEqual('custom-value');
expect(containerOne.Labels['custom.secret']).toEqual('custom-secret-value');
expect(containerTwo.Labels.username).toEqual('user1234');
expect(containerTwo.Labels.password).toEqual('abcde=cddfd=gdfg');
expect(containerOne.NetworkSettings.Networks.exoframe).toBeDefined();
expect(containerTwo.NetworkSettings.Networks.exoframe).toBeDefined();

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/compose-project/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ services:
custom.secret: '${CUSTOM_SECRET}'
redis:
image: 'redis:alpine'
labels:
- username=user1234
- "password=abcde=cddfd=gdfg"

0 comments on commit ad2e52f

Please sign in to comment.