-
Notifications
You must be signed in to change notification settings - Fork 42
Move version APIs to the specs-go package #214
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
Move version APIs to the specs-go package #214
Conversation
f3ac289
to
591c2a0
Compare
Signed-off-by: Ed Bartosh <[email protected]>
Signed-off-by: Ed Bartosh <[email protected]>
591c2a0
to
1e39659
Compare
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.
@elezar can you review this PR? |
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.
Thanks @bart0sh.
Definitely a great start. I think we can simplify the API that we expose w.r.t the versions and limit it to two functions:
ValidateVersion(*Spec) error
MinimumRequiredVersion(*Spec) (string, error)
1ff42ed
to
93c6586
Compare
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.
Thanks @bart0sh. It's looking a lot cleaner now.
I have some additional comments, but these are mostly limited to docstrings.
@@ -525,7 +525,7 @@ func specType(content []byte) string { | |||
} | |||
|
|||
func TestCurrentVersionIsValid(t *testing.T) { | |||
require.NoError(t, validateVersion(cdi.CurrentVersion)) | |||
require.NoError(t, cdi.ValidateVersion(&cdi.Spec{Version: cdi.CurrentVersion})) | |||
} | |||
|
|||
func TestRequiredVersion(t *testing.T) { |
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.
We could consider moving these to specs-go/version_test.go
.
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 would add a bunch of dependencies to specs-go/go.mod/sum, which would make it harder to import into k/k
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.
That is true. Let's leave it where it is then. does it at least make sense to move them to a version_text.go
file in this package then with note on their intent?
Would implementing them in a specs_test
package improve the dependency situation?
Signed-off-by: Ed Bartosh <[email protected]> Co-authored-by: Evan Lezar <[email protected]>
Signed-off-by: Ed Bartosh <[email protected]>
Signed-off-by: Ed Bartosh <[email protected]> Co-authored-by: Evan Lezar <[email protected]>
30d0688
to
54e62a8
Compare
specs-go/parser.go
Outdated
|
||
import "strings" | ||
|
||
// ParseQualifier splits a device qualifier into vendor and class. |
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.
It's out of scope for this PR, but we may want to be stricter on our language here. In the spec the entity we're parsing here is the Kind
, but this public function refers to it as a qualifier. Since we're in the specs
package here, do we want to rename this to SplitKind(string)
instead?
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.
Generally it makes sense to me. I'd propose to rename it to ParseKind
if you don't mind. And I agree, it's out of scope of this PR.
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.
OK. Let's do this as a follow-up then. (ParseKind
) is fine.
Signed-off-by: Ed Bartosh <[email protected]>
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.
Thanks for this @bart0sh.
I think the last comments I have are minor and can be addressed in follow-ups.
Signed-off-by: Ed Bartosh <[email protected]>
b1e626c
to
7dd001f
Compare
This is a partial fix for #206