-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
I left a comment on the original issue but want to make it clear that I think we should hold off on merging this until the importers are updated to match (or we rethink how we want this to work). Otherwise after using |
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.
Reviewing this now, although we might put this on a little hold.
Looks good 👍
Suggested some improvements.
manifest.go
Outdated
@@ -117,6 +121,9 @@ func validateManifest(s string) ([]error, error) { | |||
warns = append(warns, fmt.Errorf("Invalid key %q in %q", key, prop)) | |||
} | |||
} | |||
if !ruleProvided && len(props) > 0 { |
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 warn for no name
attribute in constraint/override too. With that we can be sure, we have at least one attribute and not empty. And this check should be performed before checking for missing rule.
Also, since there won't be any changing part in missing name
in constraint/override warning, you can create 2 separate variables for them, similar to the error variables in https://github.com/golang/dep/blob/v0.3.2/manifest.go#L31 . And use the same variables in tests to perform comparison.
manifest.go
Outdated
@@ -117,6 +121,9 @@ func validateManifest(s string) ([]error, error) { | |||
warns = append(warns, fmt.Errorf("Invalid key %q in %q", key, prop)) | |||
} | |||
} | |||
if !ruleProvided && len(props) > 0 { | |||
warns = append(warns, fmt.Errorf("version rule or source should be provided in %q", prop)) | |||
} |
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.
I think this should be a dynamic error with name
in it. So, maybe something like:
fmt.Errorf("branch, version, revision, or source should be provided for %q %q", prop, props["name"])
Which would look something like:
branch, version, revision, or source should be provided for "constraint" "github.com/foo/bar"
Since this warning would only show up after checking for missing constraint/override, we are sure that props["name"]
won't be empty.
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.
constraint
and not for override
because just the name
attribute is useful in case of overrides. Not the same case with constraints.
manifest_test.go
Outdated
@@ -233,15 +233,20 @@ func TestValidateManifest(t *testing.T) { | |||
[[constraint]] | |||
name = "github.com/foo/bar" | |||
`, | |||
wantWarn: []error{errors.New("metadata should be a TOML table")}, | |||
wantWarn: []error{ | |||
errors.New("metadata should be a TOML table"), |
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 improve this. This error can be put in a variable and reused, like the variables in https://github.com/golang/dep/blob/v0.3.2/manifest.go#L31.
Thanks for the review, I'll ping when I've fixed things up 😄 |
thanks for creating #1373, @carolynvs - i've marked this as blocked by that. |
@darkowlzz updated! |
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! 👍
As discussed earlier, since this is blocked by another issue, we will merge it after that's cleared.
Thanks!
However, I'm not sure why it's failing on Windows only 🤔
|
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.
ah! got it. So TestCaseInsentitiveGOPATH is a windows only test and it creates a file with content "[[constraint]]". And that's invalid with this change.
Let's make that a valid constraint.
153bafc
to
6d46589
Compare
Updated tests for manifest warnings for new rule
Dynamic version constraint error message Only warn for version constraint when it's a constraint field
#1414 was just merged and |
What does this do / why do we need it?
Constraints/Overrides configs should have a version rule or source.
Warn when it doesn't.
ex.
What should your reviewer look out for in this PR?
Which issue(s) does this PR fix?
fixes #1336