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

Add URL validation #97 #100

Merged
merged 5 commits into from
Nov 29, 2018
Merged

Conversation

u5surf
Copy link
Contributor

@u5surf u5surf commented Nov 27, 2018

#97
I added url validation following rules of Go’s net/url Parse.

@k8s-ci-robot
Copy link
Collaborator

Welcome @u5surf! It looks like this is your first PR to GoogleCloudPlatform/k8s-cluster-bundle 🎉

)

// ValidateURL validates urls in object files follwing Go's net/url parsing rules.
func ValidateURL(u string) error {
Copy link
Contributor

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

@artasparks
Copy link
Contributor

Thanks for the PR!

return
}
return // no error, not a problem
} else {
Copy link
Contributor

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.

@artasparks
Copy link
Contributor

Can you update the bazel BUILD file? Once you have bazel installed, you can run bazel run //:gazelle. Or, I suppose you can just run gazelle manually: https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-go

@artasparks
Copy link
Contributor

artasparks commented Nov 28, 2018

/retest

@artasparks
Copy link
Contributor

/ok-to-test

desc string
in string
scheme string
path string
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@artasparks
Copy link
Contributor

/lgtm

@artasparks artasparks merged commit 16dbfa2 into GoogleCloudPlatform:master Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants