github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/environs/emptystorage.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package environs 5 6 import ( 7 "fmt" 8 "io" 9 10 "github.com/juju/errors" 11 "github.com/juju/utils" 12 13 "github.com/juju/juju/environs/storage" 14 ) 15 16 // EmptyStorage holds a StorageReader object that contains no files and 17 // offers no URLs. 18 var EmptyStorage storage.StorageReader = emptyStorage{} 19 20 type emptyStorage struct{} 21 22 func (s emptyStorage) Get(name string) (io.ReadCloser, error) { 23 return nil, errors.NotFoundf("file %q", name) 24 } 25 26 func (s emptyStorage) URL(name string) (string, error) { 27 return "", fmt.Errorf("file %q not found", name) 28 } 29 30 func (s emptyStorage) List(prefix string) ([]string, error) { 31 return nil, nil 32 } 33 34 // DefaultConsistencyStrategy is specified in the StorageReader interface. 35 func (s emptyStorage) DefaultConsistencyStrategy() utils.AttemptStrategy { 36 return utils.AttemptStrategy{} 37 } 38 39 // ShouldRetry is specified in the StorageReader interface. 40 func (s emptyStorage) ShouldRetry(err error) bool { 41 return false 42 }