Fix initialization bug in FakeImageService

When adding this functionality in
https://github.com/kubernetes/kubernetes/pull/88372, I forgot to
allocate a map for the `Errors` field when constructing the object. As a
result, trying to actually use the `InjectError` method failed (as I
noticed when I started trying to write tests to actually use
`InjectError`). Fortunately, `FakeImageService` is only used in tests...
but still, we should fix this issue.

Fixing in a separate diff from the one which will add additional test
coverage (and actually use `InjectError`, because I don't like having
non-working code in master.)

We could also revert the original commit and then re-merge with this
fix, but that seems like unnecessary work given we already have a fix
ready to go.
This commit is contained in:
mattjmcnaughton 2020-02-22 12:06:40 -05:00
parent 57025b652e
commit 5362e8b6cb
No known key found for this signature in database
GPG Key ID: BC530981A9A1CC9D

View File

@ -65,6 +65,7 @@ func (r *FakeImageService) SetFakeFilesystemUsage(usage []*runtimeapi.Filesystem
func NewFakeImageService() *FakeImageService {
return &FakeImageService{
Called: make([]string, 0),
Errors: make(map[string][]error),
Images: make(map[string]*runtimeapi.Image),
}
}