combine fileLoader.New and NewLoader into one function: NewLoader

This commit is contained in:
Jingfang Liu
2018-08-15 11:01:48 -07:00
parent f018370628
commit 72b1a4bc5c
6 changed files with 27 additions and 24 deletions

View File

@@ -53,17 +53,7 @@ func (l *fileLoader) Root() string {
// Example: "/home/seans/project" or "/home/seans/project/"
// NOT "/home/seans/project/file.yaml".
func (l *fileLoader) New(newRoot string) (Loader, error) {
if isRepoUrl(newRoot) {
return newGithubLoader(newRoot, l.fSys)
}
if !l.IsAbsPath(l.root, newRoot) {
return nil, fmt.Errorf("Not abs path: l.root='%s', loc='%s'\n", l.root, newRoot)
}
root, err := l.fullLocation(l.root, newRoot)
if err != nil {
return nil, err
}
return newFileLoaderAtRoot(root, l.fSys), nil
return NewLoader(newRoot, l.root, l.fSys)
}
// IsAbsPath return true if the location calculated with the root