mirror of
https://github.com/rancher/os.git
synced 2025-09-02 07:15:41 +00:00
move dependencies to vendor
This commit is contained in:
30
vendor/github.com/docker/libcompose/lookup/file.go
generated
vendored
Normal file
30
vendor/github.com/docker/libcompose/lookup/file.go
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package lookup
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
// FileConfigLookup is a "bare" structure that implements the project.ConfigLookup interface
|
||||
type FileConfigLookup struct {
|
||||
}
|
||||
|
||||
// Lookup returns the content and the actual filename of the file that is "built" using the
|
||||
// specified file and relativeTo string. file and relativeTo are supposed to be file path.
|
||||
// If file starts with a slash ('/'), it tries to load it, otherwise it will build a
|
||||
// filename using the folder part of relativeTo joined with file.
|
||||
func (f *FileConfigLookup) Lookup(file, relativeTo string) ([]byte, string, error) {
|
||||
if strings.HasPrefix(file, "/") {
|
||||
logrus.Debugf("Reading file %s", file)
|
||||
bytes, err := ioutil.ReadFile(file)
|
||||
return bytes, file, err
|
||||
}
|
||||
|
||||
fileName := path.Join(path.Dir(relativeTo), file)
|
||||
logrus.Debugf("Reading file %s relative to %s", fileName, relativeTo)
|
||||
bytes, err := ioutil.ReadFile(fileName)
|
||||
return bytes, fileName, err
|
||||
}
|
Reference in New Issue
Block a user