Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
1c97b3a1
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c97b3a1
编写于
4月 29, 2020
作者:
L
LiFeng
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
image: add list images info
Signed-off-by:
N
LiFeng
<
lifeng68@huawei.com
>
上级
2758b739
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
83 deletion
+31
-83
src/image/image.c
src/image/image.c
+0
-1
src/image/oci/oci_common_operators.c
src/image/oci/oci_common_operators.c
+26
-73
src/image/oci/storage/storage.c
src/image/oci/storage/storage.c
+4
-8
src/image/oci/storage/storage.h
src/image/oci/storage/storage.h
+1
-1
未找到文件。
src/image/image.c
浏览文件 @
1c97b3a1
...
...
@@ -73,7 +73,6 @@ static const struct bim_ops g_embedded_ops = {
};
#endif
/* isula image server */
#ifdef ENABLE_OCI_IMAGE
static
const
struct
bim_ops
g_oci_ops
=
{
.
init
=
oci_init
,
...
...
src/image/oci/oci_common_operators.c
浏览文件 @
1c97b3a1
...
...
@@ -277,55 +277,10 @@ out:
static
int
oci_list_all_images
(
imagetool_images_list
*
images_list
)
{
#if 0
TODO call storage list images
int ret = 0;
size_t i = 0;
oci_image_t **images_info = NULL;
size_t images_num = 0;
ret = oci_images_store_list(&images_info, &images_num);
if (ret != 0) {
ERROR("query all oci images info failed");
return -1;
}
if (images_num == 0) {
ret = 0;
goto out;
}
images_list->images = util_smart_calloc_s(sizeof(imagetool_image *), images_num);
if (images_list->images == NULL) {
ERROR("Out of memory");
ret = -1;
goto out;
}
for (i = 0; i < images_num; i++) {
ret = dup_oci_image_info(images_info[i]->info, &images_list->images[i]);
if (ret != 0) {
ERROR("Failed to dup oci image %s info", images_info[i]->info->id);
ret = -1;
goto out;
}
oci_image_unref(images_info[i]);
images_list->images_len++;
}
out:
if (ret != 0) {
for (; i < images_num; i++) {
oci_image_unref(images_info[i]);
}
}
free(images_info);
return ret;
#endif
return
0
;
return
storage_get_all_images
(
images_list
);
}
#if 0
static
bool
image_meet_dangling_filter
(
const
imagetool_image
*
src
,
const
struct
filters_args
*
filters
)
{
bool
ret
=
false
;
...
...
@@ -365,29 +320,27 @@ static bool image_meet_dangling_filter(const imagetool_image *src, const struct
static
int
do_image_time_filter
(
map_itor
*
itor
,
bool
is_before_filter
,
int64_t
*
cmp_nanos
)
{
int
ret
=
0
;
oci_image_t *image_info = NULL;
int64_t
tmp_nanos
=
0
;
imagetool_image
*
image_info
=
NULL
;
char
*
tmp
=
oci_resolve_image_name
(
map_itor_key
(
itor
));
if
(
tmp
==
NULL
)
{
ERROR
(
"Failed to resolve image name"
);
goto
out
;
}
image_info = oci_images_store_get(tmp);
// TODO get image info from storage
// image_info = oci_images_store_get(tmp);
if
(
image_info
==
NULL
)
{
ret
=
-
1
;
goto
out
;
}
free(tmp);
tmp = NULL;
if (to_unix_nanos_from_str(image_info->
info->
created, &tmp_nanos) != 0) {
if
(
to_unix_nanos_from_str
(
image_info
->
created
,
&
tmp_nanos
)
!=
0
)
{
ERROR
(
"Failed to get unix nano from string"
);
ret
=
-
1
;
goto
out
;
}
oci_image_unref(image_info);
image_info = NULL;
if
(
is_before_filter
)
{
if
(
*
cmp_nanos
>
tmp_nanos
)
{
...
...
@@ -400,7 +353,7 @@ static int do_image_time_filter(map_itor *itor, bool is_before_filter, int64_t *
}
out:
oci_image_unref
(image_info);
free_imagetool_image
(
image_info
);
free
(
tmp
);
return
ret
;
}
...
...
@@ -536,7 +489,7 @@ static bool image_meet_filters(const imagetool_image *src, const struct filters_
image_meet_reference_filter
(
src
,
filters
);
}
static int dup_oci_image_info_by_filters(
oci_image_t
*src, const struct filters_args *filters,
static
int
dup_oci_image_info_by_filters
(
const
imagetool_image
*
src
,
const
struct
filters_args
*
filters
,
imagetool_images_list
*
images_list
)
{
int
ret
=
0
;
...
...
@@ -546,15 +499,15 @@ static int dup_oci_image_info_by_filters(oci_image_t *src, const struct filters_
imagetool_image
*
tmp_image
=
NULL
;
size_t
new_size
,
old_size
;
if (src == NULL
|| src->info == NULL
) {
if
(
src
==
NULL
)
{
goto
out
;
}
if (!image_meet_filters(src
->info
, filters)) {
if
(
!
image_meet_filters
(
src
,
filters
))
{
goto
out
;
}
json = imagetool_image_generate_json(src
->info
, NULL, &err);
json
=
imagetool_image_generate_json
(
src
,
NULL
,
&
err
);
if
(
json
==
NULL
)
{
ERROR
(
"Failed to generate json: %s"
,
err
);
ret
=
-
1
;
...
...
@@ -602,33 +555,33 @@ static int oci_list_images_by_filters(struct filters_args *filters, imagetool_im
int
ret
=
0
;
int
nret
;
size_t
i
=
0
;
oci_image_t **images_info = NULL;
size_t images_num = 0;
imagetool_images_list
*
all_images
=
NULL
;
ret = oci_images_store_list(&images_info, &images_num);
if (ret != 0) {
ERROR("query all oci images info failed");
return -1;
all_images
=
util_common_calloc_s
(
sizeof
(
imagetool_images_list
));
if
(
all_images
==
NULL
)
{
ERROR
(
"Memory out"
);
ret
=
-
1
;
goto
out
;
}
if (images_num == 0) {
ret = 0;
if
(
storage_get_all_images
(
all_images
)
!=
0
)
{
ERROR
(
"Failed to get all images info"
);
ret
=
-
1
;
goto
out
;
}
for (i = 0; i <
images_num
; i++) {
nret = dup_oci_image_info_by_filters(
images_info
[i], filters, images_list);
for
(
i
=
0
;
i
<
all_images
->
images_len
;
i
++
)
{
nret
=
dup_oci_image_info_by_filters
(
all_images
->
images
[
i
],
filters
,
images_list
);
if
(
nret
!=
0
)
{
WARN
(
"Failed to dup oci image info"
);
}
oci_image_unref(images_info[i]);
}
out:
free
(images_info
);
free
_imagetool_images_list
(
all_images
);
return
ret
;
}
#endif
static
void
oci_strip_all_dockerios
(
const
imagetool_images_list
*
images
)
{
size_t
i
=
0
;
...
...
@@ -661,7 +614,7 @@ int oci_list_images(const im_list_request *request, imagetool_images_list **imag
}
if
(
image_filters
!=
NULL
)
{
// TODO
ret = oci_list_images_by_filters(image_filters, *images);
ret
=
oci_list_images_by_filters
(
image_filters
,
*
images
);
}
else
{
ret
=
oci_list_all_images
(
*
images
);
}
...
...
src/image/oci/storage/storage.c
浏览文件 @
1c97b3a1
...
...
@@ -347,13 +347,12 @@ out:
return
ret
;
}
int
storage_get_all_images
(
imagetool_images_list
*
*
images
)
int
storage_get_all_images
(
imagetool_images_list
*
images
)
{
int
ret
=
0
;
imagetool_images_list
*
images_tmp
=
NULL
;
i
mages_tmp
=
util_common_calloc_s
(
sizeof
(
imagetool_images_list
));
if
(
images_tmp
==
NULL
)
{
i
f
(
images
==
NULL
)
{
ERROR
(
"Invalid input arguments"
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -362,12 +361,9 @@ int storage_get_all_images(imagetool_images_list **images)
// ret = -1;
// goto out;
// }
*
images
=
images_tmp
;
images_tmp
=
NULL
;
// ret = image_store_get_all_images(images);
out:
free_imagetool_images_list
(
images_tmp
);
return
ret
;
}
...
...
src/image/oci/storage/storage.h
浏览文件 @
1c97b3a1
...
...
@@ -83,7 +83,7 @@ int storage_img_set_loaded_time(const char *img_id, types_timestamp_t *loaded_ti
int
storage_img_set_names
(
const
char
*
img_id
,
const
char
**
names
,
size_t
names_len
);
int
storage_get_all_images
(
imagetool_images_list
*
*
images
);
int
storage_get_all_images
(
imagetool_images_list
*
images
);
int
storage_get_images_fs_usage
(
imagetool_fs_info
*
fs_info
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录