mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-03-22 03:55:22 +00:00
Remove trailing slashes from working directories of services
This is to combat when a working directory is in the compose file for a service with a trailing slash. Docker will strip this slash and that means service comparisons will fail going forward - even if they are the same. Change-type: patch Closes: #635 Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
parent
45cb5b6c07
commit
ddbf3418de
@ -62,7 +62,7 @@ getUser = (service, imageInfo) ->
|
||||
return service.user ? imageInfo?.Config?.User ? ''
|
||||
|
||||
getWorkingDir = (service, imageInfo) ->
|
||||
return service.workingDir ? imageInfo?.Config?.WorkingDir ? ''
|
||||
return (service.workingDir ? imageInfo?.Config?.WorkingDir ? '').replace(/(^.+)\/$/, '$1')
|
||||
|
||||
buildHealthcheckTest = (test) ->
|
||||
if _.isString(test)
|
||||
|
@ -147,3 +147,17 @@ describe 'compose/service.cofee', ->
|
||||
expect(makeComposeServiceWithLimit('64gb').memLimit).to.equal(68719476736)
|
||||
expect(makeComposeServiceWithLimit('64Gb').memLimit).to.equal(68719476736)
|
||||
|
||||
describe 'getWorkingDir', ->
|
||||
makeComposeServiceWithWorkdir = (workdir) ->
|
||||
new Service(
|
||||
appId: 123456,
|
||||
serviceId: 123456,
|
||||
serviceName: 'foobar'
|
||||
workingDir: workdir
|
||||
)
|
||||
|
||||
it 'should remove a trailing slash', ->
|
||||
expect(makeComposeServiceWithWorkdir('/usr/src/app/').workingDir).to.equal('/usr/src/app')
|
||||
expect(makeComposeServiceWithWorkdir('/').workingDir).to.equal('/')
|
||||
expect(makeComposeServiceWithWorkdir('/usr/src/app').workingDir).to.equal('/usr/src/app')
|
||||
expect(makeComposeServiceWithWorkdir('').workingDir).to.equal('')
|
||||
|
Loading…
x
Reference in New Issue
Block a user