-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (52 loc) · 1.97 KB
/
Copy pathmain.cpp
File metadata and controls
58 lines (52 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <string.h>
#include <iostream>
#include <algorithm>
#include <wsjcpp_core.h>
#include <wsjcpp_docker_api.h>
int main(int argc, const char* argv[]) {
std::string TAG = "MAIN";
std::string appName = std::string(WSJCPP_APP_NAME);
std::string appVersion = std::string(WSJCPP_APP_VERSION);
if (!WsjcppCore::dirExists(".logs")) {
WsjcppCore::makeDir(".logs");
}
WsjcppLog::setPrefixLogFile("wsjcpp");
WsjcppLog::setLogDirectory(".logs");
WsjcppDockerApi dockerApi;
std::string sUnixSocketPath = dockerApi.getDefaultUnixSocketPath();
if (!dockerApi.doConnectUnixSocketPath(sUnixSocketPath) ) {
WsjcppLog::err(TAG, "Could not connect to '" + sUnixSocketPath + "'");
return -1;
}
// std::string sResponse;
std::vector<WsjcppDockerImage> vImages;
std::string sError;
if (!dockerApi.getImages(vImages, sError)) {
WsjcppLog::err(TAG, "Could not get list of images '" + sError + "'");
return -1;
}
std::string sOutput = "\nImages: \n";
for (int i = 0; i < vImages.size(); i++) {
WsjcppDockerImage img = vImages[i];
sOutput +=
"\n"
" ID: " + img.getId() + "\n"
" SIZE: " + std::to_string(img.getSize()) + "\n";
if (img.getParentId().length() > 0) {
sOutput += " PARENT-ID: " + img.getParentId() + "\n";
}
std::vector<std::string> vRepoTags = img.getRepoTags();
std::string sTags = "";
for (int n = 0; n < vRepoTags.size(); n++) {
std::string sRepoTag = vRepoTags[n];
std::vector<std::string> vRepoTag = WsjcppCore::split(sRepoTag, ":");
sOutput += " REPOSITORY: " + vRepoTag[0] + "\n";
sOutput += " TAG: " + vRepoTag[1] + "\n";
}
sOutput +=
" CREATED: " + std::to_string(img.getCreated()) + ", " + WsjcppCore::formatTimeForWeb(img.getCreated()) + "\n"
;
}
WsjcppLog::info(TAG, sOutput);
return 0;
}