mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-21 11:35:18 +00:00
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:
parent
367dd876aa
commit
5537ae4e2e
@ -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));
|
||||
|
22
test/19-compose-utils.coffee
Normal file
22
test/19-compose-utils.coffee
Normal 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'
|
||||
]
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user