mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 16:35:23 +00:00
Fix routing for deleting images with a slash in the name
This commit is contained in:
parent
7b9eaeea3a
commit
951bd2888f
@ -171,7 +171,7 @@ module.exports = (application) ->
|
||||
res.json(device.getState())
|
||||
|
||||
unparsedRouter.post '/v1/images/create', dockerUtils.createImage
|
||||
unparsedRouter.delete '/v1/images/:name', dockerUtils.deleteImage
|
||||
unparsedRouter.delete '/v1/images/*', dockerUtils.deleteImage
|
||||
unparsedRouter.get '/v1/images', dockerUtils.listImages
|
||||
parsedRouter.post '/v1/containers/create', dockerUtils.createContainer
|
||||
parsedRouter.post '/v1/containers/:id/start', dockerUtils.startContainer
|
||||
|
@ -262,13 +262,14 @@ do ->
|
||||
res.status(500).send(err?.message or err or 'Unknown error')
|
||||
|
||||
exports.deleteImage = (req, res) ->
|
||||
imageName = req.params[0]
|
||||
Promise.using lockImages(), ->
|
||||
knex('image').select().where('repoTag', req.params.name)
|
||||
knex('image').select().where('repoTag', imageName)
|
||||
.then (images) ->
|
||||
throw new Error('Only images created via the Supervisor can be deleted.') if images.length == 0
|
||||
knex('image').where('repoTag', req.params.name).delete()
|
||||
knex('image').where('repoTag', imageName).delete()
|
||||
.then ->
|
||||
docker.getImage(req.params.name).removeAsync(sanitizeQuery(req.query))
|
||||
docker.getImage(imageName).removeAsync(sanitizeQuery(req.query))
|
||||
.then (data) ->
|
||||
res.json(data)
|
||||
.catch (err) ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user