errors.go 854 B

12345678910111213141516171819202122232425262728293031
  1. package lib
  2. import "fmt"
  3. // imageNotFoundError implements an error returned when an image is not in the docker host.
  4. type imageNotFoundError struct {
  5. imageID string
  6. }
  7. // Error returns a string representation of an imageNotFoundError
  8. func (i imageNotFoundError) Error() string {
  9. return fmt.Sprintf("Image not found: %s", i.imageID)
  10. }
  11. // ImageNotFound returns the ID of the image not found on the docker host.
  12. func (i imageNotFoundError) ImageIDNotFound() string {
  13. return i.imageID
  14. }
  15. // ImageNotFound is an interface that describes errors caused
  16. // when an image is not found in the docker host.
  17. type ImageNotFound interface {
  18. ImageIDNotFound() string
  19. }
  20. // IsImageNotFound returns true when the error is caused
  21. // when an image is not found in the docker host.
  22. func IsErrImageNotFound(err error) bool {
  23. _, ok := err.(ImageNotFound)
  24. return ok
  25. }