errors.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package distribution
  2. import (
  3. "errors"
  4. "fmt"
  5. "strings"
  6. "github.com/opencontainers/go-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. // ErrSchemaV1Unsupported is returned when a client tries to upload a schema v1
  18. // manifest but the registry is configured to reject it
  19. var ErrSchemaV1Unsupported = errors.New("manifest schema v1 unsupported")
  20. // ErrTagUnknown is returned if the given tag is not known by the tag service
  21. type ErrTagUnknown struct {
  22. Tag string
  23. }
  24. func (err ErrTagUnknown) Error() string {
  25. return fmt.Sprintf("unknown tag=%s", err.Tag)
  26. }
  27. // ErrRepositoryUnknown is returned if the named repository is not known by
  28. // the registry.
  29. type ErrRepositoryUnknown struct {
  30. Name string
  31. }
  32. func (err ErrRepositoryUnknown) Error() string {
  33. return fmt.Sprintf("unknown repository name=%s", err.Name)
  34. }
  35. // ErrRepositoryNameInvalid should be used to denote an invalid repository
  36. // name. Reason may set, indicating the cause of invalidity.
  37. type ErrRepositoryNameInvalid struct {
  38. Name string
  39. Reason error
  40. }
  41. func (err ErrRepositoryNameInvalid) Error() string {
  42. return fmt.Sprintf("repository name %q invalid: %v", err.Name, err.Reason)
  43. }
  44. // ErrManifestUnknown is returned if the manifest is not known by the
  45. // registry.
  46. type ErrManifestUnknown struct {
  47. Name string
  48. Tag string
  49. }
  50. func (err ErrManifestUnknown) Error() string {
  51. return fmt.Sprintf("unknown manifest name=%s tag=%s", err.Name, err.Tag)
  52. }
  53. // ErrManifestUnknownRevision is returned when a manifest cannot be found by
  54. // revision within a repository.
  55. type ErrManifestUnknownRevision struct {
  56. Name string
  57. Revision digest.Digest
  58. }
  59. func (err ErrManifestUnknownRevision) Error() string {
  60. return fmt.Sprintf("unknown manifest name=%s revision=%s", err.Name, err.Revision)
  61. }
  62. // ErrManifestUnverified is returned when the registry is unable to verify
  63. // the manifest.
  64. type ErrManifestUnverified struct{}
  65. func (ErrManifestUnverified) Error() string {
  66. return "unverified manifest"
  67. }
  68. // ErrManifestVerification provides a type to collect errors encountered
  69. // during manifest verification. Currently, it accepts errors of all types,
  70. // but it may be narrowed to those involving manifest verification.
  71. type ErrManifestVerification []error
  72. func (errs ErrManifestVerification) Error() string {
  73. var parts []string
  74. for _, err := range errs {
  75. parts = append(parts, err.Error())
  76. }
  77. return fmt.Sprintf("errors verifying manifest: %v", strings.Join(parts, ","))
  78. }
  79. // ErrManifestBlobUnknown returned when a referenced blob cannot be found.
  80. type ErrManifestBlobUnknown struct {
  81. Digest digest.Digest
  82. }
  83. func (err ErrManifestBlobUnknown) Error() string {
  84. return fmt.Sprintf("unknown blob %v on manifest", err.Digest)
  85. }
  86. // ErrManifestNameInvalid should be used to denote an invalid manifest
  87. // name. Reason may set, indicating the cause of invalidity.
  88. type ErrManifestNameInvalid struct {
  89. Name string
  90. Reason error
  91. }
  92. func (err ErrManifestNameInvalid) Error() string {
  93. return fmt.Sprintf("manifest name %q invalid: %v", err.Name, err.Reason)
  94. }