github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/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 "launchpad.net/juju-core/environs/storage" 11 "launchpad.net/juju-core/errors" 12 "launchpad.net/juju-core/utils" 13 ) 14 15 // EmptyStorage holds a StorageReader object that contains no files and 16 // offers no URLs. 17 var EmptyStorage storage.StorageReader = emptyStorage{} 18 19 type emptyStorage struct{} 20 21 func (s emptyStorage) Get(name string) (io.ReadCloser, error) { 22 return nil, errors.NotFoundf("file %q", name) 23 } 24 25 func (s emptyStorage) URL(name string) (string, error) { 26 return "", fmt.Errorf("file %q not found", name) 27 } 28 29 func (s emptyStorage) List(prefix string) ([]string, error) { 30 return nil, nil 31 } 32 33 // DefaultConsistencyStrategy is specified in the StorageReader interface. 34 func (s emptyStorage) DefaultConsistencyStrategy() utils.AttemptStrategy { 35 return utils.AttemptStrategy{} 36 } 37 38 // ShouldRetry is specified in the StorageReader interface. 39 func (s emptyStorage) ShouldRetry(err error) bool { 40 return false 41 }