mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-18 14:54:19 +01:00
to the kata-containers repo under the src/tools/log-parser folder and vendor the modules Fixes: #4100 Signed-off-by: Snir Sheriber <ssheribe@redhat.com>
39 lines
681 B
Go
39 lines
681 B
Go
//
|
|
// Copyright (c) 2017-2018 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// resolvePath returns the fully resolved and expanded value of the
|
|
// specified path.
|
|
func resolvePath(path string) (string, error) {
|
|
if path == "" {
|
|
return "", fmt.Errorf("path must be specified")
|
|
}
|
|
|
|
absolute, err := filepath.Abs(path)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
resolved, err := filepath.EvalSymlinks(absolute)
|
|
if err != nil {
|
|
if os.IsNotExist(err) {
|
|
// Make the error clearer than the default
|
|
return "", fmt.Errorf("file %v does not exist", absolute)
|
|
}
|
|
|
|
return "", err
|
|
}
|
|
|
|
return resolved, nil
|
|
}
|