fix: Correctly handle array based network definitions for service

Change-type: patch
Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
Cameron Diver 2018-09-24 12:04:11 +01:00
parent 367dd876aa
commit 5537ae4e2e
No known key found for this signature in database
GPG Key ID: 69264F9C923F55C1
2 changed files with 25 additions and 1 deletions

View File

@ -19,7 +19,9 @@ import {
export function camelCaseConfig(literalConfig: ConfigMap): ServiceComposeConfig {
const config = _.mapKeys(literalConfig, (_v, k) => _.camelCase(k));
if (_.isObject(config.networks)) {
// Networks can either be an object or array, but given _.isObject
// returns true for an array, we check the other way
if (!_.isArray(config.networks)) {
const networksTmp = _.cloneDeep(config.networks);
_.each(networksTmp, (v, k) => {
config.networks[k] = _.mapKeys(v, (_v, k) => _.camelCase(k));

View File

@ -0,0 +1,22 @@
require('mocha');
{ expect } = require('chai');
ComposeUtils = require('../src/compose/utils');
describe 'Composition utilities', ->
it 'Should correctly camel case the configuration', ->
config =
networks: [
'test',
'test2',
]
expect(ComposeUtils.camelCaseConfig(config)).to.deep.equal({
networks: [
'test'
'test2'
]
})