kubecontainer: add image ref to ImageService interfaces

This commit is contained in:
Pengfei Ni 2016-12-29 15:22:38 +08:00
parent 9a428cc5e0
commit cac38615ac
3 changed files with 12 additions and 12 deletions

View File

@ -146,10 +146,10 @@ type IndirectStreamingRuntime interface {
type ImageService interface { type ImageService interface {
// PullImage pulls an image from the network to local storage using the supplied // PullImage pulls an image from the network to local storage using the supplied
// secrets if necessary. // secrets if necessary. It returns a reference (digest or ID) to the pulled image.
PullImage(image ImageSpec, pullSecrets []v1.Secret) error PullImage(image ImageSpec, pullSecrets []v1.Secret) (string, error)
// IsImagePresent checks whether the container image is already in the local storage. // IsImagePresent checks whether the container image is already in the local storage.
IsImagePresent(image ImageSpec) (bool, error) IsImagePresent(image ImageSpec) (string, error)
// Gets all images currently on the machine. // Gets all images currently on the machine.
ListImages() ([]Image, error) ListImages() ([]Image, error)
// Removes the specified image. // Removes the specified image.

View File

@ -348,25 +348,25 @@ func (f *FakeRuntime) GetContainerLogs(pod *v1.Pod, containerID ContainerID, log
return f.Err return f.Err
} }
func (f *FakeRuntime) PullImage(image ImageSpec, pullSecrets []v1.Secret) error { func (f *FakeRuntime) PullImage(image ImageSpec, pullSecrets []v1.Secret) (string, error) {
f.Lock() f.Lock()
defer f.Unlock() defer f.Unlock()
f.CalledFunctions = append(f.CalledFunctions, "PullImage") f.CalledFunctions = append(f.CalledFunctions, "PullImage")
return f.Err return image.Image, f.Err
} }
func (f *FakeRuntime) IsImagePresent(image ImageSpec) (bool, error) { func (f *FakeRuntime) IsImagePresent(image ImageSpec) (string, error) {
f.Lock() f.Lock()
defer f.Unlock() defer f.Unlock()
f.CalledFunctions = append(f.CalledFunctions, "IsImagePresent") f.CalledFunctions = append(f.CalledFunctions, "IsImagePresent")
for _, i := range f.ImageList { for _, i := range f.ImageList {
if i.ID == image.Image { if i.ID == image.Image {
return true, nil return i.ID, nil
} }
} }
return false, f.InspectErr return "", f.InspectErr
} }
func (f *FakeRuntime) ListImages() ([]Image, error) { func (f *FakeRuntime) ListImages() ([]Image, error) {

View File

@ -105,14 +105,14 @@ func (r *Mock) GetContainerLogs(pod *v1.Pod, containerID ContainerID, logOptions
return args.Error(0) return args.Error(0)
} }
func (r *Mock) PullImage(image ImageSpec, pullSecrets []v1.Secret) error { func (r *Mock) PullImage(image ImageSpec, pullSecrets []v1.Secret) (string, error) {
args := r.Called(image, pullSecrets) args := r.Called(image, pullSecrets)
return args.Error(0) return image.Image, args.Error(0)
} }
func (r *Mock) IsImagePresent(image ImageSpec) (bool, error) { func (r *Mock) IsImagePresent(image ImageSpec) (string, error) {
args := r.Called(image) args := r.Called(image)
return args.Get(0).(bool), args.Error(1) return args.Get(0).(string), args.Error(1)
} }
func (r *Mock) ListImages() ([]Image, error) { func (r *Mock) ListImages() ([]Image, error) {