Skip to content

Conversation

@yevgenypats
Copy link
Contributor

Fixes: defaults, validation and unknown keys

Also, this enable to detect unusued keys which is useful in typos
and/or deprecated options.
@yevgenypats
Copy link
Contributor Author

Closes cloudquery/cloudquery#2054

Comment on lines +51 to +54
"invalid_kind",
`kind: nice`,
"failed to decode spec: unknown kind nice",
nil,
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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")
Copy link
Member

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?

Copy link
Contributor Author

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

yevgenypats and others added 3 commits September 27, 2022 15:05
Co-authored-by: Herman Schaaf <hermanschaaf@gmail.com>
Co-authored-by: Herman Schaaf <hermanschaaf@gmail.com>
@yevgenypats yevgenypats enabled auto-merge (squash) September 27, 2022 14:21
@yevgenypats yevgenypats merged commit ba9128a into main Sep 27, 2022
@yevgenypats yevgenypats deleted the fix/spec_unmarshal branch September 27, 2022 14:23
yevgenypats pushed a commit that referenced this pull request Sep 27, 2022
🤖 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") {
Copy link
Member

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")
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants