validate: Test config.json and rootfs sibling-hood#353
validate: Test config.json and rootfs sibling-hood#353liangchenye merged 1 commit intoopencontainers:masterfrom
Conversation
validate/validate.go
Outdated
| } | ||
|
|
||
| rootParent := filepath.Dir(absRootPath); | ||
| if rootParent == string(filepath.Separator) || rootParent != absBundlePath { |
There was a problem hiding this comment.
You mean rootParent can't be "/"? It seems there is no such limitation in SPEC.
There was a problem hiding this comment.
You mean rootParent can't be "/"?
That should be fine. The Separator comparison is intended to catch absRootPath being a spelling of /, based on the Dir docs:
The returned path does not end in a separator unless it is the root directory.
But I'll double check Dir("/") later tonight.
078bb17 to
8d697e8
Compare
validate/validate.go
Outdated
| if err != nil { | ||
| msgs = append(msgs, fmt.Sprintf("unable to convert %q to an absolute path", v.bundlePath)) | ||
| } | ||
| absBundlePath = filepath.Clean(absBundlePath) |
There was a problem hiding this comment.
Maybe we don't need this, Abs() calls Clean() on the result.
validate/validate.go
Outdated
| var absRootPath string | ||
| if filepath.IsAbs(v.spec.Root.Path) { | ||
| rootfsPath = v.spec.Root.Path | ||
| absRootPath = rootfsPath |
There was a problem hiding this comment.
I think adding filepath.Clean() here will be fine
validate/validate.go
Outdated
| msgs = append(msgs, fmt.Sprintf("unable to convert %q to an absolute path", rootfsPath)) | ||
| } | ||
| } | ||
| absRootPath = filepath.Clean(absRootPath) |
There was a problem hiding this comment.
removing this from here will be fine.
Test the spec's [1]: While these artifacts MUST all be present in a single directory on the local filesystem, ... which is a condition it imposes on config.json and the directory referenced by root.path. I think we should drop that restriction from the spec, but my attempt to remove the restriction was rejected [2]. If a future spec drops the restriction, we can revert this commit. Using path/filepath for the path manipulation will break when validating cross-platform configs (e.g. trying to validate a Windows bundle on a Linux machine). But that's a bigger issue than this commit, so I've left it alone for now. [1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc5/bundle.md#container-format [2]: opencontainers/runtime-spec#469 Signed-off-by: W. Trevor King <wking@tremily.us>
8d697e8 to
899afea
Compare
1 similar comment
|
Interesting, CI fails in getting golint. |
Test the spec's:
which is a condition it imposes on
config.jsonand the directory referenced byroot.path.I think we should drop that restriction from the spec, but my attempt to remove the restriction was rejected. If a future spec drops the restriction, we can revert this commit.
Using
path/filepathfor the path manipulation will break when validating cross-platform configs (e.g. trying to validate a Windows bundle on a Linux machine). But that's a bigger issue than this commit (previous discussion here and here), so I've left it alone for now.