...

Source file src/github.com/docker/distribution/errors.go

Documentation: github.com/docker/distribution

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

View as plain text