-
Notifications
You must be signed in to change notification settings - Fork 59
/
bundle.go
41 lines (36 loc) · 1.08 KB
/
bundle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
package charm
import (
"os"
"path/filepath"
"strings"
)
// The Bundle interface is implemented by any type that
// may be handled as a bundle. It encapsulates all
// the data of a bundle.
type Bundle interface {
// Data returns the contents of the bundle's bundle.yaml file.
Data() *BundleData
// ReadMe returns the contents of the bundle's README.md file.
ReadMe() string
// ContainsOverlays returns true if the bundle contains any overlays.
ContainsOverlays() bool
}
// ReadBundle reads a Bundle from path, which can point to either a
// bundle archive or a bundle directory.
func ReadBundle(path string) (Bundle, error) {
info, err := os.Stat(path)
if err != nil {
return nil, err
}
if info.IsDir() {
return ReadBundleDir(path)
}
return ReadBundleArchive(path)
}
// IsValidLocalCharmOrBundlePath returns true if path is valid for reading a
// local charm or bundle.
func IsValidLocalCharmOrBundlePath(path string) bool {
return strings.HasPrefix(path, ".") || filepath.IsAbs(path)
}