Shoot comparator
Overview
This tool compares shoot files created by KIM and Provisioner. It was created to ensure that KIM generates exactly the same shoots as Provisioner does.
For more details, please refer to the following issues:
Build
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./bin/shoot-comparator ./cmd
Run
To compare files, execute the following command:
shoot-comparator files <shoot file generated by Provisioner> <shoot file generated by KIM>
To compare directories, execute the following command:
shoot-comparator dirs <directory with shoot files generated by Provisioner> <directory with shoot files generated by KIM>
In order to save details of the comparison such as the exact differences between the files, use the --outputDir
flag:
shoot-comparator files <shoot file generated by Provisioner> <shoot file generated by KIM> --outputDir <output directory>
In order to specify the date from which the shoots should be compared, use the --fromDate
flag:
shoot-comparator files <shoot file generated by Provisioner> <shoot file generated by KIM> --fromDate <date>
Interpretation of the results
Compared directories are equal
The following is an example of the shoot-comparator
output when no differences are found:
2024/07/30 09:00:18 INFO Comparing directories: /tmp/kim-test/shoot-comparator/test1/kim and /tmp/kim-test/shoot-comparator/test1/provisioner
2024/07/30 09:00:18 INFO Saving comparison details
2024/07/30 09:00:18 INFO Results stored in "/tmp/kim-test/shoot-comparator/test1/results/2024-07-30T09:00:18+02:00"
2024/07/30 09:00:18 INFO No differences found.
The output directory will contain the result.txt
file. Exemplary content of the file:
Comparing files older than:0001-01-01 00:00:00 +0000 UTC
Number of files in /Users/myuser/dev/temp/kim-test/shoot-comparator/test1/kim directory = 2
Number of files in /Users/myuser/dev/temp/kim-test/shoot-comparator/test1/provisioner directory = 2
No differences found.
Compared directories differ
The following is an example of the shoot-comparator
output when differences are found:
2024/07/30 08:56:01 INFO Comparing directories: /tmp/kim-test/shoot-comparator/test2/kim and /tmp/kim-test/shoot-comparator/test2/provisioner
2024/07/30 08:56:01 INFO Saving comparison details
2024/07/30 08:56:01 INFO Results stored in "/tmp/kim-test/shoot-comparator/test2/results/2024-07-30T08:56:01+02:00"
2024/07/30 08:56:01 WARN Differences found.
Exemplary content of the result.txt
file:
Comparing files older than:0001-01-01 00:00:00 +0000 UTC
Number of files in /Users/myuser/dev/temp/kim-test/shoot-comparator/test2/kim directory = 2
Number of files in /Users/myuser/dev/temp/kim-test/shoot-comparator/test2/provisioner directory = 2
Differences found.
------------------------------------------------------------------------------------------
Files that differ:
- shoot1.yaml
------------------------------------------------------------------------------------------
The output directory will also contain the shoot1.yaml.diff
file with detailed file comparison results.
The following is an example of the result.txt
file when some files exist only in one of the directories:
Comparing files older than:0001-01-01 00:00:00 +0000 UTC
Number of files in /Users/myuser/dev/temp/kim-test/shoot-comparator/test3/kim directory = 22
Number of files in /Users/myuser/dev/temp/kim-test/shoot-comparator/test3/provisioner directory = 157
Differences found.
------------------------------------------------------------------------------------------
Files existing in /Users/myuser/dev/temp/kim-test/shoot-comparator/test3/kim folder only:
- garden-kyma-dev-kim-pvc-test3.yaml
- garden-kyma-dev-kims-aws-pvc-shootCR.yaml
------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
Files existing in /Users/myuser/dev/temp/kim-test/shoot-comparator/test3/provisioner folder only:
- garden-kyma-dev-a2f8da9.yaml
- garden-kyma-dev-a3008c5.yaml
------------------------------------------------------------------------------------------