-
Notifications
You must be signed in to change notification settings - Fork 19
/
what-is
executable file
·45 lines (38 loc) · 1.27 KB
/
what-is
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
#!/bin/bash -e
# Identify the charm test framework and charm structure type of a charm git clone
# Tip: use `./get-charms master` to git clone all charms first.
charm_dir="$1"
usage="Usage example: ./what-is ~/git/charm-aodh"
if [ -z "$charm_dir" ]; then
echo $usage && exit 1
fi
if [ ! -d "$charm_dir" ]; then
echo "Not found ($charm_dir). Consider using ./get-charms master." && exit 1
fi
# Determine charm test framework
if (cd $charm_dir && find -maxdepth 3 -type f -name tests.yaml |
xargs grep "gate_bundles:" &> /dev/null); then
test_framework="zaza"
else
test_framework="unknown"
fi
# Determine charm structure (source charm or classic charm)
if (cd $charm_dir && find -path "./src/*" -name metadata.yaml |
xargs grep "name:" &> /dev/null); then
charm_structure="source"
elif (cd $charm_dir && find -maxdepth 1 -name metadata.yaml |
xargs grep "name:" &> /dev/null); then
if (cd $charm_dir && find -maxdepth 1 -name charm-helpers-hooks.yaml |
xargs grep "repo:" &> /dev/null); then
charm_structure="classic"
else
charm_structure="ops"
fi
else
charm_structure="unknown"
fi
if [ -f $charm_dir/.gitreview ]; then
echo $charm_structure-$test_framework
else
echo "ERROR: Not a charm" && exit 1
fi