forked from openshift-knative/knative-kafka-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catalog.sh
executable file
·47 lines (39 loc) · 1.13 KB
/
catalog.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
#!/usr/bin/env bash
DIR=${DIR:-$(cd $(dirname "$0")/.. && pwd)}
NAME=${NAME:-$(ls $DIR/deploy/olm-catalog)}
x=( $(echo $NAME | tr '-' ' ') )
DISPLAYNAME=${DISPLAYNAME:=${x[*]^}}
LATEST=$(find $DIR/deploy/olm-catalog -name '*version.yaml' | sort -n | sed "s/^.*\/\([^/]..*\).clusterserviceversion.yaml$/\1/" | tail -1)
indent() {
INDENT=" "
sed "s/^/$INDENT/" | sed "s/^${INDENT}\($1\)/${INDENT:0:-2}- \1/"
}
rm -rf $DIR/.crds
mkdir $DIR/.crds
find $DIR/deploy/olm-catalog -name '*_crd.yaml' | sort -n | xargs -I{} cp {} $DIR/.crds/
CRD=$(cat $(ls $DIR/.crds/*) | grep -v -- "---" | indent apiVersion)
CSV=$(cat $(find $DIR/deploy/olm-catalog -name '*version.yaml' | sort -n) | indent apiVersion)
PKG=$(cat $DIR/deploy/olm-catalog/$NAME/*package.yaml | indent packageName)
cat <<EOF | sed 's/^ *$//'
kind: ConfigMap
apiVersion: v1
metadata:
name: $NAME
data:
customResourceDefinitions: |-
$CRD
clusterServiceVersions: |-
$CSV
packages: |-
$PKG
---
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: $NAME
spec:
configMap: $NAME
displayName: $DISPLAYNAME
publisher: Red Hat
sourceType: internal
EOF