-
Notifications
You must be signed in to change notification settings - Fork 240
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
Reject invalid endpoint #320
Conversation
b37cc40
to
447c5fa
Compare
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.
LGTM
@rmweir Looks like the test is failing tho in testing sqlite:
passing just an endpoint without a url should be allowed as well, like passing just |
@galal-hussein can we either change the test or explicity check for "sqlite"? Because the value gets totally discarded, its not evaluated. |
@galal-hussein I added an explicit check in a new commit so you can review it. If you're okay with that I can squash. |
ec630d7
to
d00b612
Compare
I would be willing to tighten this down to require a valid scheme. So if you want sqlite for example, you have to do at least Also, please do use the proper RFC3986 labels for the URI components in the error, not |
@brandond I think passing an empty storage endpoint is how one usually uses sqlite. I think expecting either a valid DSN URI or empty to imply an embedded backend is required, makes enough sense. Can we go with that? |
yeah thats what I meant. Either leave it empty, or pass a URI with a valid scheme and separator. The URI can have an empty authority/path/parameters to get whatever the defaults are for that backend. |
d6827f0
to
03a8ed2
Compare
@brandond I just updated the latest commit to what I was thinking. Lmk if that's fine and I will squash. If you want me too add some option for "sqlite://" I can do that too but I think we're okay without it. |
|
03a8ed2
to
37f8946
Compare
Prior, a non-empty endpoint of the incorrect format would cause an embedded sqlite backend to be used. By passing a non-empty endpoint the user is intending to use an external backend. Now, the endpoint will be validated and passing a non-empty endpoint of an incorrect format will result in an error. Signed-off-by: Ricardo Weir <ricardo.weir@loft.sh>
37f8946
to
b3743bd
Compare
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.
lgtm!
@brandond fixed test, also had to move validation to its own function as we use that network/address parsing function in multiple places where string could be empty, squashed all commits. Just take another pass on everything please as I don't want to sneak anything in. |
@@ -1,6 +1,6 @@ | |||
#!/bin/bash | |||
start-test() { | |||
KINE_IMAGE=$IMAGE KINE_ENDPOINT="sqlite" provision-kine | |||
KINE_IMAGE=$IMAGE KINE_ENDPOINT="" provision-kine |
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.
[sqlite] time="2024-09-03T21:27:16Z" level=fatal msg="flag needs an argument: -endpoint"
You can leave --endpoint
unset, but you can't currently set it to an empty string... so you should either fix the CLI flag, or explicitly set it.
KINE_IMAGE=$IMAGE KINE_ENDPOINT="" provision-kine | |
KINE_IMAGE=$IMAGE KINE_ENDPOINT="sqlite://" provision-kine |
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.
Actually I suspect that when the var is empty the script is just running kine --endpoint
instead of kine --endpoint ""
so the CLI framework is complaining that the flag doesn't have a value - which is valid.
You could change this
Line 254 in cb8c874
--endpoint $KINE_ENDPOINT |
to
--endpoint=$KINE_ENDPOINT
Signed-off-by: Ricardo Weir <ricardo.weir@loft.sh>
b3743bd
to
40b2102
Compare
@brandond @galal-hussein thanks for the fast replies! Will probably need someone to merge this for me as well once everything passes 😬. |
I'll wait for @galal-hussein to review again, then either one of us can merge and tag! |
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Support for 'sqlite' as the endpoint was removed in k3s-io/kine#320 and the constant removed in k3s-io/kine#325 Signed-off-by: Brad Davidson <brad.davidson@rancher.com> (cherry picked from commit 0942e6a) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
Problem:
Prior, a non-empty endpoint of the incorrect format would cause an embedded sqlite backend to be used. By passing a non-empty endpoint the user is intending to use an external backend.
Solution:
Now, the endpoint will be validated and passing a non-empty endpoint of an incorrect format will result in an error.
Issue:
#319