mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #71667 from pohly/testfiles-absolute
e2e/framework: absolute test file paths
This commit is contained in:
commit
0f50fdc58d
@ -129,9 +129,16 @@ type RootFileSource struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReadTestFile looks for the file relative to the configured
|
// ReadTestFile looks for the file relative to the configured
|
||||||
// root directory.
|
// root directory. If the path is already absolute, for example
|
||||||
|
// in a test that has its own method of determining where
|
||||||
|
// files are, then the path will be used directly.
|
||||||
func (r RootFileSource) ReadTestFile(filePath string) ([]byte, error) {
|
func (r RootFileSource) ReadTestFile(filePath string) ([]byte, error) {
|
||||||
fullPath := filepath.Join(r.Root, filePath)
|
var fullPath string
|
||||||
|
if path.IsAbs(filePath) {
|
||||||
|
fullPath = filePath
|
||||||
|
} else {
|
||||||
|
fullPath = filepath.Join(r.Root, filePath)
|
||||||
|
}
|
||||||
data, err := ioutil.ReadFile(fullPath)
|
data, err := ioutil.ReadFile(fullPath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
// Not an error (yet), some other provider may have the file.
|
// Not an error (yet), some other provider may have the file.
|
||||||
|
Loading…
Reference in New Issue
Block a user