Skip to content
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

Remove go-homedir dependency #1333

Merged
merged 1 commit into from
Apr 10, 2018
Merged

Conversation

justincormack
Copy link
Contributor

This is overcomplicated for a very simple requirement. It can call
exec, it has a cache protected by a mutex because it is so complex.
Just use the per platform environment variables which will always be
set, if the user has a weird environment they can specify full paths.

Signed-off-by: Justin Cormack justin.cormack@docker.com

Copy link
Contributor

@riyazdf riyazdf left a comment

Choose a reason for hiding this comment

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

LGTM on mac, not as familiar with windows

// homeExpand will expand an initial ~ to the user home directory. This is supported for
// config files where the shell will not have expanded paths.
func homeExpand(homeDir, path string) string {
if path == "" || path[1] != '~' || (len(path) > 1 && path[1] != os.PathSeparator) {
Copy link
Contributor

@cyli cyli Apr 9, 2018

Choose a reason for hiding this comment

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

Should path[1] != '~' be path[0] ~= '~'? Since we only want to expand if the first char is ~? (e.g. ~/.docker).

Also, how would we expand for something like ~cyli or ~justincormack? That is not the homedir of the current user, necessarily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes, typo, fixed now.

This has never worked with ~cyli etc so there is no change here. If you put that on the command line your shell will expand it before notary sees it anyway, so it is only for use in the config file, where it would be quite odd to put files in another user's home.

Copy link
Contributor

Choose a reason for hiding this comment

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

This has never worked with ~cyli etc so there is no change here. If you put that on the command line your shell will expand it before notary sees it anyway, so it is only for use in the config file, where it would be quite odd to put files in another user's home.

Ah ok, I didn't realize that library never expanded that correctly. But makes sense that we shouldn't put that in the config file.

@justincormack justincormack force-pushed the no-homedir branch 2 times, most recently from 6d4451a to 2141477 Compare April 9, 2018 17:17
@justincormack
Copy link
Contributor Author

justincormack commented Apr 9, 2018 via email

@cyli
Copy link
Contributor

cyli commented Apr 9, 2018

I should add some tests to clarify this.

That would be awesome, thanks. I was wondering if we had tests to make sure ~/ had been expanded correctly, but hadn't had a chance to look them up yet.

This is overcomplicated for a very simple requirement. It can call
`exec`, it has a cache protected by a mutex because it is so complex.
Just use the per platform environment variables which will always be
set, if the user has a weird environment they can specify full paths.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
@justincormack
Copy link
Contributor Author

Added a unit test for homeExpand.

Copy link
Contributor

@cyli cyli left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@cyli cyli merged commit 76c5c9a into notaryproject:master Apr 10, 2018
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