-
Notifications
You must be signed in to change notification settings - Fork 26
fix: Spec unmarshalling now supports defaults and validation #181
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
Conversation
31cde61 to
c87bf0e
Compare
Also, this enable to detect unusued keys which is useful in typos and/or deprecated options.
c87bf0e to
7636ec7
Compare
|
Closes cloudquery/cloudquery#2054 |
| "invalid_kind", | ||
| `kind: nice`, | ||
| "failed to decode spec: unknown kind nice", | ||
| nil, |
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: let's add keys to these struct instantiations
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 feel for this test driven use-case it reduces the boilerplate imo and makes it easier to add new tests. just opinion ofc.
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.
Makes sense, though as someone reading it for the first time, I found it hard to know what all these parameters were for, and had to scroll up and down a few times. I think it improves readability if you have the keys right there
| return fmt.Errorf("version is required") | ||
| } | ||
| if !strings.HasPrefix(s.Version, "v") { | ||
| return fmt.Errorf("version must start with v") |
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.
Do we not support latest version at all anymore?
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.
nope. per cloudquery/cloudquery#2054 . I think it's the right approach such as with any other package managers (go, npm) they are not supporting latest
Co-authored-by: Herman Schaaf <hermanschaaf@gmail.com>
Co-authored-by: Herman Schaaf <hermanschaaf@gmail.com>
🤖 I have created a release *beep* *boop* --- ## [0.9.2](v0.9.1...v0.9.2) (2022-09-27) ### Bug Fixes * Spec unmarshalling now supports defaults and validation ([#181](#181)) ([ba9128a](ba9128a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
| if d.Version == "" { | ||
| return fmt.Errorf("version is required") | ||
| } | ||
| if !strings.HasPrefix(d.Version, "v") { |
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, we should do full SemVer validation as the following string vv1.0.0 passes this validation
| return fmt.Errorf("version is required") | ||
| } | ||
| if !strings.HasPrefix(d.Version, "v") { | ||
| return fmt.Errorf("version must start with v") |
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.
Then change this error message to version must be a valid SemVer string)
Fixes: defaults, validation and unknown keys