Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
saltstack-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chalermpong
saltstack-api
Commits
979c06d7
Commit
979c06d7
authored
Sep 03, 2024
by
chalermpong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug file
parent
22709861
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletions
+31
-1
app.js
+2
-0
controller/getImageVersion.js
+26
-0
controller/index.js
+3
-1
No files found.
app.js
View file @
979c06d7
...
...
@@ -47,6 +47,8 @@ app.post('/apply-state', async (req, res) => {
await
controllers
.
dockerFileStatus
(
results
,
salt
);
}
else
if
(
state
===
'dockerps'
)
{
return
controllers
.
getDockerPsStatus
(
results
,
res
);
}
else
if
(
state
===
'checkversion'
)
{
return
controllers
.
getImageVersion
(
results
,
res
);
}
res
.
status
(
200
).
send
({
message
:
'Salt state applied successfully'
,
results
});
...
...
controller/getImageVersion.js
0 → 100644
View file @
979c06d7
// controller/getDockerImageVersion.js
async
function
getImageVersion
(
results
,
res
)
{
try
{
const
output
=
results
[
'salt-minion'
][
'cmd_|-docker_ps_status_|-docker images_|-run'
][
'changes'
][
'stdout'
];
const
lines
=
output
.
split
(
'
\
n'
);
const
images
=
lines
.
slice
(
1
).
filter
(
line
=>
line
.
trim
()
!==
''
).
map
(
line
=>
{
const
parts
=
line
.
trim
().
split
(
/
\s{2,}
/
);
return
{
repository
:
parts
[
0
],
tag
:
parts
[
1
],
size
:
parts
[
parts
.
length
-
1
]
// แก้ไขส่วนนี้เพื่อให้แสดง size ถูกต้อง
};
});
return
res
.
status
(
200
).
json
({
message
:
'Salt state applied successfully'
,
images
});
}
catch
(
error
)
{
console
.
error
(
'Error processing docker images output:'
,
error
);
res
.
status
(
500
).
send
({
error
:
'Error processing docker images output'
,
details
:
error
.
message
});
}
};
module
.
exports
=
getImageVersion
\ No newline at end of file
controller/index.js
View file @
979c06d7
...
...
@@ -6,6 +6,7 @@ const checkDirectory = require('./checkDirectory');
const
updateImage
=
require
(
'./updateImage'
);
const
install_packages
=
require
(
'./installpackages'
);
const
getDockerPsStatus
=
require
(
'./getDockerPsStatus'
);
const
getImageVersion
=
require
(
'./getImageVersion'
);
module
.
exports
=
{
checkDockerStatus
,
runDockerComposeUp
,
...
...
@@ -14,5 +15,6 @@ module.exports = {
checkDirectory
,
updateImage
,
install_packages
,
getDockerPsStatus
getDockerPsStatus
,
getImageVersion
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment