Ive also taken the opportunity to improve the unit test suite drastically, to allow for actual testing of the AdmissionRequest and AdmissionResponse.Patch field contents, so we can explicitly see exactly what the mutate() handler does :)
It should be very easy now to create a new test case by:
create a AdmissionRequest in yaml at test/fixtures/k8s/admissioncontrol/request/foo.yaml
create a Patch JSON at test/fixtures/k8s/admissioncontrol/patch/foo.json
register your test in the pkg/server/webhook_test.go list mutationTests
It helpfully does proper JSON diffing so we can easily see how a patch fails, which will help with functionality like expecting the injector to not overwrite env vars that are already in the pod spec, etc.
Testing Steps
[x] Added unit tests for this feature (make test)
Reviewers
Required reviewers: @komapa @byxorna
Request reviews from other people you want to review this PR in the "Reviewers" section on the right.
:warning: this PR must have at least 2 thumbs from the MAINTAINERS.md of the project before merging!
What and why?
Fixes #20
Ive also taken the opportunity to improve the unit test suite drastically, to allow for actual testing of the
AdmissionRequest
andAdmissionResponse.Patch
field contents, so we can explicitly see exactly what themutate()
handler does :)It should be very easy now to create a new test case by:
test/fixtures/k8s/admissioncontrol/request/foo.yaml
test/fixtures/k8s/admissioncontrol/patch/foo.json
pkg/server/webhook_test.go
listmutationTests
It helpfully does proper JSON diffing so we can easily see how a patch fails, which will help with functionality like expecting the injector to not overwrite env vars that are already in the pod spec, etc.
Testing Steps
make test
)Reviewers
Required reviewers: @komapa @byxorna Request reviews from other people you want to review this PR in the "Reviewers" section on the right.