github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/state/toolstorage/interface.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package toolstorage 5 6 import ( 7 "io" 8 9 "github.com/juju/juju/version" 10 ) 11 12 // Metadata describes a Juju tools tarball. 13 type Metadata struct { 14 Version version.Binary 15 Size int64 16 SHA256 string 17 } 18 19 // Storage provides methods for storing and retrieving tools by version. 20 type Storage interface { 21 // AddTools adds the tools tarball and metadata into state, 22 // replacing existing metadata if any exists with the specified 23 // version. 24 AddTools(io.Reader, Metadata) error 25 26 // Tools returns the Metadata and tools tarball contents 27 // for the specified version if it exists, else an error 28 // satisfying errors.IsNotFound. 29 Tools(version.Binary) (Metadata, io.ReadCloser, error) 30 31 // AllMetadata returns metadata for the full list of tools in 32 // the catalogue. 33 AllMetadata() ([]Metadata, error) 34 35 // Metadata returns the Metadata for the specified version 36 // if it exists, else an error satisfying errors.IsNotFound. 37 Metadata(v version.Binary) (Metadata, error) 38 } 39 40 // StorageCloser extends the Storage interface with a Close method. 41 type StorageCloser interface { 42 Storage 43 Close() error 44 }