Skip to content

Conversation

@wking
Copy link
Contributor

@wking wking commented Mar 28, 2017

Test the spec's:

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. 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 (previous discussion here and here), so I've left it alone for now.

}

rootParent := filepath.Dir(absRootPath);
if rootParent == string(filepath.Separator) || rootParent != absBundlePath {

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, should be fixed with 078bb178d697e8.

@wking wking force-pushed the root-path-config-sibling branch from 078bb17 to 8d697e8 Compare March 29, 2017 03:29
if err != nil {
msgs = append(msgs, fmt.Sprintf("unable to convert %q to an absolute path", v.bundlePath))
}
absBundlePath = filepath.Clean(absBundlePath)

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks :). Addressed this (and your other Abs / Clean points) with 8d697e8899afea.

var absRootPath string
if filepath.IsAbs(v.spec.Root.Path) {
rootfsPath = v.spec.Root.Path
absRootPath = rootfsPath

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

msgs = append(msgs, fmt.Sprintf("unable to convert %q to an absolute path", rootfsPath))
}
}
absRootPath = filepath.Clean(absRootPath)

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]>
@wking wking force-pushed the root-path-config-sibling branch from 8d697e8 to 899afea Compare March 29, 2017 04:06
@Mashimiao
Copy link

Mashimiao commented Mar 29, 2017

LGTM

Approved with PullApprove

1 similar comment
@liangchenye
Copy link
Member

liangchenye commented Mar 30, 2017

LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit 38e8560 into opencontainers:master Mar 30, 2017
@liangchenye
Copy link
Member

Interesting, CI fails in getting golint.
I restart the build, it works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants