-
Notifications
You must be signed in to change notification settings - Fork 0
/
olm
executable file
·48 lines (42 loc) · 1.49 KB
/
olm
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
#!/bin/bash
set -e
. /opt/precache/common
process_index_db(){
db_path=$1
operators_spec_file=$2
log_debug "Index image is database-based. This format is deprecated."
/usr/libexec/platform-python /opt/precache/olm_db.py "${db_path}" "${operators_spec_file}" "/tmp/images.txt"
return $?
}
process_index_filesystem(){
index_path=$1
log_debug "Index image is file system based. This format is not yet implemented."
return 1
}
main(){
declare -i ret_val=0
# There could be several indexes, hence the loop
for index in $(sort -u $config_volume_path/operators.indexes) ; do
image_id=$(podman pull --quiet $index --root="/cache" --authfile=/var/lib/kubelet/config.json )
log_debug "$index image ID is $image_id"
image_mount=$(podman --root="/cache" image mount $image_id)
log_debug "Image mount: $image_mount"
operators_spec_file="$config_volume_path/operators.packagesAndChannels"
if [[ -f "$image_mount/database/index.db" ]]; then
process_index_db $image_mount/database/index.db $operators_spec_file
else
process_index_filesystem $image_mount $operators_spec
fi
ret_val=ret_val+$?
podman image unmount $image_id
done
log_debug "OLM pull spec extraction done"
if [[ $ret_val -ne 0 ]]; then
log_debug "Some of the extractions failed, please check the log."
fi
return $ret_val
}
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
main "${@}"
exit $?
fi