clibdocker  0.1.0-alpha.0
A Docker API for C
docker_images.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2018-2022 Abhishek Mishra
4  *
5  * This file is part of clibdocker.
6  *
7  * clibdocker is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation,
10  * either version 3 of the License, or (at your option)
11  * any later version.
12  *
13  * clibdocker is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty
15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with clibdocker.
20  * If not, see <https://www.gnu.org/licenses/>.
21  *
22  */
23 
29 #ifndef SRC_DOCKER_IMAGES_H_
30 #define SRC_DOCKER_IMAGES_H_
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <coll_arraylist.h>
37 #include "docker_connection_util.h"
38 #include "docker_result.h"
39 #include "docker_util.h"
40 
44 #define DEFAULT_DOCKER_FILE_NAME "Dockerfile"
45 
60 typedef json_object docker_image;
61 
68 #define docker_image_id_get(img) get_attr_str((json_object*)img, "Id")
69 
76 #define docker_image_container_get(img) get_attr_str((json_object*)img, "Container")
77 
84 #define docker_image_comment_get(img) get_attr_str((json_object*)img, "Comment")
85 
92 #define docker_image_os_get(img) get_attr_str((json_object*)img, "Os")
93 
100 #define docker_image_architecture_get(img) get_attr_str((json_object*)img, "Architecture")
101 
108 #define docker_image_parent_get(img) get_attr_str((json_object*)img, "Parent")
109 
116 #define docker_image_docker_version_get(img) get_attr_str((json_object*)img, "DockerVersion")
117 
124 #define docker_image_virtual_size_get(img) get_attr_long_long((json_object*)img, "VirtualSize")
125 
132 #define docker_image_size_get(img) get_attr_long_long((json_object*)img, "Size")
133 
140 #define docker_image_author_get(img) get_attr_str((json_object*)img, "Author")
141 
148 #define docker_image_created_get(img) get_attr_unsigned_long((json_object*)img, "Created")
149 
160 #define docker_image_repo_tags_get(img) get_attr_json_object((json_object*)img, "RepoTags")
161 
169 #define docker_image_repo_tags_length(img) json_object_array_length(docker_image_repo_tags_get(img))
170 
179 #define docker_image_repo_tags_get_idx(img, i) (char*)json_object_get_string(json_object_array_get_idx(docker_image_repo_tags_get(img), i))
180 
191 #define docker_image_repo_digests_get(img) get_attr_json_object((json_object*)img, "RepoDigests")
192 
200 #define docker_image_repo_digests_length(img) json_object_array_length(docker_image_repo_digests_get(img))
201 
210 #define docker_image_repo_digests_get_idx(img, i) (char*)json_object_get_string(json_object_array_get_idx(docker_image_repo_digests_get(img), i))
211 
218 typedef json_object docker_image_list;
219 
225 #define free_docker_image_list(image_ls) json_object_put(image_ls)
226 
233 #define docker_image_list_length(image_ls) json_object_array_length(image_ls)
234 
242 #define docker_image_list_get_idx(image_ls, i) (docker_image*) json_object_array_get_idx(image_ls, i)
243 
259  docker_image_list** images, int all, int digests, char* filter_before,
260  int filter_dangling, char* filter_label, char* filter_reference,
261  char* filter_since);
262 
266 typedef struct docker_progress_detail_t {
267  long current;
268  long total;
270 
277  char* status;
278  char* id;
279  char* progress;
282 
287 typedef struct docker_build_status_t {
288  char* stream;
289  char* aux_id;
291 
292 //Docker Image Create commands
305  char* from_image, char* tag, char* platform);
306 
321  void (*status_cb)(docker_image_create_status*, void* cbargs),
322  void* cbargs, char* from_image, char* tag, char* platform);
323 
324 //error_t docker_image_create_from_src(docker_context* ctx, docker_result** res, char* from_src, char* repo, char* tag, char* platform);
325 
339  char* folder, char* dockerfile,
340  void (*status_cb)(docker_build_status*, void* cbargs),
341  void* cbargs, ...);
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 
347 #endif /* SRC_DOCKER_IMAGES_H_ */
Docker Connection Utils.
struct docker_build_status_t docker_build_status
Docker Build Status is used to provide a status update of the docker image build status.
json_object docker_image
The Docker Image object.
Definition: docker_images.h:60
json_object docker_image_list
Docker Image List object.
Definition: docker_images.h:218
d_err_t docker_image_build_cb(docker_context *ctx, char *folder, char *dockerfile, void(*status_cb)(docker_build_status *, void *cbargs), void *cbargs,...)
Definition: docker_images.c:259
struct docker_image_create_status_t docker_image_create_status
Docker Image Creation Status is returned when creating a docker image. It is useful for a user facing...
d_err_t docker_images_list(docker_context *ctx, docker_image_list **images, int all, int digests, char *filter_before, int filter_dangling, char *filter_label, char *filter_reference, char *filter_since)
Definition: docker_images.c:37
d_err_t docker_image_create_from_image_cb(docker_context *ctx, void(*status_cb)(docker_image_create_status *, void *cbargs), void *cbargs, char *from_image, char *tag, char *platform)
Definition: docker_images.c:148
d_err_t docker_image_create_from_image(docker_context *ctx, char *from_image, char *tag, char *platform)
Definition: docker_images.c:141
struct docker_progress_detail_t docker_progress_detail
Provides progress detail for docker image creation process.
Docker Results.
enum _config_error d_err_t
Definition: docker_result.h:60
Docker API utils.
Docker Build Status is used to provide a status update of the docker image build status.
Definition: docker_images.h:287
char * stream
the status stream
Definition: docker_images.h:288
char * aux_id
the aux id
Definition: docker_images.h:289
A docker context for a specific docker server.
Definition: docker_connection_util.h:141
Docker Image Creation Status is returned when creating a docker image. It is useful for a user facing...
Definition: docker_images.h:276
char * progress
progress description
Definition: docker_images.h:279
char * id
image id
Definition: docker_images.h:278
docker_progress_detail * progress_detail
progress detail (provides current and total steps)
Definition: docker_images.h:280
char * status
a status message from the docker api
Definition: docker_images.h:277
Provides progress detail for docker image creation process.
Definition: docker_images.h:266
long current
current value of progress bar
Definition: docker_images.h:267
long total
total value of progress bar
Definition: docker_images.h:268