errors.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package distribution
  2. import (
  3. "errors"
  4. "fmt"
  5. "strings"
  6. "github.com/docker/distribution/digest"
  7. )
  8. // ErrAccessDenied is returned when an access to a requested resource is
  9. // denied.
  10. var ErrAccessDenied = errors.New("access denied")
  11. // ErrManifestNotModified is returned when a conditional manifest GetByTag
  12. // returns nil due to the client indicating it has the latest version
  13. var ErrManifestNotModified = errors.New("manifest not modified")
  14. // ErrUnsupported is returned when an unimplemented or unsupported action is
  15. // performed
  16. var ErrUnsupported = errors.New("operation unsupported")
  17. // ErrTagUnknown is returned if the given tag is not known by the tag service
  18. type ErrTagUnknown struct {
  19. Tag string
  20. }
  21. func (err ErrTagUnknown) Error() string {
  22. return fmt.Sprintf("unknown tag=%s", err.Tag)
  23. }
  24. // ErrRepositoryUnknown is returned if the named repository is not known by
  25. // the registry.
  26. type ErrRepositoryUnknown struct {
  27. Name string
  28. }
  29. func (err ErrRepositoryUnknown) Error() string {
  30. return fmt.Sprintf("unknown repository name=%s", err.Name)
  31. }
  32. // ErrRepositoryNameInvalid should be used to denote an invalid repository
  33. // name. Reason may set, indicating the cause of invalidity.
  34. type ErrRepositoryNameInvalid struct {
  35. Name string
  36. Reason error
  37. }
  38. func (err ErrRepositoryNameInvalid) Error() string {
  39. return fmt.Sprintf("repository name %q invalid: %v", err.Name, err.Reason)
  40. }
  41. // ErrManifestUnknown is returned if the manifest is not known by the
  42. // registry.
  43. type ErrManifestUnknown struct {
  44. Name string
  45. Tag string
  46. }
  47. func (err ErrManifestUnknown) Error() string {
  48. return fmt.Sprintf("unknown manifest name=%s tag=%s", err.Name, err.Tag)
  49. }
  50. // ErrManifestUnknownRevision is returned when a manifest cannot be found by
  51. // revision within a repository.
  52. type ErrManifestUnknownRevision struct {
  53. Name string
  54. Revision digest.Digest
  55. }
  56. func (err ErrManifestUnknownRevision) Error() string {
  57. return fmt.Sprintf("unknown manifest name=%s revision=%s", err.Name, err.Revision)
  58. }
  59. // ErrManifestUnverified is returned when the registry is unable to verify
  60. // the manifest.
  61. type ErrManifestUnverified struct{}
  62. func (ErrManifestUnverified) Error() string {
  63. return fmt.Sprintf("unverified manifest")
  64. }
  65. // ErrManifestVerification provides a type to collect errors encountered
  66. // during manifest verification. Currently, it accepts errors of all types,
  67. // but it may be narrowed to those involving manifest verification.
  68. type ErrManifestVerification []error
  69. func (errs ErrManifestVerification) Error() string {
  70. var parts []string
  71. for _, err := range errs {
  72. parts = append(parts, err.Error())
  73. }
  74. return fmt.Sprintf("errors verifying manifest: %v", strings.Join(parts, ","))
  75. }
  76. // ErrManifestBlobUnknown returned when a referenced blob cannot be found.
  77. type ErrManifestBlobUnknown struct {
  78. Digest digest.Digest
  79. }
  80. func (err ErrManifestBlobUnknown) Error() string {
  81. return fmt.Sprintf("unknown blob %v on manifest", err.Digest)
  82. }
  83. // ErrManifestNameInvalid should be used to denote an invalid manifest
  84. // name. Reason may set, indicating the cause of invalidity.
  85. type ErrManifestNameInvalid struct {
  86. Name string
  87. Reason error
  88. }
  89. func (err ErrManifestNameInvalid) Error() string {
  90. return fmt.Sprintf("manifest name %q invalid: %v", err.Name, err.Reason)
  91. }