-
Notifications
You must be signed in to change notification settings - Fork 363
55 lines (44 loc) · 1.97 KB
/
verify-manifest.yml
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
name: Check Velero Manifest
on: pull_request
jobs:
check-velero-manifest:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create kind cluster
uses: helm/kind-action@v1.5.0
- name: Install velero
run: |
echo "Determine the velero version"
VERSION=$(yq eval ".image.tag" charts/velero/values.yaml)
echo "Install velero $VERSION"
wget https://github.com/vmware-tanzu/velero/releases/download/${VERSION}/velero-${VERSION}-linux-amd64.tar.gz
tar -xvf velero-${VERSION}-linux-amd64.tar.gz
cd velero-${VERSION}-linux-amd64
sudo cp velero /usr/local/bin
velero version
- name: Compare manifests
run: |
cd charts/velero
mkdir -p diff_workspace
echo "Generate velero manifest file"
velero install --crds-only --dry-run -o yaml | kubectl apply --dry-run=client -f - -o yaml > diff_workspace/velero_manifest.yaml
echo "Generate crds manifest file"
kubectl apply --dry-run=client -f crds/ -o yaml > diff_workspace/crds_manifest.yaml
echo "Filter non-required values"
for yaml_file in diff_workspace/*.yaml; do
yq -i '.items |= sort_by(.metadata.name)' "$yaml_file"
yq -i 'del(.items[].metadata.creationTimestamp)' "$yaml_file"
yq -i 'del(.items[].metadata.annotations."kubectl.kubernetes.io/last-applied-configuration")' "$yaml_file"
yq -i 'del(.status)' "$yaml_file"
done
echo "Compare the two files using diff"
difference=$(diff diff_workspace/velero_manifest.yaml diff_workspace/crds_manifest.yaml) || true
if [ -z "$difference" ]; then
echo "Files are synced. No differences found."
else
echo "Differences between velero_manifest.yaml and crds_manifest.yaml:"
echo "$difference"
exit 1
fi