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

Subdir support #40

Merged
merged 5 commits into from
Mar 27, 2018
Merged

Subdir support #40

merged 5 commits into from
Mar 27, 2018

Conversation

trajano
Copy link

@trajano trajano commented Mar 27, 2018

Fixes #35

Copy link
Author

@trajano trajano left a comment

Choose a reason for hiding this comment

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

FWIW, I don't find Go to be a fun language to program in :)

@@ -11,18 +11,26 @@ import (
)

const (
validHostnameRegex = `(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])`
validVolUriRegex = `([^:]+?):\/?([^\/]+)(/.+)?`
Copy link
Author

Choose a reason for hiding this comment

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

I am opting not to make the regex too strict, if the user decides to put in wrong input then it will just fail anyway. So I simplified it here

Copy link
Author

Choose a reason for hiding this comment

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

It will also allow special internationalized characters https://en.wikipedia.org/wiki/Internationalized_domain_name

Copy link
Owner

@sapk sapk Mar 27, 2018

Choose a reason for hiding this comment

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

It is better to fail at creation of volume and not mount and be strict to validate that.
It mostly important (at least for me) when using distributed docker like swarm because it will fail at creation of service and not try to mount (and remount and remount and ...) a false volume.
It allow for better error handling also otherwise it will be another case behind mount failling with just exit status 1. https://github.com/sapk/docker-volume-gluster/issues?utf8=%E2%9C%93&q=is%3Aissue+exit+status+1

I will fix this if you prefer for the rest thank you very much.

@@ -21,6 +21,10 @@ func TestIsValidURI(t *testing.T) {
{"192.168.1.:volume", false},
{"192.168.1.1,10.8.0.1:volume", true},
{"192.168.1.1,test2:volume", true},
{"192.168.1.1,test2:volume/subdir", true},
{"192.168.1.1,test2:/volume/subdir", true},
{"192.168.1.1,test2://volume/subdir", false},
Copy link
Author

Choose a reason for hiding this comment

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

double slashes in the beginning is not allowed from what I can tell.

@@ -18,9 +18,13 @@ func TestIsValidURI(t *testing.T) {
{"test,volume", false},
{"test,test2:volume", true},
{"192.168.1.1:volume", true},
{"192.168.1.:volume", false},
{"192.168.1.:volume", true},
Copy link
Owner

@sapk sapk Mar 27, 2018

Choose a reason for hiding this comment

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

From previous comment, this should fail

Copy link
Author

Choose a reason for hiding this comment

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

Feel free to update the PR. However, I still think making it loose will prevent future cases when some people have atypical but valid host names or volume names. Is there a way of extracting the error message so it can be displayed rather than status code is 1?

Copy link
Author

Choose a reason for hiding this comment

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

Hopefully we'd get a release I can try so I don't have to spend the effort of creating extra volumes.

@@ -18,9 +18,13 @@ func TestIsValidURI(t *testing.T) {
{"test,volume", false},
{"test,test2:volume", true},
{"192.168.1.1:volume", true},
{"192.168.1.:volume", false},
{"192.168.1.:volume", true},
Copy link
Author

Choose a reason for hiding this comment

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

this needed to change because I made the regex looser.

@@ -11,18 +11,26 @@ import (
)

const (
validHostnameRegex = `(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])`
validVolUriRegex = `([^:]+?):\/?([^\/]+)(/.+)?`
Copy link
Author

Choose a reason for hiding this comment

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

It will also allow special internationalized characters https://en.wikipedia.org/wiki/Internationalized_domain_name

@sapk sapk merged commit 4f227e9 into sapk:master Mar 27, 2018
sapk added a commit that referenced this pull request Mar 27, 2018
@sapk
Copy link
Owner

sapk commented Mar 27, 2018

Done thanks for the contrib.

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.

None yet

2 participants