Skip to content

Commit f45e89d

Browse files
use registry-support cache samples
Signed-off-by: Michael Valdron <[email protected]>
1 parent 46193a0 commit f45e89d

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

tests/build_parents_file.sh

+9-30
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ samples_dir=$(pwd)/samples/.cache
77
# default stacks directory
88
stacks_dir=${STACKS:-"$(pwd)/stacks"}
99
parents_file=$(pwd)/parents.yaml
10+
# Base directory path
11+
base_path=$(realpath $(dirname $(dirname $0)))
1012

1113
# YAML query cmd path
1214
YQ_PATH=${YQ_PATH:-yq}
@@ -17,34 +19,6 @@ if [ ! -z "${1}" ]; then
1719
samples_file=${1}
1820
fi
1921

20-
# Clones remote samples into cache directory
21-
clone_samples() {
22-
samples_len=$($YQ_PATH eval '.samples | length' ${samples_file})
23-
24-
# Removes old cached samples directory
25-
if [ -d ${samples_dir} ]; then
26-
rm -rf ${samples_dir}
27-
fi
28-
29-
for ((s_idx=0;s_idx<${samples_len};s_idx++)); do
30-
name=$($YQ_PATH eval .samples.${s_idx}.name ${samples_file})
31-
versions=($($YQ_PATH eval .samples.${s_idx}.versions.[].version ${samples_file}))
32-
33-
# Iterate through sample versions if sample has multi version support
34-
if [ ${#versions[@]} -ne 0 ]; then
35-
for ((v_idx=0;v_idx<${#versions[@]};v_idx++)); do
36-
remote_url=$($YQ_PATH eval .samples.${s_idx}.versions.${v_idx}.git.remotes.origin ${samples_file})
37-
38-
git clone --depth=1 ${remote_url} ${samples_dir}/${name}/${versions[$v_idx]}
39-
done
40-
else
41-
remote_url=$($YQ_PATH eval .samples.${s_idx}.git.remotes.origin ${samples_file})
42-
43-
git clone --depth=1 ${remote_url} ${samples_dir}/${name}
44-
fi
45-
done
46-
}
47-
4822
get_parent_version() {
4923
devfile=$1
5024
name=$2
@@ -229,12 +203,17 @@ get_children_of_parents() {
229203
echo ${children[@]}
230204
}
231205

232-
clone_samples
206+
if [ ! -d ${base_path}/registry-support ]
207+
then
208+
git clone https://github.com/devfile/registry-support ${base_path}/registry-support
209+
fi
210+
211+
bash ${base_path}/registry-support/build-tools/cache_samples.sh ${samples_file} ${samples_dir}
233212

234213
if [ -f ${parents_file} ]; then
235214
rm ${parents_file}
236215
fi
237216

238217
build_parents_file
239218

240-
echo $(get_children_of_parents)
219+
get_children_of_parents

0 commit comments

Comments
 (0)