1 // Copyright 2019 Nokia
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // tonyaw: refer to "kubernetes/helm/pkg/chartutil/load.go"
19 "k8s.io/helm/pkg/proto/hapi/chart"
22 helm_chartutil "k8s.io/helm/pkg/chartutil"
23 "github.com/ncw/swift"
26 // Load takes a string name, tries to resolve it to a file or directory, and then loads it.
28 // This is the preferred way to load a chart. It will discover the chart encoding
29 // and hand off to the appropriate chart reader.
31 // If a .helmignore file is present, the directory loader will skip loading any files
32 // matching it. But .helmignore is not evaluated when reading out of an archive.
33 func Load(c *swift.Connection, container, name string) (*chart.Chart, error) {
34 // tonyaw.TBD: ignore dir case for now.
35 // fi, err := os.Stat(name)
40 // return LoadDir(name)
42 return LoadFile(c, container, name)
46 // LoadFile loads from an archive file.
47 func LoadFile(c *swift.Connection, container, name string) (*chart.Chart, error) {
48 // tonyaw.TBD: ignore dir case for now.
49 // if fi, err := os.Stat(name); err != nil {
51 // } else if fi.IsDir() {
52 // return nil, errors.New("cannot load a directory")
55 object, _, err := c.ObjectOpen(container, name, false, nil)
61 return helm_chartutil.LoadArchive(object)
65 // LoadDir loads from a directory.
67 // This loads charts only from directories.
68 // tonyaw.TBD: do we still need "LoadDir" for swift?
69 func LoadDir(dir string) (*chart.Chart, error) {