mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-06 01:21:39 +00:00
Merge pull request #1252 from balena-io/1247-spaced-volumes
Allow spaces in volume definitions
This commit is contained in:
commit
be42ef5047
@ -1012,9 +1012,9 @@ export class Service {
|
|||||||
const [bindSource, bindDest, mode] = volume.split(':');
|
const [bindSource, bindDest, mode] = volume.split(':');
|
||||||
if (!path.isAbsolute(bindSource)) {
|
if (!path.isAbsolute(bindSource)) {
|
||||||
// namespace our volumes by appId
|
// namespace our volumes by appId
|
||||||
let volumeDef = `${appId}_${bindSource}:${bindDest}`;
|
let volumeDef = `${appId}_${bindSource.trim()}:${bindDest.trim()}`;
|
||||||
if (mode != null) {
|
if (mode != null) {
|
||||||
volumeDef = `${volumeDef}:${mode}`;
|
volumeDef = `${volumeDef}:${mode.trim()}`;
|
||||||
}
|
}
|
||||||
volumes.push(volumeDef);
|
volumes.push(volumeDef);
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,6 +240,35 @@ describe('compose/service', () => {
|
|||||||
.that.deep.equals(['80/tcp', '100/tcp']);
|
.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', () => {
|
describe('Ordered array parameters', () => {
|
||||||
it('Should correctly compare ordered array parameters', () => {
|
it('Should correctly compare ordered array parameters', () => {
|
||||||
const svc1 = Service.fromComposeObject(
|
const svc1 = Service.fromComposeObject(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user