gopkg.in/juju/charm.v6-unstable@v6.0.0-20171026192109-50d0c219b496/bundle.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the LGPLv3, see LICENCE file for details.
     3  
     4  package charm
     5  
     6  import "os"
     7  
     8  // The Bundle interface is implemented by any type that
     9  // may be handled as a bundle. It encapsulates all
    10  // the data of a bundle.
    11  type Bundle interface {
    12  	// Data returns the contents of the bundle's bundle.yaml file.
    13  	Data() *BundleData
    14  	// Data returns the contents of the bundle's README.md file.
    15  	ReadMe() string
    16  }
    17  
    18  // ReadBundle reads a Bundle from path, which can point to either a
    19  // bundle archive or a bundle directory.
    20  func ReadBundle(path string) (Bundle, error) {
    21  	info, err := os.Stat(path)
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  	if info.IsDir() {
    26  		return ReadBundleDir(path)
    27  	}
    28  	return ReadBundleArchive(path)
    29  }