Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cmd/oci-runtime-tool/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -78,7 +77,7 @@ var bundleValidateCommand = cli.Command{
return err
}

configPath := path.Join(inputPath, "config.json")
configPath := filepath.Join(inputPath, "config.json")
Copy link

@Mashimiao Mashimiao Oct 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we replace all path.* to filepath.* and remove import "path" in this file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, I modified all path in 'validate.go' by updating the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

content, err := ioutil.ReadFile(configPath)
if err != nil {
return err
Expand All @@ -91,7 +90,12 @@ var bundleValidateCommand = cli.Command{
return err
}

rootfsPath := path.Join(inputPath, spec.Root.Path)
var rootfsPath string
if filepath.IsAbs(spec.Root.Path) {
rootfsPath = spec.Root.Path
} else {
rootfsPath = filepath.Join(inputPath, spec.Root.Path)
}
if fi, err := os.Stat(rootfsPath); err != nil {
return fmt.Errorf("Cannot find the root path %q", rootfsPath)
} else if !fi.IsDir() {
Expand Down Expand Up @@ -213,7 +217,7 @@ func checkProcess(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string
logrus.Debugf("check process")

process := spec.Process
if !path.IsAbs(process.Cwd) {
if !filepath.IsAbs(process.Cwd) {
msgs = append(msgs, fmt.Sprintf("cwd %q is not an absolute path", process.Cwd))
}

Expand All @@ -240,7 +244,7 @@ func checkProcess(spec rspec.Spec, rootfs string, hostCheck bool) (msgs []string
}

if len(process.ApparmorProfile) > 0 {
profilePath := path.Join(rootfs, "/etc/apparmor.d", process.ApparmorProfile)
profilePath := filepath.Join(rootfs, "/etc/apparmor.d", process.ApparmorProfile)
_, err := os.Stat(profilePath)
if err != nil {
msgs = append(msgs, err.Error())
Expand Down