-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add URL validation #97 #100
Conversation
Welcome @u5surf! It looks like this is your first PR to GoogleCloudPlatform/k8s-cluster-bundle 🎉 |
pkg/validation/validate_url.go
Outdated
) | ||
|
||
// ValidateURL validates urls in object files follwing Go's net/url parsing rules. | ||
func ValidateURL(u string) error { |
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.
Let's make this private; I don't think it needs to be public
Thanks for the PR! |
pkg/validation/validate_url_test.go
Outdated
return | ||
} | ||
return // no error, not a problem | ||
} else { |
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.
nit: don't need the else here.
Can you update the bazel BUILD file? Once you have |
/retest |
/ok-to-test |
pkg/validation/validate_url_test.go
Outdated
desc string | ||
in string | ||
scheme string | ||
path string |
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.
Let's just remove path -- it's not used any longer.
t.Run(tc.desc, func(t *testing.T) { | ||
err := validateURL(tc.in) | ||
if err == nil { | ||
if tc.errSubstr != "" && !strings.Contains(err.Error(), tc.errSubstr) { |
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.
this isn't quite right. err == nil means that err.Error() is dereferencing a nil object.
There should be a case where err != nil and you check this. I got this wrong in validate_names, which is probably why this is wrong here. I'll go fix that.
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 |
#97
I added url validation following rules of Go’s net/url Parse.