mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-11 05:09:55 +00:00
Allow spaces in volume definitions
Closes: #1247 Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
ae92ff54b2
commit
0950b66c52
@ -1012,9 +1012,9 @@ export class Service {
|
||||
const [bindSource, bindDest, mode] = volume.split(':');
|
||||
if (!path.isAbsolute(bindSource)) {
|
||||
// namespace our volumes by appId
|
||||
let volumeDef = `${appId}_${bindSource}:${bindDest}`;
|
||||
let volumeDef = `${appId}_${bindSource.trim()}:${bindDest.trim()}`;
|
||||
if (mode != null) {
|
||||
volumeDef = `${volumeDef}:${mode}`;
|
||||
volumeDef = `${volumeDef}:${mode.trim()}`;
|
||||
}
|
||||
volumes.push(volumeDef);
|
||||
} else {
|
||||
|
@ -240,6 +240,35 @@ describe('compose/service', () => {
|
||||
.that.deep.equals(['80/tcp', '100/tcp']);
|
||||
});
|
||||
|
||||
it('should correctly handle spaces in volume definitions', () => {
|
||||
const service = Service.fromComposeObject(
|
||||
{
|
||||
appId: 123,
|
||||
serviceId: 123,
|
||||
serviceName: 'test',
|
||||
volumes: [
|
||||
'vol1:vol2',
|
||||
'vol3 :/usr/src/app',
|
||||
'vol4: /usr/src/app',
|
||||
'vol5 : vol6',
|
||||
],
|
||||
},
|
||||
{ appName: 'test' } as any,
|
||||
);
|
||||
|
||||
expect(service.config)
|
||||
.to.have.property('volumes')
|
||||
.that.deep.equals([
|
||||
'123_vol1:vol2',
|
||||
'123_vol3:/usr/src/app',
|
||||
'123_vol4:/usr/src/app',
|
||||
'123_vol5:vol6',
|
||||
|
||||
'/tmp/balena-supervisor/services/123/test:/tmp/resin',
|
||||
'/tmp/balena-supervisor/services/123/test:/tmp/balena',
|
||||
]);
|
||||
});
|
||||
|
||||
describe('Ordered array parameters', () => {
|
||||
it('Should correctly compare ordered array parameters', () => {
|
||||
const svc1 = Service.fromComposeObject(
|
||||
|
Loading…
x
Reference in New Issue
Block a user