github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/resource/opened.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package resource 5 6 // TODO(ericsnow) Move this file to the charm repo? 7 8 import ( 9 "io" 10 ) 11 12 // Opened provides both the resource info and content. 13 type Opened struct { 14 Resource 15 io.ReadCloser 16 } 17 18 // Content returns the "content" for the opened resource. 19 func (o Opened) Content() Content { 20 return Content{ 21 Data: o.ReadCloser, 22 Size: o.Size, 23 Fingerprint: o.Fingerprint, 24 } 25 } 26 27 // Opener exposes the functionality for opening a resource. 28 type Opener interface { 29 // OpenResource returns an opened resource with a reader that will 30 // stream the resource content. 31 OpenResource(name string) (Opened, error) 32 }