forked from k0sproject/k0s
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-calico.sh
More file actions
executable file
·41 lines (29 loc) · 797 Bytes
/
Copy pathget-calico.sh
File metadata and controls
executable file
·41 lines (29 loc) · 797 Bytes
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
#!/bin/bash
CSPLIT_BINARY="csplit"
# on MacOS, we need to use the homebrew coreutils (gnu-utils) version of csplit, named gcsplit by default
if [[ "$OSTYPE" == "darwin"* ]]; then
CSPLIT_BINARY="gcsplit"
fi
PATH=$PATH:$GOPATH/bin
DIR="static/manifests/calico"
mkdir -p $DIR
curl https://docs.projectcalico.org/manifests/calico.yaml -O
$CSPLIT_BINARY --digits=2 --quiet --prefix=$DIR/ calico.yaml "/---/" "{*}"
for f in $DIR/*
do
# skip directories
if [ -d $f ]; then
continue
fi
filename=$(yq r $f 'metadata.name')
kind=$(yq r $f 'kind')
if [[ $filename == "" || $kind == "" ]]; then
rm $f
continue
fi
echo "Processing $kind $filename"
mkdir -p $DIR/$kind
mv $f $DIR/$kind/$filename.yaml
done
# cleanup
rm calico.yaml