forked from joelanford/example-operator-index
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsanity.sh
executable file
·74 lines (62 loc) · 1.57 KB
/
sanity.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# PNAME=$$(bin/yq "select(.schema == \"olm.package\") | .name" catalog/$(OPERATOR_NAME)/catalog.yaml)
# @echo `bin/yq "select(.schema == \"olm.package\") | .name" catalog/$(OPERATOR_NAME)/catalog.yaml`
# @export PNAME=$(shell bin/yq "select(.schema == \"olm.package\") | .name" catalog/$(OPERATOR_NAME)/catalog.yaml)
# @echo package name is $(PNAME)
# @if [ ${PNAME} != ${OPERATOR_NAME} ] \
# then \
# $(error "operator name in veneer and Makefile does not agree: Makefile(${OPERATOR_NAME}) Veneer:(${PNAME})")
# fi
function usage () {
echo "usage: $0 -n package-name -f veneer-file-name"
exit 1
}
function logit() {
if [ $QUIET_MODE -eq 0 ]; then
echo $1
fi
}
YQ=bin/yq
QUIET_MODE=0
while getopts 'n:f:q' arg;
do
case "$arg" in
f) FILENAME=$OPTARG ;;
n) PKGNAME=$OPTARG ;;
q) QUIET_MODE=1 ;;
h) usage ;;
esac
done
shift `expr $OPTIND - 1`
#echo "FILENAME is $FILENAME"
#echo "PKGNAME is $PKGNAME"
if [ -z $FILENAME ]
then
logit "veneer-file-name is empty"
usage
fi
if [ ! -e $FILENAME ]
then
logit "$FILENAME does not exist"
exit 253
fi
if [ -z $PKGNAME ]
then
logit "package-name is empty"
usage
fi
if [ ! -e $YQ ]
then
logit "unable to find yq binary: $YQ"
exit 255
fi
SCHEMA_PNAME=$($YQ "select(.schema == \"olm.package\") | .name" ${FILENAME})
if [ $SCHEMA_PNAME != $PKGNAME ]
then
logit "operator name in catalog and Makefile do not agree:"
logit " Makefile(${SCHEMA_PNAME})"
logit " catalog (${PKGNAME})"
exit 254
else
logit "operator name match between catalog and Makefile"
fi