Skip to content

Commit acaf504

Browse files
committed
Init
1 parent fe1413d commit acaf504

23 files changed

+35236
-2
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.wsjcpp/*
2+
.logs/*
3+
wsjcpp-docker-api
4+
tmp/*
5+
.vscode/*
6+
.DS_Store
7+
18
# Prerequisites
29
*.d
310

CMakeLists.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
cmake_minimum_required(VERSION 3.0)
2+
3+
project(wsjcpp-docker-api C CXX)
4+
5+
include(${CMAKE_CURRENT_SOURCE_DIR}/src.wsjcpp/CMakeLists.txt)
6+
7+
#### BEGIN_WSJCPP_APPEND
8+
#### END_WSJCPP_APPEND
9+
10+
set(CMAKE_CXX_STANDARD 11)
11+
set(EXECUTABLE_OUTPUT_PATH ${wsjcpp-docker-api_SOURCE_DIR})
12+
13+
# include header dirs
14+
list (APPEND WSJCPP_INCLUDE_DIRS "src")
15+
16+
list (APPEND WSJCPP_SOURCES "src/main.cpp")
17+
list (APPEND WSJCPP_SOURCES "src/wsjcpp_docker_api.h")
18+
list (APPEND WSJCPP_SOURCES "src/wsjcpp_docker_api.cpp")
19+
20+
include_directories(${WSJCPP_INCLUDE_DIRS})
21+
22+
add_executable (wsjcpp-docker-api ${WSJCPP_SOURCES})
23+
24+
target_link_libraries(wsjcpp-docker-api ${WSJCPP_LIBRARIES})
25+
26+
install(
27+
TARGETS
28+
wsjcpp-docker-api
29+
RUNTIME DESTINATION
30+
/usr/bin
31+
)
32+

README.md

+47-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
# wsjcpp-docker-api
2-
C++ wrapper for docker-api (used curl inside)
1+
# wsjcpp-docker-api-wrapper
2+
3+
C++ implementation for docker-api (used curl)
4+
5+
Main documentation for docker here:
6+
7+
https://docs.docker.com/engine/api/v1.40/
8+
9+
## Integrate to your project
10+
11+
```
12+
$ wsjcpp install "https://github.com/wsjcpp/wsjcpp-docker-api:master"
13+
```
14+
15+
or include files:
16+
17+
* `src.wsjcpp/nlohmann_json/json.hpp`
18+
* `src.wsjcpp/wsjcpp_core/wsjcpp_core.h`
19+
* `src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp`
20+
* `src/wsjcpp_docker_api.h`
21+
* `src/wsjcpp_docker_api.cpp`
22+
23+
## How to use
24+
25+
```
26+
#include <wsjcpp_core.h>
27+
#include <wsjcpp_docker_api.h>
28+
29+
...
30+
31+
// get default unix socket path (for linux and for mac)
32+
std::string sUnixSocketPath = dockerApi.getDefaultUnixSocketPath();
33+
if (!dockerApi.doConnectUnixSocketPath(sUnixSocketPath) ) {
34+
WSJCppLog::err(TAG, "Could not connect to '" + sUnixSocketPath + "'");
35+
return -1;
36+
}
37+
38+
// get list of images like a 'docker images'
39+
std::vector<WsjcppDockerImage> vImages;
40+
std::string sError;
41+
if (!dockerApi.getImages(vImages, sError)) {
42+
WSJCppLog::err(TAG, "Could not get list of images '" + sError + "'");
43+
return -1;
44+
}
45+
46+
```
47+

build_simple.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ ! -d tmp ]; then
4+
mkdir -p tmp
5+
fi
6+
7+
cd tmp
8+
cmake ..
9+
make
10+

0 commit comments

Comments
 (0)