-
Notifications
You must be signed in to change notification settings - Fork 159
validate: Test config.json and rootfs sibling-hood #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate: Test config.json and rootfs sibling-hood #353
Conversation
validate/validate.go
Outdated
| } | ||
|
|
||
| rootParent := filepath.Dir(absRootPath); | ||
| if rootParent == string(filepath.Separator) || rootParent != absBundlePath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean rootParent can't be "/"? It seems there is no such limitation in SPEC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need this, Abs() calls Clean() on the result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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.