Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정민우
/
vps_service
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정민우
2021-06-11 03:40:35 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd5de420e7a7022d50b7f8e89478969f71f1e8b4
bd5de420
1 parent
9a08b13f
[Add] image list,remove 추가
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
2 deletions
backend/controllers/dockerController.js
backend/controllers/dockerController.js
View file @
bd5de42
...
...
@@ -85,8 +85,8 @@ exports.removeDockerfile = async (req, res) => {
return
sendError
(
res
,
404
,
'NoDockerfileFound'
)
}
if
(
!
user
||
user
.
id
!==
dockerfile
.
userId
)
{
logging
(
'dockerfile'
,
'error'
,
{
code
:
403
,
message
:
'Unautho
ir
zed'
},
req
)
return
sendError
(
res
,
403
,
'Unautho
ir
zed'
)
logging
(
'dockerfile'
,
'error'
,
{
code
:
403
,
message
:
'Unautho
ri
zed'
},
req
)
return
sendError
(
res
,
403
,
'Unautho
ri
zed'
)
}
await
Dockerfile
.
destroy
({
...
...
@@ -131,7 +131,38 @@ exports.buildImage = async (req, res) => {
}
exports
.
removeImage
=
async
(
req
,
res
)
=>
{
const
requiredKey
=
[
'id'
]
const
required
=
checkRequiredExist
(
req
.
body
,
requiredKey
)
if
(
required
)
{
logging
(
'image'
,
'error'
,
{
code
:
400
,
message
:
'missingKey:${required}'
},
req
)
return
sendError
(
res
,
400
,
`missingKey:
${
required
}
`
)
}
try
{
const
user
=
await
currentUser
(
req
.
headers
.
authorization
)
const
imageId
=
req
.
body
.
id
let
image
=
await
Image
.
findByPk
(
imageId
)
if
(
!
image
)
{
logging
(
'image'
,
'error'
,
{
code
:
404
,
message
:
'NoDockerfileFound'
},
req
)
return
sendError
(
res
,
404
,
'NoDockerfileFound'
)
}
let
dockerfile
=
await
Dockerfile
.
findByPk
(
image
.
dockerfileId
)
if
(
!
user
||
user
.
id
!==
dockerfile
.
userId
)
{
logging
(
'image'
,
'error'
,
{
code
:
403
,
message
:
'Unauthorized'
},
req
)
return
sendError
(
res
,
403
,
'Unauthorized'
)
}
await
Image
.
destroy
({
where
:
{
id
:
image
.
id
}
})
logging
(
'image'
,
'delete'
,
null
,
req
)
return
sendResponse
(
res
,
true
,
201
)
}
catch
(
error
)
{
logging
(
'image'
,
'error'
,
{
code
:
500
,
message
:
error
.
message
},
req
)
return
sendError
(
res
,
500
,
error
.
message
)
}
}
exports
.
listContainer
=
async
(
req
,
res
)
=>
{
...
...
Please
register
or
login
to post a comment